improve:PPT联动

This commit is contained in:
2026-01-18 08:18:38 +08:00
parent b3cb53b482
commit ff58675069
2 changed files with 13 additions and 8 deletions
+5
View File
@@ -303,6 +303,11 @@ namespace Ink_Canvas.Helpers
PPTROTConnectionHelper.SafeReleaseComObject(bestApp); PPTROTConnectionHelper.SafeReleaseComObject(bestApp);
bestApp = null; bestApp = null;
} }
else if (bestApp == null && PPTApplication != null)
{
LogHelper.WriteLogToFile("检测到PPT已关闭,断开连接", LogHelper.LogType.Trace);
DisconnectFromPPT();
}
} }
if (PPTApplication != null && _pptActivePresentation != null) if (PPTApplication != null && _pptActivePresentation != null)
+8 -8
View File
@@ -275,7 +275,7 @@ namespace Ink_Canvas.Windows
var presentationOpenEvent = pptManager.GetType().GetEvent("PresentationOpen"); var presentationOpenEvent = pptManager.GetType().GetEvent("PresentationOpen");
if (presentationOpenEvent != null) if (presentationOpenEvent != null)
{ {
var openHandler = new Action<Microsoft.Office.Interop.PowerPoint.Presentation>(OnPPTPresentationOpen); var openHandler = new Action<object>(OnPPTPresentationOpen);
presentationOpenEvent.AddEventHandler(pptManager, openHandler); presentationOpenEvent.AddEventHandler(pptManager, openHandler);
} }
@@ -283,7 +283,7 @@ namespace Ink_Canvas.Windows
var slideShowBeginEvent = pptManager.GetType().GetEvent("SlideShowBegin"); var slideShowBeginEvent = pptManager.GetType().GetEvent("SlideShowBegin");
if (slideShowBeginEvent != null) if (slideShowBeginEvent != null)
{ {
var beginHandler = new Action<Microsoft.Office.Interop.PowerPoint.SlideShowWindow>(OnPPTSlideShowBegin); var beginHandler = new Action<object>(OnPPTSlideShowBegin);
slideShowBeginEvent.AddEventHandler(pptManager, beginHandler); slideShowBeginEvent.AddEventHandler(pptManager, beginHandler);
} }
@@ -291,7 +291,7 @@ namespace Ink_Canvas.Windows
var slideShowNextSlideEvent = pptManager.GetType().GetEvent("SlideShowNextSlide"); var slideShowNextSlideEvent = pptManager.GetType().GetEvent("SlideShowNextSlide");
if (slideShowNextSlideEvent != null) if (slideShowNextSlideEvent != null)
{ {
var handler = new Action<Microsoft.Office.Interop.PowerPoint.SlideShowWindow>(OnPPTSlideChanged); var handler = new Action<object>(OnPPTSlideChanged);
slideShowNextSlideEvent.AddEventHandler(pptManager, handler); slideShowNextSlideEvent.AddEventHandler(pptManager, handler);
} }
@@ -299,7 +299,7 @@ namespace Ink_Canvas.Windows
var slideShowEndEvent = pptManager.GetType().GetEvent("SlideShowEnd"); var slideShowEndEvent = pptManager.GetType().GetEvent("SlideShowEnd");
if (slideShowEndEvent != null) if (slideShowEndEvent != null)
{ {
var handler = new Action<Microsoft.Office.Interop.PowerPoint.Presentation>(OnPPTSlideShowEnd); var handler = new Action<object>(OnPPTSlideShowEnd);
slideShowEndEvent.AddEventHandler(pptManager, handler); slideShowEndEvent.AddEventHandler(pptManager, handler);
} }
} }
@@ -310,7 +310,7 @@ namespace Ink_Canvas.Windows
} }
} }
private void OnPPTPresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation presentation) private void OnPPTPresentationOpen(object presentation)
{ {
Application.Current.Dispatcher.BeginInvoke(new Action(() => Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{ {
@@ -326,7 +326,7 @@ namespace Ink_Canvas.Windows
}), DispatcherPriority.Normal); }), DispatcherPriority.Normal);
} }
private void OnPPTSlideShowBegin(Microsoft.Office.Interop.PowerPoint.SlideShowWindow window) private void OnPPTSlideShowBegin(object window)
{ {
Application.Current.Dispatcher.BeginInvoke(new Action(async () => Application.Current.Dispatcher.BeginInvoke(new Action(async () =>
{ {
@@ -369,7 +369,7 @@ namespace Ink_Canvas.Windows
}), DispatcherPriority.Normal); }), DispatcherPriority.Normal);
} }
private void OnPPTSlideChanged(Microsoft.Office.Interop.PowerPoint.SlideShowWindow window) private void OnPPTSlideChanged(object window)
{ {
Application.Current.Dispatcher.BeginInvoke(new Action(async () => Application.Current.Dispatcher.BeginInvoke(new Action(async () =>
{ {
@@ -420,7 +420,7 @@ namespace Ink_Canvas.Windows
}), DispatcherPriority.Normal); }), DispatcherPriority.Normal);
} }
private void OnPPTSlideShowEnd(Microsoft.Office.Interop.PowerPoint.Presentation presentation) private void OnPPTSlideShowEnd(object presentation)
{ {
Application.Current.Dispatcher.BeginInvoke(new Action(() => Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{ {