From f91deb5d7aeb7ed0ed8f32c270a422a0cc28357f Mon Sep 17 00:00:00 2001 From: Netherite_Bowl Date: Thu, 1 Aug 2024 17:34:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=BF=AE=E5=A5=BD=E4=BA=86?= =?UTF-8?q?=E7=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow.xaml.cs | 53 ++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index 9483f27..1ac8f28 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -2495,7 +2495,7 @@ private void PptApplication_PresentationClose(Presentation Pres) timerCheckPPT.Start(); Application.Current.Dispatcher.Invoke(() => { - BtnPPTSlideShow.Visibility = Visibility.Collapsed; + //BtnPPTSlideShow.Visibility = Visibility.Collapsed; BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed; }); } @@ -2504,6 +2504,7 @@ private void PptApplication_PresentationClose(Presentation Pres) private string pptName = null; + int currentShowPosition = -1; //bool isButtonBackgroundTransparent = true; //此变量仅用于保存用于幻灯片放映时的优化 private void PptApplication_SlideShowBegin(SlideShowWindow Wn) { @@ -2564,21 +2565,24 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn) int count = 0; foreach (FileInfo file in files) { - int i = -1; - try + if (file.Name != "Position") { - i = int.Parse(System.IO.Path.GetFileNameWithoutExtension(file.Name)); - //var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read); - //MemoryStream ms = new MemoryStream(File.ReadAllBytes(file.FullName)); - //new StrokeCollection(fs).Save(ms); - //ms.Position = 0; - memoryStreams[i] = new MemoryStream(File.ReadAllBytes(file.FullName)); - memoryStreams[i].Position = 0; - count++; - } - catch (Exception ex) - { - LogHelper.WriteLogToFile(string.Format("Failed to load strokes on Slide {0}\n{1}", i, ex.ToString()), LogHelper.LogType.Error); + int i = -1; + try + { + i = int.Parse(System.IO.Path.GetFileNameWithoutExtension(file.Name)); + //var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read); + //MemoryStream ms = new MemoryStream(File.ReadAllBytes(file.FullName)); + //new StrokeCollection(fs).Save(ms); + //ms.Position = 0; + memoryStreams[i] = new MemoryStream(File.ReadAllBytes(file.FullName)); + memoryStreams[i].Position = 0; + count++; + } + catch (Exception ex) + { + LogHelper.WriteLogToFile(string.Format("Failed to load strokes on Slide {0}\n{1}", i, ex.ToString()), LogHelper.LogType.Error); + } } } LogHelper.WriteLogToFile(string.Format("Loaded {0} saved strokes", count.ToString())); @@ -2669,6 +2673,7 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn) bool isEnteredSlideShowEndEvent = false; //防止重复调用本函数导致墨迹保存失效 private void PptApplication_SlideShowEnd(Presentation Pres) { + IsNotifyPreviousPageWindowShown = false; LogHelper.WriteLogToFile(string.Format("PowerPoint Slide Show End"), LogHelper.LogType.Event); if (isEnteredSlideShowEndEvent) { @@ -2684,7 +2689,22 @@ private void PptApplication_SlideShowEnd(Presentation Pres) { Directory.CreateDirectory(folderPath); } - File.WriteAllText(folderPath + "/Position", previousSlideID.ToString()); + try + { + File.WriteAllText(folderPath + "/Position", previousSlideID.ToString()); + } + catch { } + Application.Current.Dispatcher.Invoke(() => + { + try + { + MemoryStream ms = new MemoryStream(); + inkCanvas.Strokes.Save(ms); + ms.Position = 0; + memoryStreams[currentShowPosition] = ms; + } + catch { } + }); for (int i = 1; i <= Pres.Slides.Count; i++) { if (memoryStreams[i] != null) @@ -2801,6 +2821,7 @@ private void PptApplication_SlideShowNextSlide(SlideShowWindow Wn) { inkCanvas.Strokes.Add(new StrokeCollection(memoryStreams[Wn.View.CurrentShowPosition])); } + currentShowPosition = Wn.View.CurrentShowPosition; } catch { }