From 238498dc852ee1304e30ac7ffe9778fb1ada5904 Mon Sep 17 00:00:00 2001 From: Chang_breezing Date: Wed, 31 Jul 2024 23:40:15 +0800 Subject: [PATCH] [fix] updateBorderStrokeSelectionControlLocation --- Ink Canvas/Helpers/DelAutoSavedFiles.cs | 2 +- Ink Canvas/MainWindow.xaml | 2 +- Ink Canvas/MainWindow_cs/MW_PPT.cs | 22 +++++++++++++++---- .../MainWindow_cs/MW_SelectionGestures.cs | 11 ++++++++-- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Ink Canvas/Helpers/DelAutoSavedFiles.cs b/Ink Canvas/Helpers/DelAutoSavedFiles.cs index 7170687..05fe4e4 100644 --- a/Ink Canvas/Helpers/DelAutoSavedFiles.cs +++ b/Ink Canvas/Helpers/DelAutoSavedFiles.cs @@ -8,7 +8,7 @@ internal class DelAutoSavedFiles { public static void DeleteFilesOlder(string directoryPath, int daysThreshold) { - string[] extensionsToDel = { ".icstk", ".png" }; + string[] extensionsToDel = { ".icstk", ".icart", ".png" }; if (Directory.Exists(directoryPath)) { // 获取目录中的所有子目录 diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index 3b7d927..d06a524 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -3699,7 +3699,7 @@ Foreground="{DynamicResource SettingsPageForeground}" Text="定期自动删除超过保存时间的墨迹、截图文件" /> - + diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index 80eb8ea..b403bde 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -463,16 +463,30 @@ private async void PptApplication_SlideShowEnd(Presentation Pres) { try { + string baseFilePath = folderPath + @"\" + i.ToString("0000"); + string icartFilePath = baseFilePath + ".icart"; + string icstkFilePath = baseFilePath + ".icstk"; + if (memoryStreams[i].Length > 8) { - byte[] srcBuf = new Byte[memoryStreams[i].Length]; + byte[] srcBuf = new byte[memoryStreams[i].Length]; int byteLength = memoryStreams[i].Read(srcBuf, 0, srcBuf.Length); - File.WriteAllBytes(folderPath + @"\" + i.ToString("0000") + ".icstk", srcBuf); - LogHelper.WriteLogToFile(string.Format("Saved strokes for Slide {0}, size={1}, byteLength={2}", i.ToString(), memoryStreams[i].Length, byteLength)); + + if (File.Exists(icartFilePath)) + { + File.WriteAllBytes(icartFilePath, srcBuf); + LogHelper.WriteLogToFile(string.Format("Saved strokes for Slide {0} as .icart, size={1}, byteLength={2}", i.ToString(), memoryStreams[i].Length, byteLength)); + } + else + { + File.WriteAllBytes(icstkFilePath, srcBuf); + LogHelper.WriteLogToFile(string.Format("Saved strokes for Slide {0} as .icstk, size={1}, byteLength={2}", i.ToString(), memoryStreams[i].Length, byteLength)); + } } else { - File.Delete(folderPath + @"\" + i.ToString("0000") + ".icstk"); + File.Delete(icartFilePath); + File.Delete(icstkFilePath); } } catch (Exception ex) diff --git a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs index 538fd90..becf3bb 100644 --- a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs +++ b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs @@ -447,7 +447,7 @@ private void inkCanvas_SelectionChanged(object sender, EventArgs e) private void updateBorderStrokeSelectionControlLocation() { - var selectionBounds = inkCanvas.GetSelectionBounds(); + Rect selectionBounds = inkCanvas.GetSelectionBounds(); double borderLeft = (selectionBounds.Left + selectionBounds.Right - BorderStrokeSelectionControlWidth) / 2; double borderTop = selectionBounds.Bottom + 15; @@ -482,7 +482,14 @@ private void updateBorderStrokeSelectionControlLocation() { borderTop = Math.Min(Height - BorderStrokeSelectionControlHeight - 60, borderTop); } - BorderStrokeSelectionControl.Margin = new Thickness(borderLeft, borderTop, 0, 0); + if (!double.IsNaN(borderLeft) && !double.IsNaN(borderTop)) + { + BorderStrokeSelectionControl.Margin = new Thickness(borderLeft, borderTop, 0, 0); + } + else + { + BorderStrokeSelectionControl.Margin = new Thickness(0, 0, 0, 0); + } } private void GridInkCanvasSelectionCover_ManipulationStarting(object sender, ManipulationStartingEventArgs e)