From e792f2637d5177c3ca9091d1ed2d91eb5cafc94c Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sat, 13 Dec 2025 20:13:08 +0800 Subject: [PATCH] =?UTF-8?q?improve:PPT=E5=A2=A8=E8=BF=B9=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow_cs/MW_PPT.cs | 70 ++++++++++++++++-------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index 1a206383..8fdc8413 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -835,49 +835,53 @@ namespace Ink_Canvas var previousSlide = _currentSlideShowPosition > 0 ? _currentSlideShowPosition : (_pptManager?.GetCurrentSlideNumber() ?? 0); - // 先保存当前页墨迹的副本 - StrokeCollection strokesToSave = null; - if (previousSlide > 0 && previousSlide != currentSlide && inkCanvas.Strokes.Count > 0) - { - strokesToSave = inkCanvas.Strokes.Clone(); - } - if (_isInkClearedByButton) { _isInkClearedByButton = false; } - else if (inkCanvas.Strokes.Count > 0) + else { - ClearStrokes(true); - timeMachine.ClearStrokeHistory(); + StrokeCollection strokesToSave = null; + if (previousSlide > 0 && previousSlide != currentSlide && inkCanvas.Strokes.Count > 0) + { + strokesToSave = inkCanvas.Strokes.Clone(); + } + + // 清除墨迹 + if (inkCanvas.Strokes.Count > 0) + { + ClearStrokes(true); + timeMachine.ClearStrokeHistory(); + } + + // 异步保存之前页面的墨迹 + if (strokesToSave != null && previousSlide > 0 && previousSlide != currentSlide) + { + Task.Run(() => + { + try + { + Application.Current.Dispatcher.Invoke(() => + { + bool canWrite = _singlePPTInkManager?.CanWriteInk(previousSlide) == true; + if (canWrite) + { + _singlePPTInkManager?.SaveCurrentSlideStrokes(previousSlide, strokesToSave); + } + }); + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"异步保存PPT页面墨迹失败: {ex}", LogHelper.LogType.Error); + } + }); + } } // 更新当前播放页码 _currentSlideShowPosition = currentSlide; - // 异步保存之前页面的墨迹(不阻塞翻页操作) - if (strokesToSave != null && previousSlide > 0 && previousSlide != currentSlide) - { - Task.Run(() => - { - try - { - Application.Current.Dispatcher.Invoke(() => - { - bool canWrite = _singlePPTInkManager?.CanWriteInk(previousSlide) == true; - if (canWrite) - { - _singlePPTInkManager?.SaveCurrentSlideStrokes(previousSlide, strokesToSave); - } - }); - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"异步保存PPT页面墨迹失败: {ex}", LogHelper.LogType.Error); - } - }); - } - LoadCurrentSlideInk(currentSlide, skipClear: true); // 跳过清除,因为已在上面清除 + LoadCurrentSlideInk(currentSlide, skipClear: true); _pptUIManager?.UpdateCurrentSlideNumber(currentSlide, totalSlides); });