From 9c611698c7070fa551eab653260c6ad476fe1090 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sat, 17 Jan 2026 20:05:33 +0800 Subject: [PATCH] fix:issue #346 --- Ink Canvas/MainWindow_cs/MW_PPT.cs | 38 +++++++++++++----------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index 307607b3..37163638 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -1628,31 +1628,25 @@ namespace Ink_Canvas }); } - // 结束放映 - if (_pptManager?.TryEndSlideShow() == true) + Application.Current.Dispatcher.Invoke(() => { - // 如果成功结束放映,等待OnPPTSlideShowEnd事件处理收纳状态恢复 - } - else - { - LogHelper.WriteLogToFile("结束幻灯片放映失败", LogHelper.LogType.Warning); + CursorIcon_Click(null, null); + }); - // 手动更新UI状态,防止事件未触发 - await Application.Current.Dispatcher.InvokeAsync(() => + await Task.Delay(100); + await Application.Current.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.Background); + + Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + try { - _pptUIManager?.UpdateSlideShowStatus(false); - _pptUIManager?.UpdateSidebarExitButtons(false); - LogHelper.WriteLogToFile("手动更新放映结束UI状态", LogHelper.LogType.Trace); - }); - - // 手动处理自动收纳,因为OnPPTSlideShowEnd事件可能未触发 - await HandleManualSlideShowEnd(); - } - - HideSubPanels("cursor"); - SetCurrentToolMode(InkCanvasEditingMode.None); - - await Task.Delay(150); + _pptManager?.TryEndSlideShow(); + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"结束放映时发生异常: {ex}", LogHelper.LogType.Error); + } + }), System.Windows.Threading.DispatcherPriority.Normal); if (!isFloatingBarFolded) { PureViewboxFloatingBarMarginAnimationInDesktopMode();