diff --git a/Ink Canvas/Helpers/AnimationHelper.cs b/Ink Canvas/Helpers/AnimationHelper.cs deleted file mode 100644 index 084a7d3..0000000 --- a/Ink Canvas/Helpers/AnimationHelper.cs +++ /dev/null @@ -1,196 +0,0 @@ -using System; -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Animation; - -namespace Ink_Canvas.Helpers -{ - internal class AnimationHelper - { - public static void ShowWithSlideFromBottomAndFade(UIElement element, double duration = 0.15) - { - if (element.Visibility == Visibility.Visible) return; - - if (element == null) - throw new ArgumentNullException(nameof(element)); - - var sb = new Storyboard(); - - // 渐变动画 - var fadeInAnimation = new DoubleAnimation - { - From = 0.5, - To = 1, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(UIElement.OpacityProperty)); - - // 滑动动画 - var slideAnimation = new DoubleAnimation - { - From = element.RenderTransform.Value.OffsetY + 10, // 滑动距离 - To = 0, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(slideAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)")); - - sb.Children.Add(fadeInAnimation); - sb.Children.Add(slideAnimation); - - element.Visibility = Visibility.Visible; - element.RenderTransform = new TranslateTransform(); - - sb.Begin((FrameworkElement)element); - } - - public static void ShowWithSlideFromLeftAndFade(UIElement element, double duration = 0.25) - { - if (element.Visibility == Visibility.Visible) return; - - if (element == null) - throw new ArgumentNullException(nameof(element)); - - var sb = new Storyboard(); - - // 渐变动画 - var fadeInAnimation = new DoubleAnimation - { - From = 0.5, - To = 1, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(UIElement.OpacityProperty)); - - // 滑动动画 - var slideAnimation = new DoubleAnimation - { - From = element.RenderTransform.Value.OffsetX - 20, // 滑动距离 - To = 0, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(slideAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)")); - - sb.Children.Add(fadeInAnimation); - sb.Children.Add(slideAnimation); - - element.Visibility = Visibility.Visible; - element.RenderTransform = new TranslateTransform(); - - sb.Begin((FrameworkElement)element); - } - - public static void ShowWithScaleFromLeft(UIElement element, double duration = 0.5) - { - if (element.Visibility == Visibility.Visible) return; - - if (element == null) - throw new ArgumentNullException(nameof(element)); - - var sb = new Storyboard(); - - // 水平方向的缩放动画 - var scaleXAnimation = new DoubleAnimation - { - From = 0, - To = 1, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(scaleXAnimation, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)")); - - // 垂直方向的缩放动画 - var scaleYAnimation = new DoubleAnimation - { - From = 0, - To = 1, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(scaleYAnimation, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleY)")); - - sb.Children.Add(scaleXAnimation); - sb.Children.Add(scaleYAnimation); - - element.Visibility = Visibility.Visible; - element.RenderTransformOrigin = new Point(0, 0.5); // 左侧中心点为基准 - element.RenderTransform = new ScaleTransform(0, 0); - - sb.Begin((FrameworkElement)element); - } - - public static void ShowWithScaleFromRight(UIElement element, double duration = 0.5) - { - if (element.Visibility == Visibility.Visible) return; - - if (element == null) - throw new ArgumentNullException(nameof(element)); - - var sb = new Storyboard(); - - // 水平方向的缩放动画 - var scaleXAnimation = new DoubleAnimation - { - From = 0, - To = 1, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(scaleXAnimation, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)")); - - // 垂直方向的缩放动画 - var scaleYAnimation = new DoubleAnimation - { - From = 0, - To = 1, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(scaleYAnimation, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleY)")); - - sb.Children.Add(scaleXAnimation); - sb.Children.Add(scaleYAnimation); - - element.Visibility = Visibility.Visible; - element.RenderTransformOrigin = new Point(1, 0.5); // 右侧中心点为基准 - element.RenderTransform = new ScaleTransform(0, 0); - - sb.Begin((FrameworkElement)element); - } - - public static void HideWithSlideAndFade(UIElement element, double duration = 0.15) - { - if (element.Visibility == Visibility.Collapsed) return; - - if (element == null) - throw new ArgumentNullException(nameof(element)); - - var sb = new Storyboard(); - - // 渐变动画 - var fadeOutAnimation = new DoubleAnimation - { - From = 1, - To = 0, - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(UIElement.OpacityProperty)); - - // 滑动动画 - var slideAnimation = new DoubleAnimation - { - From = 0, - To = element.RenderTransform.Value.OffsetY + 10, // 滑动距离 - Duration = TimeSpan.FromSeconds(duration) - }; - Storyboard.SetTargetProperty(slideAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)")); - - sb.Children.Add(fadeOutAnimation); - sb.Children.Add(slideAnimation); - - sb.Completed += (s, e) => - { - element.Visibility = Visibility.Collapsed; - }; - - element.RenderTransform = new TranslateTransform(); - sb.Begin((FrameworkElement)element); - } - - } -} diff --git a/Ink Canvas/Helpers/DelAutoSavedFiles.cs b/Ink Canvas/Helpers/DelAutoSavedFiles.cs new file mode 100644 index 0000000..2071ed8 --- /dev/null +++ b/Ink Canvas/Helpers/DelAutoSavedFiles.cs @@ -0,0 +1,51 @@ +using System; +using System.IO; +using System.Windows; + +namespace Ink_Canvas.Helpers { + internal class DelAutoSavedFiles { + public static void DeleteFilesOlder(string directoryPath, int daysThreshold) { + string[] extensionsToDel = { ".icstk", ".png" }; + if (Directory.Exists(directoryPath)) { + // 获取目录中的所有子目录 + string[] subDirectories = Directory.GetDirectories(directoryPath, "*", SearchOption.AllDirectories); + foreach (string subDirectory in subDirectories) { + try { + // 获取子目录下的所有文件 + string[] files = Directory.GetFiles(subDirectory); + foreach (string filePath in files) { + // 获取文件的创建日期 + DateTime creationDate = File.GetCreationTime(filePath); + // 获取文件的扩展名 + string fileExtension = Path.GetExtension(filePath); + // 如果文件的创建日期早于指定天数且是要删除的扩展名,则删除文件 + if (creationDate < DateTime.Now.AddDays(-daysThreshold)) { + if (Array.Exists(extensionsToDel, ext => ext.Equals(fileExtension, StringComparison.OrdinalIgnoreCase)) + || Path.GetFileName(filePath).Equals("Position", StringComparison.OrdinalIgnoreCase)) { + File.Delete(filePath); + } + } + } + } catch (Exception ex) { + LogHelper.WriteLogToFile("DelAutoSavedFiles | 处理文件时出错: " + ex.ToString(), LogHelper.LogType.Error); + } + } + + try { // 递归删除空文件夹 + DeleteEmptyFolders(directoryPath); + } catch (Exception ex) { + LogHelper.WriteLogToFile("DelAutoSavedFiles | 处理文件时出错: " + ex.ToString(), LogHelper.LogType.Error); + } + } + } + + private static void DeleteEmptyFolders(string directoryPath) { + foreach (string dir in Directory.GetDirectories(directoryPath)) { + DeleteEmptyFolders(dir); + if (Directory.GetFiles(dir).Length == 0 && Directory.GetDirectories(dir).Length == 0) { + Directory.Delete(dir, false); + } + } + } + } +} \ No newline at end of file diff --git a/Ink Canvas/Ink Canvas Annotation.ico b/Ink Canvas/Ink Canvas Annotation.ico deleted file mode 100644 index 72a67fe..0000000 Binary files a/Ink Canvas/Ink Canvas Annotation.ico and /dev/null differ diff --git a/Ink Canvas/Ink Canvas.csproj b/Ink Canvas/Ink Canvas.csproj index 35806fa..98ad663 100644 --- a/Ink Canvas/Ink Canvas.csproj +++ b/Ink Canvas/Ink Canvas.csproj @@ -157,6 +157,7 @@ Designer + ChangeLogWindow.xaml diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index cc96911..4b62958 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -20,7 +20,7 @@ Closing="Window_Closing" Closed="Window_Closed" PreviewKeyDown="Main_Grid_PreviewKeyDown" - Height="6500" Width="1440" + Height="7000" Width="1440" FontFamily="Microsoft YaHei UI" MouseWheel="Window_MouseWheel" Foreground="Black" @@ -383,23 +383,23 @@ - + - + - + - + @@ -408,22 +408,22 @@ - + - + - + - + @@ -565,7 +565,7 @@ - + @@ -741,32 +741,30 @@ ManipulationBoundaryFeedback="SCManipulationBoundaryFeedback"> - + - - - - - + - - - @@ -949,9 +947,9 @@ - - - + + + @@ -995,9 +993,9 @@ + - @@ -1014,6 +1012,30 @@ VerticalAlignment="Bottom" Margin="10,0,0,8" FontSize="14" Width="25" HorizontalAlignment="Center"/> + 墨迹、截图自动保存位置: + + +