From ff58675069a34ee4eb098406b762c89c127d5b5c Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 18 Jan 2026 08:18:38 +0800 Subject: [PATCH] =?UTF-8?q?improve:PPT=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/PPTManager.cs | 5 +++++ Ink Canvas/Windows/PPTQuickPanel.xaml.cs | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Ink Canvas/Helpers/PPTManager.cs b/Ink Canvas/Helpers/PPTManager.cs index a3bd95b4..139e4c7e 100644 --- a/Ink Canvas/Helpers/PPTManager.cs +++ b/Ink Canvas/Helpers/PPTManager.cs @@ -303,6 +303,11 @@ namespace Ink_Canvas.Helpers PPTROTConnectionHelper.SafeReleaseComObject(bestApp); bestApp = null; } + else if (bestApp == null && PPTApplication != null) + { + LogHelper.WriteLogToFile("检测到PPT已关闭,断开连接", LogHelper.LogType.Trace); + DisconnectFromPPT(); + } } if (PPTApplication != null && _pptActivePresentation != null) diff --git a/Ink Canvas/Windows/PPTQuickPanel.xaml.cs b/Ink Canvas/Windows/PPTQuickPanel.xaml.cs index 281e421a..704ea637 100644 --- a/Ink Canvas/Windows/PPTQuickPanel.xaml.cs +++ b/Ink Canvas/Windows/PPTQuickPanel.xaml.cs @@ -275,7 +275,7 @@ namespace Ink_Canvas.Windows var presentationOpenEvent = pptManager.GetType().GetEvent("PresentationOpen"); if (presentationOpenEvent != null) { - var openHandler = new Action(OnPPTPresentationOpen); + var openHandler = new Action(OnPPTPresentationOpen); presentationOpenEvent.AddEventHandler(pptManager, openHandler); } @@ -283,7 +283,7 @@ namespace Ink_Canvas.Windows var slideShowBeginEvent = pptManager.GetType().GetEvent("SlideShowBegin"); if (slideShowBeginEvent != null) { - var beginHandler = new Action(OnPPTSlideShowBegin); + var beginHandler = new Action(OnPPTSlideShowBegin); slideShowBeginEvent.AddEventHandler(pptManager, beginHandler); } @@ -291,7 +291,7 @@ namespace Ink_Canvas.Windows var slideShowNextSlideEvent = pptManager.GetType().GetEvent("SlideShowNextSlide"); if (slideShowNextSlideEvent != null) { - var handler = new Action(OnPPTSlideChanged); + var handler = new Action(OnPPTSlideChanged); slideShowNextSlideEvent.AddEventHandler(pptManager, handler); } @@ -299,7 +299,7 @@ namespace Ink_Canvas.Windows var slideShowEndEvent = pptManager.GetType().GetEvent("SlideShowEnd"); if (slideShowEndEvent != null) { - var handler = new Action(OnPPTSlideShowEnd); + var handler = new Action(OnPPTSlideShowEnd); 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(() => { @@ -326,7 +326,7 @@ namespace Ink_Canvas.Windows }), DispatcherPriority.Normal); } - private void OnPPTSlideShowBegin(Microsoft.Office.Interop.PowerPoint.SlideShowWindow window) + private void OnPPTSlideShowBegin(object window) { Application.Current.Dispatcher.BeginInvoke(new Action(async () => { @@ -369,7 +369,7 @@ namespace Ink_Canvas.Windows }), DispatcherPriority.Normal); } - private void OnPPTSlideChanged(Microsoft.Office.Interop.PowerPoint.SlideShowWindow window) + private void OnPPTSlideChanged(object window) { Application.Current.Dispatcher.BeginInvoke(new Action(async () => { @@ -420,7 +420,7 @@ namespace Ink_Canvas.Windows }), DispatcherPriority.Normal); } - private void OnPPTSlideShowEnd(Microsoft.Office.Interop.PowerPoint.Presentation presentation) + private void OnPPTSlideShowEnd(object presentation) { Application.Current.Dispatcher.BeginInvoke(new Action(() => {