Skip to content

Commit

Permalink
智绘教20240228a
Browse files Browse the repository at this point in the history
+ 新增了对 WPS 的联动支持
+ PPT 联动控件底层重写,新的按键消息处理机制
+ 支持键盘和界面按钮长按翻页
+ 新增 PC鼠标 橡皮粗细灵敏度预设
= 选项界面增加更多丰富选项
? 修复了许多小 BUG 和改善了许多部分,以提升体验
  • Loading branch information
Alan-CRL authored Feb 29, 2024
2 parents 092ba28 + d683a6e commit fca7810
Show file tree
Hide file tree
Showing 28 changed files with 1,215 additions and 1,057 deletions.
111 changes: 56 additions & 55 deletions PptCOM/PptCOM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
using System.Runtime.InteropServices;

using Microsoft.Office.Core;
using PPT = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Interop.PowerPoint;

namespace PptCOM
{
Expand All @@ -61,6 +61,10 @@ public interface IPptCOMServer

int totalSlideIndex();

int NextSlideShow(int check);

int PreviousSlideShow();

IntPtr GetPptHwnd();

void EndSlideShow();
Expand All @@ -71,20 +75,24 @@ public interface IPptCOMServer
[Guid("C44270BE-9A52-400F-AD7C-ED42050A77D8")]
public class PptCOMServer : IPptCOMServer
{
public static Microsoft.Office.Interop.PowerPoint.Application pptApp;
public static Microsoft.Office.Interop.PowerPoint.Presentation pptDoc;
public static Microsoft.Office.Interop.PowerPoint.SlideShowWindow pptWindow;

public PptCOMServer()
{
}

public string LinkTest()
{
return "C# COM接口 连接成功,版本 20240123.01";
return "C# COM接口 连接成功,版本 20240226.02";
}

public string IsPptDependencyLoaded()
{
try
{
PPT.Application pptApp = new PPT.Application();
pptApp = (Microsoft.Office.Interop.PowerPoint.Application)Marshal.GetActiveObject("PowerPoint.Application");
return "组件正常";
}
catch (Exception ex)
Expand All @@ -100,16 +108,13 @@ public string slideNameIndex()
try
{
// 获取正在播放的PPT应用程序对象
PPT.Application pptApp = new PPT.Application();
pptApp = (Microsoft.Office.Interop.PowerPoint.Application)Marshal.GetActiveObject("PowerPoint.Application");
// 获取当前播放的PPT文档对象
PPT.Presentation pptDoc = pptApp.ActivePresentation;
pptDoc = pptApp.ActivePresentation;

// 获取正在播放的PPT的名称
slidesName = pptDoc.FullName;

// 释放资源
pptDoc = null;
pptApp = null;
slidesName += pptDoc.FullName + "\n";
slidesName += pptApp.Caption;
}
catch
{
Expand All @@ -125,22 +130,8 @@ public int currentSlideIndex()

try
{
// 获取正在播放的PPT应用程序对象
PPT.Application pptApp = new PPT.Application();
// 获取当前播放的PPT文档对象
PPT.Presentation pptDoc = pptApp.ActivePresentation;
// 获取当前播放的PPT幻灯片窗口对象
PPT.SlideShowWindow pptWindow = pptDoc.SlideShowWindow;
// 获取当前播放的幻灯片页对象
PPT.Slide pptSlide = pptWindow.View.Slide;
// 获取当前播放的幻灯片页索引
currentSlides = pptSlide.SlideIndex;

// 释放资源
pptSlide = null;
pptWindow = null;
pptDoc = null;
pptApp = null;
currentSlides = pptWindow.View.Slide.SlideIndex;
}
catch
{
Expand All @@ -157,46 +148,68 @@ public int totalSlideIndex()
try
{
// 获取正在播放的PPT应用程序对象
PPT.Application pptApp = new PPT.Application();
pptApp = (Microsoft.Office.Interop.PowerPoint.Application)Marshal.GetActiveObject("PowerPoint.Application");
// 获取当前播放的PPT文档对象
PPT.Presentation pptDoc = pptApp.ActivePresentation;
// 获取当前播放的PPT幻灯片窗口对象
PPT.SlideShowWindow pptWindow = pptDoc.SlideShowWindow;
pptDoc = pptApp.ActivePresentation;
// 获取当前播放的PPT幻灯片窗口对象(保证当前处于放映状态)
pptWindow = pptDoc.SlideShowWindow;

// 获取当前播放的幻灯片总页数
totalSlides = pptDoc.Slides.Count;

// 释放资源
pptWindow = null;
pptDoc = null;
pptApp = null;
}
catch
{
// 获取PPT信息失败
}

return totalSlides;
}

public int NextSlideShow(int check)
{
try
{
int temp_SlideIndex = pptWindow.View.Slide.SlideIndex;
if (temp_SlideIndex != check && check != -1) return pptWindow.View.Slide.SlideIndex;

// 下一页
pptWindow.View.Next();
// 获取当前播放的幻灯片页索引
return pptWindow.View.Slide.SlideIndex;
}
catch
{
}
return -1;
}

public int PreviousSlideShow()
{
try
{ // 上一页
pptWindow.View.Previous();
// 获取当前播放的幻灯片页索引
return pptWindow.View.Slide.SlideIndex;
}
catch
{
}
return -1;
}

public IntPtr GetPptHwnd()
{
IntPtr hWnd = IntPtr.Zero;
try
{
// 获取正在播放的PPT应用程序对象
PPT.Application pptApp = new PPT.Application();
pptApp = (Microsoft.Office.Interop.PowerPoint.Application)Marshal.GetActiveObject("PowerPoint.Application");
// 获取当前播放的PPT文档对象
PPT.Presentation pptDoc = pptApp.ActivePresentation;
pptDoc = pptApp.ActivePresentation;
// 获取当前播放的PPT幻灯片窗口对象
PPT.SlideShowWindow pptWindow = pptDoc.SlideShowWindow;
pptWindow = pptDoc.SlideShowWindow;

// 获取PPT窗口句柄
hWnd = new IntPtr(pptWindow.HWND);

// 释放资源
pptWindow = null;
pptDoc = null;
pptApp = null;
}
catch
{
Expand All @@ -209,20 +222,8 @@ public void EndSlideShow()
{
try
{
// 获取正在播放的PPT应用程序对象
PPT.Application pptApp = new PPT.Application();
// 获取当前播放的PPT文档对象
PPT.Presentation pptDoc = pptApp.ActivePresentation;
// 获取当前播放的PPT幻灯片窗口对象
PPT.SlideShowWindow pptWindow = pptDoc.SlideShowWindow;

// 结束放映
pptWindow.View.Exit();

// 释放资源
pptWindow = null;
pptDoc = null;
pptApp = null;
}
catch
{
Expand Down
24 changes: 20 additions & 4 deletions PptCOM/PptCOM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,29 @@
<HintPath>..\packages\Microsoft.Office.Interop.PowerPoint.15.0.4420.1018\lib\net20\Microsoft.Office.Interop.PowerPoint.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>..\packages\MicrosoftOfficeCore.15.0.0\lib\net35\Office.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="System">
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft.Office.Core">
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>8</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="stdole">
<Guid>{00020430-0000-0000-C000-000000000046}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
24 changes: 21 additions & 3 deletions 智绘教/HiEasyX/HiWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ namespace HiEasyX
////////////****** 全局变量 ******////////////

WNDCLASSEX g_WndClassEx; ///< 窗口类
TCHAR g_lpszClassName[] = _T("HiEasyX"); ///< 窗口类名
TCHAR g_lpszClassName[] = _T("HiEasyX"); ///< 窗口类名
ScreenSize g_screenSize; ///< 显示器信息
HWND g_hConsole; ///< 控制台句柄
HINSTANCE g_hInstance = GetModuleHandle(0); ///< 程序实例

std::vector<EasyWindow> g_vecWindows; ///< 窗口表(管理多窗口)
std::deque<std::shared_mutex> g_vecWindows_vecMessage_sm;
std::vector<EasyWindow> g_vecWindows; ///< 窗口表(管理多窗口)

int g_nFocusWindowIndex = NO_WINDOW_INDEX; ///< 当前操作焦点窗口索引

bool g_isInTask = false; ///< 标记处于任务中
Expand Down Expand Up @@ -191,7 +193,9 @@ namespace HiEasyX
}

// 释放消息列表内存
std::unique_lock<std::shared_mutex> lg_vecWindows_vecMessage_sm(g_vecWindows_vecMessage_sm[index]);
std::vector<ExMessage>().swap(g_vecWindows[index].vecMessage);
lg_vecWindows_vecMessage_sm.unlock();

//DestroyWindow(g_vecWindows[index].hWnd);
//PostQuitMessage(0);
Expand Down Expand Up @@ -668,7 +672,9 @@ namespace HiEasyX
int index = GetWindowIndex(hWnd);
if (IsAliveWindow(index))
{
std::shared_lock<std::shared_mutex> lg_vecWindows_vecMessage_sm(g_vecWindows_vecMessage_sm[index]);
return g_vecWindows[index].vecMessage;
lg_vecWindows_vecMessage_sm.unlock();
}
else
{
Expand Down Expand Up @@ -1005,8 +1011,9 @@ namespace HiEasyX
msgMouse.x = (short)p.x;
msgMouse.y = (short)p.y;
}

std::unique_lock<std::shared_mutex> lg_vecWindows_vecMessage_sm(g_vecWindows_vecMessage_sm[indexWnd]);
g_vecWindows[indexWnd].vecMessage.push_back(msgMouse);
lg_vecWindows_vecMessage_sm.unlock();
}
break;

Expand Down Expand Up @@ -1047,7 +1054,9 @@ namespace HiEasyX
msgKey.extended = isExtendedKey;
msgKey.prevdown = repeatFlag;

std::unique_lock<std::shared_mutex> lg_vecWindows_vecMessage_sm(g_vecWindows_vecMessage_sm[indexWnd]);
g_vecWindows[indexWnd].vecMessage.push_back(msgKey);
lg_vecWindows_vecMessage_sm.unlock();

// 给控制台发一份,支持 _getch() 系列函数
PostMessage(g_hConsole, msg, wParam, lParam);
Expand All @@ -1060,7 +1069,10 @@ namespace HiEasyX
ExMessage msgChar = {};
msgChar.message = msg;
msgChar.ch = (TCHAR)wParam;

std::unique_lock<std::shared_mutex> lg_vecWindows_vecMessage_sm(g_vecWindows_vecMessage_sm[indexWnd]);
g_vecWindows[indexWnd].vecMessage.push_back(msgChar);
lg_vecWindows_vecMessage_sm.unlock();

// 通知控制台
PostMessage(g_hConsole, msg, wParam, lParam);
Expand All @@ -1076,7 +1088,9 @@ namespace HiEasyX
msgWindow.message = msg;
msgWindow.wParam = wParam;
msgWindow.lParam = lParam;
std::unique_lock<std::shared_mutex> lg_vecWindows_vecMessage_sm(g_vecWindows_vecMessage_sm[indexWnd]);
g_vecWindows[indexWnd].vecMessage.push_back(msgWindow);
lg_vecWindows_vecMessage_sm.unlock();
}
break;
}
Expand Down Expand Up @@ -1556,7 +1570,11 @@ namespace HiEasyX

// 在创建窗口前将窗口加入容器,预设句柄为空,方便过程函数接收 WM_CREATE 消息
InitWindowStruct(wnd, hParent, w, h, WindowProcess);

g_vecWindows_vecMessage_sm.emplace_back();
std::unique_lock<std::shared_mutex> lg_vecWindows_vecMessage_sm(g_vecWindows_vecMessage_sm[nIndexWnd]);
g_vecWindows.push_back(wnd);
lg_vecWindows_vecMessage_sm.unlock();

// 创建窗口
for (int i = 0;; i++)
Expand Down
8 changes: 8 additions & 0 deletions 智绘教/HiEasyX/HiWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <vector>
#include <thread>

#include <shared_mutex>
#include <deque>

#ifdef _MSC_VER
#pragma comment (lib, "Msimg32.lib")
#endif
Expand Down Expand Up @@ -97,6 +100,8 @@ namespace HiEasyX
std::vector<SysControlBase*> vecSysCtrl; ///< 记录创建的系统控件
bool bHasCtrl = false; ///< 是否创建过系统控件
};
extern std::deque<std::shared_mutex> g_vecWindows_vecMessage_sm;
extern std::vector<EasyWindow> g_vecWindows;

/**
* @brief <pre>
Expand Down Expand Up @@ -777,6 +782,9 @@ namespace HiEasyX
* @return MOUSEMSG 消息
*/
MOUSEMSG To_MouseMsg(ExMessage msgEx);

// 智绘教零散交互
int GetWindowIndex(HWND hWnd, bool flag);
}

////////////****** 任务指令宏定义 ******////////////
Expand Down
6 changes: 6 additions & 0 deletions 智绘教/IdtConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ struct SetListStruct
{
StartUp = 0, CreateLnk = false;
BrushRecover = true, RubberRecover = false;
RubberMode = 0;

IntelligentDrawing = true, SmoothWriting = true;

SetSkinMode = 0, SkinMode = 1;
}

int StartUp; bool CreateLnk;
bool BrushRecover, RubberRecover;
int RubberMode;

bool IntelligentDrawing, SmoothWriting;

int SetSkinMode, SkinMode;
};
Expand Down
Loading

0 comments on commit fca7810

Please sign in to comment.