From 44e331ae9623584a3c339d5b6d43fd54f74eabea Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Mon, 21 Jul 2025 09:56:51 +0800 Subject: [PATCH] fix:issue #91 --- Ink Canvas/MainWindow_cs/MW_PPT.cs | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index 403db3da..2743ae2d 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -928,6 +928,11 @@ namespace Ink_Canvas { currentMode = 0; } + // 切换前同步保存墨迹 + Application.Current.Dispatcher.Invoke(() => { + SaveCurrentSlideInkStrokes(); + }); + _isPptClickingBtnTurned = true; // 添加安全检查 @@ -1011,6 +1016,11 @@ namespace Ink_Canvas { currentMode = 0; } + // 切换前同步保存墨迹 + Application.Current.Dispatcher.Invoke(() => { + SaveCurrentSlideInkStrokes(); + }); + _isPptClickingBtnTurned = true; // 添加安全检查 @@ -1214,6 +1224,11 @@ namespace Ink_Canvas { return; } + // 切换前同步保存墨迹 + Application.Current.Dispatcher.Invoke(() => { + SaveCurrentSlideInkStrokes(); + }); + try { // 检查SlideShowWindows是否存在且有效 @@ -2091,5 +2106,28 @@ namespace Ink_Canvas { return "error"; } } + + // 新增:同步保存当前页面墨迹的方法 + private void SaveCurrentSlideInkStrokes() + { + try + { + if (pptApplication != null && pptApplication.SlideShowWindows != null && pptApplication.SlideShowWindows.Count >= 1) + { + var slideShowWindow = pptApplication.SlideShowWindows[1]; + if (slideShowWindow != null && slideShowWindow.View != null) + { + var ms = new MemoryStream(); + inkCanvas.Strokes.Save(ms); + ms.Position = 0; + memoryStreams[slideShowWindow.View.CurrentShowPosition] = ms; + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex.ToString()}", LogHelper.LogType.Error); + } + } } }