From aa6082d18ae6473b118df8e69634d272f0c9bdd2 Mon Sep 17 00:00:00 2001 From: Netherite_Bowl Date: Fri, 14 Jun 2024 19:56:47 +0800 Subject: [PATCH 1/5] fix #129 --- Ink Canvas/MainWindow.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index 86d73b04..dbc4d23e 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -916,9 +916,9 @@ - + - + @@ -936,9 +936,9 @@ - + - + From 239eb0851078022f96281b765c2bec9fb3d0aa1b Mon Sep 17 00:00:00 2001 From: Netherite_Bowl Date: Fri, 14 Jun 2024 21:21:32 +0800 Subject: [PATCH 2/5] fix #129 --- Ink Canvas/MainWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index dbc4d23e..1759a40d 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -916,7 +916,7 @@ - + @@ -936,7 +936,7 @@ - + From df734390cb70fce111b4062706ccaaade42bce44 Mon Sep 17 00:00:00 2001 From: Netherite_Bowl Date: Sat, 15 Jun 2024 21:28:49 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=AE=E9=A2=98=20#128?= =?UTF-8?q?=20=E7=9A=84=E6=9D=A1=E7=9B=AE=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow.xaml.cs | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index b7b49e90..af20caaf 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -2314,6 +2314,8 @@ private void ToggleSwitchSupportWPS_Toggled(object sender, RoutedEventArgs e) public static bool IsShowingRestoreHiddenSlidesWindow = false; + public static bool IsNotifyPreviousPageWindowShown = false; + private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e) { if (IsShowingRestoreHiddenSlidesWindow) return; @@ -2369,30 +2371,31 @@ private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e) // 跳转到上次播放页 if (Settings.PowerPointSettings.IsNotifyPreviousPage) Application.Current.Dispatcher.BeginInvoke(() => - { - string defaultFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + - @"\Ink Canvas Strokes\Auto Saved\Presentations\"; - string folderPath = defaultFolderPath + presentation.Name + "_" + presentation.Slides.Count; - if (File.Exists(folderPath + "/Position")) { - if (int.TryParse(File.ReadAllText(folderPath + "/Position"), out var page)) + string defaultFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + + @"\Ink Canvas Strokes\Auto Saved\Presentations\"; + string folderPath = defaultFolderPath + presentation.Name + "_" + presentation.Slides.Count; + if (File.Exists(folderPath + "/Position") & !IsNotifyPreviousPageWindowShown) //判断是否已存在NotifyPreviousPage窗口 { - if (page <= 0) return; - new YesOrNoNotificationWindow($"上次播放到了第 {page} 页, 是否立即跳转", () => + if (int.TryParse(File.ReadAllText(folderPath + "/Position"), out var page)) { - if (pptApplication.SlideShowWindows.Count >= 1) - { - // 如果已经播放了的话, 跳转 - presentation.SlideShowWindow.View.GotoSlide(page); - } - else + IsNotifyPreviousPageWindowShown= true; + if (page <= 0) return; + new YesOrNoNotificationWindow($"上次播放到了第 {page} 页, 是否立即跳转", () => { - presentation.Windows[1].View.GotoSlide(page); - } - }).ShowDialog(); + if (pptApplication.SlideShowWindows.Count >= 1) + { + // 如果已经播放了的话, 跳转 + presentation.SlideShowWindow.View.GotoSlide(page); + } + else + { + presentation.Windows[1].View.GotoSlide(page); + } + }).ShowDialog(); + } } - } - }, DispatcherPriority.Normal); + }, DispatcherPriority.Normal); //检查是否有隐藏幻灯片 @@ -2871,6 +2874,7 @@ private void BtnPPTSlideShowEnd_Click(object sender, RoutedEventArgs e) ms.Position = 0; memoryStreams[pptApplication.SlideShowWindows[1].View.CurrentShowPosition] = ms; timeMachine.ClearStrokeHistory(); + IsNotifyPreviousPageWindowShown = false; } catch { } }); From 14e33684f0416c7310888408d723459504fec071 Mon Sep 17 00:00:00 2001 From: Netherite_Bowl Date: Sat, 15 Jun 2024 21:28:49 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=AE=E9=A2=98=20#128?= =?UTF-8?q?=20=E7=9A=84=E6=9D=A1=E7=9B=AE=E4=B8=80=EF=BC=88=E8=AE=AE?= =?UTF-8?q?=E9=A2=98=E5=91=A8=E8=BE=B9=EF=BC=9A=E6=96=87=E5=AD=97=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow.xaml.cs | 44 ++++++++++++----------- Ink Canvas/YesOrNoNotificationWindow.xaml | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index b7b49e90..05873334 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -2314,6 +2314,8 @@ private void ToggleSwitchSupportWPS_Toggled(object sender, RoutedEventArgs e) public static bool IsShowingRestoreHiddenSlidesWindow = false; + public static bool IsNotifyPreviousPageWindowShown = false; + private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e) { if (IsShowingRestoreHiddenSlidesWindow) return; @@ -2369,30 +2371,31 @@ private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e) // 跳转到上次播放页 if (Settings.PowerPointSettings.IsNotifyPreviousPage) Application.Current.Dispatcher.BeginInvoke(() => - { - string defaultFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + - @"\Ink Canvas Strokes\Auto Saved\Presentations\"; - string folderPath = defaultFolderPath + presentation.Name + "_" + presentation.Slides.Count; - if (File.Exists(folderPath + "/Position")) { - if (int.TryParse(File.ReadAllText(folderPath + "/Position"), out var page)) + string defaultFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + + @"\Ink Canvas Strokes\Auto Saved\Presentations\"; + string folderPath = defaultFolderPath + presentation.Name + "_" + presentation.Slides.Count; + if (File.Exists(folderPath + "/Position") & !IsNotifyPreviousPageWindowShown) //判断是否已存在NotifyPreviousPage窗口 { - if (page <= 0) return; - new YesOrNoNotificationWindow($"上次播放到了第 {page} 页, 是否立即跳转", () => + if (int.TryParse(File.ReadAllText(folderPath + "/Position"), out var page)) { - if (pptApplication.SlideShowWindows.Count >= 1) - { - // 如果已经播放了的话, 跳转 - presentation.SlideShowWindow.View.GotoSlide(page); - } - else + IsNotifyPreviousPageWindowShown= true; + if (page <= 0) return; + new YesOrNoNotificationWindow($"上次播放到了第 {page} 页, 是否立即跳转", () => { - presentation.Windows[1].View.GotoSlide(page); - } - }).ShowDialog(); + if (pptApplication.SlideShowWindows.Count >= 1) + { + // 如果已经播放了的话, 跳转 + presentation.SlideShowWindow.View.GotoSlide(page); + } + else + { + presentation.Windows[1].View.GotoSlide(page); + } + }).ShowDialog(); + } } - } - }, DispatcherPriority.Normal); + }, DispatcherPriority.Normal); //检查是否有隐藏幻灯片 @@ -2413,7 +2416,7 @@ private void TimerCheckPPT_Elapsed(object sender, ElapsedEventArgs e) if (isHaveHiddenSlide && !IsShowingRestoreHiddenSlidesWindow) { IsShowingRestoreHiddenSlidesWindow = true; - new YesOrNoNotificationWindow("检测到此演示文档中包含隐藏的幻灯片,是否取消隐藏?", + new YesOrNoNotificationWindow("检测到此演示文稿包含隐藏的幻灯片,是否取消隐藏?", () => { foreach (Slide slide in slides) @@ -2871,6 +2874,7 @@ private void BtnPPTSlideShowEnd_Click(object sender, RoutedEventArgs e) ms.Position = 0; memoryStreams[pptApplication.SlideShowWindows[1].View.CurrentShowPosition] = ms; timeMachine.ClearStrokeHistory(); + IsNotifyPreviousPageWindowShown = false; } catch { } }); diff --git a/Ink Canvas/YesOrNoNotificationWindow.xaml b/Ink Canvas/YesOrNoNotificationWindow.xaml index 5bb40507..b21ede70 100644 --- a/Ink Canvas/YesOrNoNotificationWindow.xaml +++ b/Ink Canvas/YesOrNoNotificationWindow.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:Ink_Canvas" xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" mc:Ignorable="d" Topmost="True" WindowStartupLocation="CenterScreen" ui:WindowHelper.UseModernWindowStyle="True" ResizeMode="NoResize" Closed="Window_Closed" ui:ThemeManager.RequestedTheme="Light" - Title="演示文档设置 - Ink Canvas 画板" Height="160" Width="450" FontFamily="Microsoft YaHei UI"> + Title="提示 - Ink Canvas 画板" Height="160" Width="450" FontFamily="Microsoft YaHei UI"> From f91deb5d7aeb7ed0ed8f32c270a422a0cc28357f Mon Sep 17 00:00:00 2001 From: Netherite_Bowl Date: Thu, 1 Aug 2024 17:34:52 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=BF=AE=E5=A5=BD?= =?UTF-8?q?=E4=BA=86=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 9483f27d..1ac8f28c 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 { }