From 80503dc42eb15d32d6241909130c177cb599ec43 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 07:54:43 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/DeviceIdentifier.cs | 6 +- Ink Canvas/Helpers/GlobalHotkeyManager.cs | 20 +++---- Ink Canvas/Helpers/InkFadeManager.cs | 4 +- .../MainWindow_cs/MW_ElementsControls.cs | 60 ++++++++++++------- .../MainWindow_cs/MW_FloatingBarIcons.cs | 12 ++-- Ink Canvas/MainWindow_cs/MW_TouchEvents.cs | 28 ++++----- .../Windows/HotkeySettingsWindow.xaml.cs | 24 ++++---- 7 files changed, 87 insertions(+), 67 deletions(-) diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs index 04736514..650211db 100644 --- a/Ink Canvas/Helpers/DeviceIdentifier.cs +++ b/Ink Canvas/Helpers/DeviceIdentifier.cs @@ -1512,14 +1512,14 @@ namespace Ink_Canvas.Helpers { try { - LogHelper.WriteLogToFile("DeviceIdentifier | 开始关机时保存使用时间数据", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("DeviceIdentifier | 开始关机时保存使用时间数据"); // 1. 加载现有使用统计数据 var stats = LoadUsageStats(); if (stats == null) { stats = new UsageStats { DeviceId = DeviceId }; - LogHelper.WriteLogToFile("DeviceIdentifier | 创建新的使用统计数据", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("DeviceIdentifier | 创建新的使用统计数据"); } // 2. 计算本次会话时长(防止异常值) @@ -1542,7 +1542,7 @@ namespace Ink_Canvas.Helpers // 4. 保存数据 SaveUsageStats(stats); - LogHelper.WriteLogToFile("DeviceIdentifier | 关机保存完成", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("DeviceIdentifier | 关机保存完成"); } catch (Exception ex) { diff --git a/Ink Canvas/Helpers/GlobalHotkeyManager.cs b/Ink Canvas/Helpers/GlobalHotkeyManager.cs index dd90ddf7..efa21461 100644 --- a/Ink Canvas/Helpers/GlobalHotkeyManager.cs +++ b/Ink Canvas/Helpers/GlobalHotkeyManager.cs @@ -175,7 +175,7 @@ namespace Ink_Canvas.Helpers { if (!File.Exists(HotkeyConfigFile)) { - LogHelper.WriteLogToFile("快捷键配置文件不存在", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("快捷键配置文件不存在"); return new List(); } @@ -208,7 +208,7 @@ namespace Ink_Canvas.Helpers }); } - LogHelper.WriteLogToFile($"从配置文件读取到 {hotkeyList.Count} 个快捷键信息", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"从配置文件读取到 {hotkeyList.Count} 个快捷键信息"); return hotkeyList; } catch (Exception ex) @@ -284,14 +284,14 @@ namespace Ink_Canvas.Helpers { // 成功从配置文件加载快捷键设置 _hotkeysShouldBeRegistered = true; - LogHelper.WriteLogToFile("成功从配置文件加载快捷键设置", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("成功从配置文件加载快捷键设置"); } else { // 如果配置文件不存在或加载失败,使用默认快捷键 if (!File.Exists(HotkeyConfigFile)) { - LogHelper.WriteLogToFile("配置文件不存在,注册默认快捷键", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("配置文件不存在,注册默认快捷键"); RegisterDefaultHotkeys(); _hotkeysShouldBeRegistered = true; } @@ -345,14 +345,14 @@ namespace Ink_Canvas.Helpers if (!_hotkeysShouldBeRegistered) { _hotkeysShouldBeRegistered = true; - LogHelper.WriteLogToFile("启用快捷键注册功能", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("启用快捷键注册功能"); // 立即加载快捷键设置 LoadHotkeysFromSettings(); } else { - LogHelper.WriteLogToFile("快捷键注册功能已经启用,重新加载快捷键设置", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("快捷键注册功能已经启用,重新加载快捷键设置"); // 即使已经启用,也要重新加载快捷键设置以确保快捷键正常工作 LoadHotkeysFromSettings(); } @@ -374,14 +374,14 @@ namespace Ink_Canvas.Helpers if (_hotkeysShouldBeRegistered) { _hotkeysShouldBeRegistered = false; - LogHelper.WriteLogToFile("禁用快捷键注册功能", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("禁用快捷键注册功能"); // 注销所有快捷键 UnregisterAllHotkeys(); } else { - LogHelper.WriteLogToFile("快捷键注册功能已经禁用", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("快捷键注册功能已经禁用"); } } catch (Exception ex) @@ -403,13 +403,13 @@ namespace Ink_Canvas.Helpers { // 鼠标模式下禁用快捷键,让键盘操作放行 DisableHotkeyRegistration(); - LogHelper.WriteLogToFile("切换到鼠标模式,禁用快捷键以放行键盘操作", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("切换到鼠标模式,禁用快捷键以放行键盘操作"); } else { // 非鼠标模式下启用快捷键 EnableHotkeyRegistration(); - LogHelper.WriteLogToFile("切换到非鼠标模式,启用快捷键", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("切换到非鼠标模式,启用快捷键"); } } catch (Exception ex) diff --git a/Ink Canvas/Helpers/InkFadeManager.cs b/Ink Canvas/Helpers/InkFadeManager.cs index febc4662..b28b9eb4 100644 --- a/Ink Canvas/Helpers/InkFadeManager.cs +++ b/Ink Canvas/Helpers/InkFadeManager.cs @@ -258,7 +258,7 @@ namespace Ink_Canvas.Helpers public void Enable() { IsEnabled = true; - LogHelper.WriteLogToFile("墨迹渐隐功能已启用", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("墨迹渐隐功能已启用"); } /// @@ -267,7 +267,7 @@ namespace Ink_Canvas.Helpers public void Disable() { IsEnabled = false; - LogHelper.WriteLogToFile("墨迹渐隐功能已禁用", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("墨迹渐隐功能已禁用"); } #endregion diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index cbfb5a81..66f7a672 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -748,19 +748,30 @@ namespace Ink_Canvas InkCanvas.SetLeft(clonedImage, InkCanvas.GetLeft(image) + 20); InkCanvas.SetTop(clonedImage, InkCanvas.GetTop(image) + 20); + // 设置图片属性,避免被InkCanvas选择系统处理 + clonedImage.IsHitTestVisible = true; + clonedImage.Focusable = false; + + // 初始化变换 + InitializeElementTransform(clonedImage); + + // 绑定事件 + BindElementEvents(clonedImage); + // 添加到画布 inkCanvas.Children.Add(clonedImage); // 提交到时间机器以支持撤销 timeMachine.CommitElementInsertHistory(clonedImage); + + return clonedImage; } catch (Exception ex) { // 记录错误但不中断程序 - System.Diagnostics.Debug.WriteLine($"克隆图片时发生错误: {ex.Message}"); + LogHelper.WriteLogToFile($"克隆图片时发生错误: {ex.Message}", LogHelper.LogType.Error); + return null; } - - return null; } /// @@ -1064,23 +1075,32 @@ namespace Ink_Canvas { if (currentSelectedElement is Image originalImage) { - // 创建克隆图片 - Image clonedImage = CloneImage(originalImage); + // 创建新页面 + BtnWhiteBoardAdd_Click(null, null); - // 这里可以添加切换到新页面的逻辑 - // 暂时先添加到当前页面 - inkCanvas.Children.Add(clonedImage); + // 创建克隆图片(不添加到当前画布,因为已经创建了新页面) + Image clonedImage = CreateClonedImage(originalImage); - // 初始化变换 - InitializeElementTransform(clonedImage); - - // 绑定事件 - BindElementEvents(clonedImage); - - // 记录历史 - timeMachine.CommitElementInsertHistory(clonedImage); - - LogHelper.WriteLogToFile($"图片克隆到新页面完成: {clonedImage.Name}"); + if (clonedImage != null) + { + // 设置图片属性,避免被InkCanvas选择系统处理 + clonedImage.IsHitTestVisible = true; + clonedImage.Focusable = false; + + // 初始化变换 + InitializeElementTransform(clonedImage); + + // 绑定事件 + BindElementEvents(clonedImage); + + // 添加到新页面的画布 + inkCanvas.Children.Add(clonedImage); + + // 记录历史 + timeMachine.CommitElementInsertHistory(clonedImage); + + LogHelper.WriteLogToFile($"图片克隆到新页面完成: {clonedImage.Name}"); + } } } catch (Exception ex) @@ -1185,7 +1205,7 @@ namespace Ink_Canvas } } - // 克隆图片的辅助方法 + // 克隆图片的辅助方法(只创建图片,不添加到画布) private Image CreateClonedImage(Image originalImage) { try @@ -1204,7 +1224,7 @@ namespace Ink_Canvas clonedImage.Stretch = originalImage.Stretch; clonedImage.StretchDirection = originalImage.StretchDirection; - // 复制位置 + // 复制位置(在新页面中居中显示) double left = InkCanvas.GetLeft(originalImage); double top = InkCanvas.GetTop(originalImage); InkCanvas.SetLeft(clonedImage, left + 20); // 稍微偏移位置 diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index ff1b66d6..0754132c 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -2077,9 +2077,9 @@ namespace Ink_Canvas { highlighterColor = 100; // 黑色荧光笔 } - else if (color == Colors.Yellow || IsColorSimilar(color, Color.FromRgb(234, 179, 8), 15) || - IsColorSimilar(color, Color.FromRgb(250, 204, 21), 15) || - IsColorSimilar(color, Color.FromRgb(253, 224, 71), 15)) + else if (color == Colors.Yellow || IsColorSimilar(color, Color.FromRgb(234, 179, 8)) || + IsColorSimilar(color, Color.FromRgb(250, 204, 21)) || + IsColorSimilar(color, Color.FromRgb(253, 224, 71))) { highlighterColor = 103; // 黄色荧光笔 } @@ -2094,12 +2094,12 @@ namespace Ink_Canvas { highlighterColor = 106; // 蓝色荧光笔 } - else if (color == Colors.Red || IsColorSimilar(color, Color.FromRgb(220, 38, 38), 15) || - IsColorSimilar(color, Color.FromRgb(239, 68, 68), 15)) + else if (color == Colors.Red || IsColorSimilar(color, Color.FromRgb(220, 38, 38)) || + IsColorSimilar(color, Color.FromRgb(239, 68, 68))) { highlighterColor = 102; // 红色荧光笔 } - else if (color == Colors.Green || IsColorSimilar(color, Color.FromRgb(22, 163, 74), 15)) + else if (color == Colors.Green || IsColorSimilar(color, Color.FromRgb(22, 163, 74))) { highlighterColor = 104; // 绿色荧光笔 } diff --git a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs index 9c1a8393..a36e7a47 100644 --- a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs +++ b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs @@ -162,13 +162,13 @@ namespace Ink_Canvas return; } - LogHelper.WriteLogToFile($"MainWindow_StylusDown 被调用,笔尾状态: {e.StylusDevice.Inverted}, 当前 drawingShapeMode: {drawingShapeMode}, 当前 EditingMode: {inkCanvas.EditingMode}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"MainWindow_StylusDown 被调用,笔尾状态: {e.StylusDevice.Inverted}, 当前 drawingShapeMode: {drawingShapeMode}, 当前 EditingMode: {inkCanvas.EditingMode}"); // 新增:根据是否为笔尾自动切换橡皮擦/画笔模式 if (e.StylusDevice.Inverted) { inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint; - LogHelper.WriteLogToFile("检测到笔尾,设置 EditingMode 为 EraseByPoint", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("检测到笔尾,设置 EditingMode 为 EraseByPoint"); } else { @@ -177,18 +177,18 @@ namespace Ink_Canvas { // 确保几何绘制模式下不切换到Ink模式,避免触摸轨迹被收集 inkCanvas.EditingMode = InkCanvasEditingMode.None; - LogHelper.WriteLogToFile("几何绘制模式,设置 EditingMode 为 None", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("几何绘制模式,设置 EditingMode 为 None"); return; } // 修复:保持当前的线擦模式,不要强制切换到Ink模式 if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke) { inkCanvas.EditingMode = InkCanvasEditingMode.Ink; - LogHelper.WriteLogToFile("设置 EditingMode 为 Ink", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("设置 EditingMode 为 Ink"); } else { - LogHelper.WriteLogToFile("保持当前线擦模式", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("保持当前线擦模式"); } } SetCursorBasedOnEditingMode(inkCanvas); @@ -230,14 +230,14 @@ namespace Ink_Canvas { try { - LogHelper.WriteLogToFile($"MainWindow_StylusUp 被调用,EditingMode: {inkCanvas.EditingMode}, EnableInkFade: {Settings.Canvas.EnableInkFade}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"MainWindow_StylusUp 被调用,EditingMode: {inkCanvas.EditingMode}, EnableInkFade: {Settings.Canvas.EnableInkFade}"); var stroke = GetStrokeVisual(e.StylusDevice.Id).Stroke; - LogHelper.WriteLogToFile($"获取到墨迹,StylusPoints数量: {stroke.StylusPoints.Count}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"获取到墨迹,StylusPoints数量: {stroke.StylusPoints.Count}"); // 正常模式:添加到画布并参与墨迹纠正 // 墨迹渐隐功能现在在 StrokeCollected 事件中统一处理所有输入方式 - LogHelper.WriteLogToFile("StylusUp: 添加墨迹到画布", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("StylusUp: 添加墨迹到画布"); inkCanvas.Strokes.Add(stroke); await Task.Delay(5); // 避免渲染墨迹完成前预览墨迹被删除导致墨迹闪烁 @@ -528,7 +528,7 @@ namespace Ink_Canvas StartPalmEraserRecoveryTimer(); // 记录日志 - LogHelper.WriteLogToFile($"Palm eraser activated - Sensitivity: {Settings.Canvas.PalmEraserSensitivity}, Touch bounds: {bounds.Width}x{bounds.Height}, Aspect ratio: {aspectRatio:F2}, Touch points: {dec.Count}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"Palm eraser activated - Sensitivity: {Settings.Canvas.PalmEraserSensitivity}, Touch bounds: {bounds.Width}x{bounds.Height}, Aspect ratio: {aspectRatio:F2}, Touch points: {dec.Count}"); } } @@ -623,7 +623,7 @@ namespace Ink_Canvas break; } - LogHelper.WriteLogToFile($"Palm eraser recovered to mode: {palmEraserLastEditingMode}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"Palm eraser recovered to mode: {palmEraserLastEditingMode}"); } } catch (Exception ex) @@ -648,7 +648,7 @@ namespace Ink_Canvas ViewboxFloatingBar.IsHitTestVisible = true; BlackboardUIGridForInkReplay.IsHitTestVisible = true; - LogHelper.WriteLogToFile("Palm eraser state reset completed", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("Palm eraser state reset completed"); } // 新增:超时检测 - 如果手掌擦激活时间过长,强制重置状态 @@ -697,7 +697,7 @@ namespace Ink_Canvas // 停止恢复定时器 StopPalmEraserRecoveryTimer(); - LogHelper.WriteLogToFile("Palm eraser timeout recovery completed", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("Palm eraser timeout recovery completed"); } } // 修复:几何绘制模式下,触摸抬手时应该正确处理,而不是简单模拟鼠标事件 @@ -1033,7 +1033,7 @@ namespace Ink_Canvas break; } - LogHelper.WriteLogToFile($"Palm eraser timer recovery to mode: {palmEraserLastEditingMode}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"Palm eraser timer recovery to mode: {palmEraserLastEditingMode}"); } } catch (Exception ex) @@ -1055,7 +1055,7 @@ namespace Ink_Canvas // 停止定时器 StopPalmEraserRecoveryTimer(); - LogHelper.WriteLogToFile("Palm eraser timer recovery completed", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("Palm eraser timer recovery completed"); } } } diff --git a/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs b/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs index ea00e278..14ca4c9c 100644 --- a/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs +++ b/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs @@ -57,7 +57,7 @@ namespace Ink_Canvas.Windows { try { - LogHelper.WriteLogToFile("开始初始化快捷键项", LogHelper.LogType.Info); + LogHelper.WriteLogToFile("开始初始化快捷键项"); // 初始化快捷键项并设置HotkeyName _hotkeyItems["Undo"] = UndoHotkey; @@ -114,7 +114,7 @@ namespace Ink_Canvas.Windows _hotkeyItems["Exit"] = ExitHotkey; ExitHotkey.HotkeyName = "Exit"; - LogHelper.WriteLogToFile($"成功初始化 {_hotkeyItems.Count} 个快捷键项", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"成功初始化 {_hotkeyItems.Count} 个快捷键项"); } catch (Exception ex) { @@ -128,7 +128,7 @@ namespace Ink_Canvas.Windows { // 首先尝试从配置文件获取快捷键信息 var configHotkeys = _hotkeyManager.GetHotkeysFromConfigFile(); - LogHelper.WriteLogToFile($"配置文件中的快捷键数量: {configHotkeys.Count}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"配置文件中的快捷键数量: {configHotkeys.Count}"); // 显示配置文件中的快捷键 foreach (var hotkey in configHotkeys) @@ -136,7 +136,7 @@ namespace Ink_Canvas.Windows if (_hotkeyItems.TryGetValue(hotkey.Name, out var hotkeyItem)) { hotkeyItem.SetCurrentHotkey(hotkey.Key, hotkey.Modifiers); - LogHelper.WriteLogToFile($"从配置文件设置快捷键项: {hotkey.Name} -> {hotkey.Modifiers}+{hotkey.Key}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"从配置文件设置快捷键项: {hotkey.Name} -> {hotkey.Modifiers}+{hotkey.Key}"); } } @@ -148,7 +148,7 @@ namespace Ink_Canvas.Windows { // 根据DefaultKey和DefaultModifiers设置默认显示值 SetDefaultHotkeyForItem(hotkeyItem); - LogHelper.WriteLogToFile($"设置默认显示值: {hotkeyItem.HotkeyName}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"设置默认显示值: {hotkeyItem.HotkeyName}"); } } } @@ -243,7 +243,7 @@ namespace Ink_Canvas.Windows { try { - LogHelper.WriteLogToFile($"收到快捷键变更事件: {e.HotkeyName} -> {e.Modifiers}+{e.Key}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"收到快捷键变更事件: {e.HotkeyName} -> {e.Modifiers}+{e.Key}"); // 检查快捷键冲突 if (IsHotkeyConflict(e.Key, e.Modifiers, e.HotkeyName)) @@ -305,30 +305,30 @@ namespace Ink_Canvas.Windows { try { - LogHelper.WriteLogToFile($"开始更新快捷键: {hotkeyName} -> {modifiers}+{key}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"开始更新快捷键: {hotkeyName} -> {modifiers}+{key}"); // 先注销原有的快捷键(如果存在) _hotkeyManager.UnregisterHotkey(hotkeyName); - LogHelper.WriteLogToFile($"已注销原有快捷键: {hotkeyName}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"已注销原有快捷键: {hotkeyName}"); // 根据快捷键名称获取对应的动作 var action = GetActionForHotkey(hotkeyName); if (action != null) { - LogHelper.WriteLogToFile($"找到快捷键动作: {hotkeyName}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"找到快捷键动作: {hotkeyName}"); // 直接注册新的快捷键 if (_hotkeyManager.RegisterHotkey(hotkeyName, key, modifiers, action)) { - LogHelper.WriteLogToFile($"成功注册新快捷键: {hotkeyName} -> {modifiers}+{key}", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"成功注册新快捷键: {hotkeyName} -> {modifiers}+{key}"); // 立即保存到配置文件 _hotkeyManager.SaveHotkeysToSettings(); - LogHelper.WriteLogToFile($"已保存快捷键配置", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"已保存快捷键配置"); // 更新UI显示 LoadCurrentHotkeys(); - LogHelper.WriteLogToFile($"已更新UI显示", LogHelper.LogType.Info); + LogHelper.WriteLogToFile($"已更新UI显示"); LogHelper.WriteLogToFile($"快捷键 {hotkeyName} 已更新为 {modifiers}+{key} 并保存", LogHelper.LogType.Event); } From 5784c974f729f9b3a41c1b79f74a08e7f2776c65 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 07:56:26 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/DeviceIdentifier.cs | 1 - Ink Canvas/Helpers/InkSmoothingConfig.cs | 1 - Ink Canvas/MainWindow_cs/MW_ElementsControls.cs | 2 -- Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs | 2 -- 4 files changed, 6 deletions(-) diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs index 650211db..da8d7de3 100644 --- a/Ink Canvas/Helpers/DeviceIdentifier.cs +++ b/Ink Canvas/Helpers/DeviceIdentifier.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Reflection; using System.Security.Cryptography; using System.Text; -using System.Threading; namespace Ink_Canvas.Helpers { diff --git a/Ink Canvas/Helpers/InkSmoothingConfig.cs b/Ink Canvas/Helpers/InkSmoothingConfig.cs index e57aad38..af8420f8 100644 --- a/Ink Canvas/Helpers/InkSmoothingConfig.cs +++ b/Ink Canvas/Helpers/InkSmoothingConfig.cs @@ -1,5 +1,4 @@ using System; -using System.Configuration; namespace Ink_Canvas.Helpers { diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index 66f7a672..0a0b6b6e 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -6,11 +6,9 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Threading; using Ink_Canvas.Helpers; using System.Windows.Input; using System.Linq; -using System.Collections.Generic; using System.Windows.Ink; namespace Ink_Canvas diff --git a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs index 6c6ab016..88daa927 100644 --- a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs +++ b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs @@ -6,8 +6,6 @@ using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Shapes; -using System.Windows.Threading; using Point = System.Windows.Point; using System.Linq; From a2aa6b48a8ccdb2d8d3e95b05fddfacf3b2b3089 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 08:04:46 +0800 Subject: [PATCH 03/14] =?UTF-8?q?improve:=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C=E5=88=86=E7=BA=A7=E5=8F=8A=E5=9B=BE=E7=89=87=E6=8F=92?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/DeviceIdentifier.cs | 214 +++--------------- Ink Canvas/MainWindow.xaml.cs | 13 +- .../MainWindow_cs/MW_ElementsControls.cs | 2 - 3 files changed, 33 insertions(+), 196 deletions(-) diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs index da8d7de3..306ff21f 100644 --- a/Ink Canvas/Helpers/DeviceIdentifier.cs +++ b/Ink Canvas/Helpers/DeviceIdentifier.cs @@ -349,14 +349,7 @@ namespace Ink_Canvas.Helpers [JsonProperty("averageSessionSeconds")] public double AverageSessionSeconds { get; set; } - // 保留旧字段以保持向后兼容性(已弃用) - [JsonProperty("totalUsageMinutes")] - [Obsolete("已弃用,请使用 TotalUsageSeconds")] - public long TotalUsageMinutes { get; set; } - [JsonProperty("averageSessionMinutes")] - [Obsolete("已弃用,请使用 AverageSessionSeconds")] - public double AverageSessionMinutes { get; set; } [JsonProperty("lastUpdateCheck")] public DateTime LastUpdateCheck { get; set; } @@ -386,53 +379,6 @@ namespace Ink_Canvas.Helpers [JsonProperty("lastWeekUsageSeconds")] public long LastWeekUsageSeconds { get; set; } - // 保留旧字段以保持向后兼容性(已弃用) - [JsonProperty("weeklyUsageMinutes")] - [Obsolete("已弃用,请使用 WeeklyUsageSeconds")] - public long WeeklyUsageMinutes { get; set; } - - [JsonProperty("lastWeekUsageMinutes")] - [Obsolete("已弃用,请使用 LastWeekUsageSeconds")] - public long LastWeekUsageMinutes { get; set; } - - /// - /// 数据迁移:从分钟精度迁移到秒级精度 - /// - public void MigrateToSecondsPrecision() - { - try - { - // 如果新字段为空但旧字段有数据,进行迁移 - if (TotalUsageSeconds == 0 && TotalUsageSeconds > 0) - { - TotalUsageSeconds = TotalUsageSeconds * 60; - LogHelper.WriteLogToFile($"DeviceIdentifier | 迁移总使用时长: {TotalUsageSeconds}分钟 -> {TotalUsageSeconds}秒"); - } - - if (AverageSessionSeconds == 0 && AverageSessionSeconds > 0) - { - AverageSessionSeconds = AverageSessionSeconds * 60; - LogHelper.WriteLogToFile($"DeviceIdentifier | 迁移平均会话时长: {AverageSessionSeconds}分钟 -> {AverageSessionSeconds}秒"); - } - - if (WeeklyUsageSeconds == 0 && WeeklyUsageSeconds > 0) - { - WeeklyUsageSeconds = WeeklyUsageSeconds * 60; - LogHelper.WriteLogToFile($"DeviceIdentifier | 迁移每周使用时长: {WeeklyUsageSeconds}分钟 -> {WeeklyUsageSeconds}秒"); - } - - if (LastWeekUsageSeconds == 0 && LastWeekUsageSeconds > 0) - { - LastWeekUsageSeconds = LastWeekUsageSeconds * 60; - LogHelper.WriteLogToFile($"DeviceIdentifier | 迁移上周使用时长: {LastWeekUsageSeconds}分钟 -> {LastWeekUsageSeconds}秒"); - } - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"DeviceIdentifier | 数据迁移失败: {ex.Message}", LogHelper.LogType.Error); - } - } - /// /// 检查并重置每周统计数据(秒级精度) /// @@ -448,13 +394,9 @@ namespace Ink_Canvas.Helpers LastWeekLaunchCount = WeeklyLaunchCount; LastWeekUsageSeconds = WeeklyUsageSeconds; - // 同时更新旧字段以保持兼容性 - LastWeekUsageSeconds = LastWeekUsageSeconds / 60; - // 重置本周数据 WeeklyLaunchCount = 0; WeeklyUsageSeconds = 0; - WeeklyUsageSeconds = 0; WeekStartDate = currentWeekStart; LogHelper.WriteLogToFile($"DeviceIdentifier | 每周统计重置 - 上周启动: {LastWeekLaunchCount}次, 上周使用: {FormatDuration(LastWeekUsageSeconds)}"); @@ -487,8 +429,6 @@ namespace Ink_Canvas.Helpers { CheckAndResetWeeklyStats(); WeeklyUsageSeconds += seconds; - // 同时更新旧字段以保持兼容性 - WeeklyUsageSeconds = WeeklyUsageSeconds / 60; } } @@ -586,9 +526,6 @@ namespace Ink_Canvas.Helpers { var stats = LoadUsageStats(); - // 执行数据迁移(如果需要) - stats.MigrateToSecondsPrecision(); - // 计算本次会话时长(秒级精度) long sessionSeconds = 0; if (stats.LastLaunchTime != DateTime.MinValue) @@ -599,8 +536,7 @@ namespace Ink_Canvas.Helpers // 更新秒级精度数据 stats.TotalUsageSeconds += sessionSeconds; - // 同时更新旧字段以保持兼容性 - stats.TotalUsageSeconds = stats.TotalUsageSeconds / 60; + // 记录每周使用时长(秒级精度) stats.RecordWeeklyUsage(sessionSeconds); @@ -609,8 +545,7 @@ namespace Ink_Canvas.Helpers if (stats.LaunchCount > 0) { stats.AverageSessionSeconds = (double)stats.TotalUsageSeconds / stats.LaunchCount; - // 同时更新旧字段以保持兼容性 - stats.AverageSessionSeconds = stats.AverageSessionSeconds / 60; + } } @@ -648,21 +583,13 @@ namespace Ink_Canvas.Helpers var currentWeekLaunches = stats.WeeklyLaunchCount; var currentWeekSeconds = stats.WeeklyUsageSeconds; - // 如果秒级数据为空但分钟数据存在,进行转换 - if (currentWeekSeconds == 0 && stats.WeeklyUsageSeconds > 0) - { - currentWeekSeconds = stats.WeeklyUsageSeconds * 60; - } + // 如果本周数据不足,参考上周数据 var weeklyLaunches = currentWeekLaunches > 0 ? currentWeekLaunches : stats.LastWeekLaunchCount; var weeklySeconds = currentWeekSeconds > 0 ? currentWeekSeconds : stats.LastWeekUsageSeconds; - // 如果秒级数据仍为空,使用分钟数据转换 - if (weeklySeconds == 0 && stats.LastWeekUsageSeconds > 0) - { - weeklySeconds = stats.LastWeekUsageSeconds * 60; - } + // 综合评分系统(0-100分) var frequencyScore = CalculateFrequencyScoreWithWeeklyData(stats, daysSinceLastUse, weeklyLaunches, weeklySeconds); @@ -730,7 +657,7 @@ namespace Ink_Canvas.Helpers else if (weeklySeconds >= 3600) score += 5; // 1-2小时:轻度使用 // 历史使用深度评分(10分)- 反映用户的长期使用习惯(秒级精度) - var totalSeconds = stats.TotalUsageSeconds > 0 ? stats.TotalUsageSeconds : stats.TotalUsageSeconds * 60; + var totalSeconds = stats.TotalUsageSeconds; if (totalSeconds >= 180000) score += 10; // 50小时以上:资深用户 else if (totalSeconds >= 72000) score += 7; // 20-50小时:中等用户 else if (totalSeconds >= 18000) score += 4; // 5-20小时:新手用户 @@ -791,25 +718,7 @@ namespace Ink_Canvas.Helpers } } - /// - /// 获取使用统计信息(兼容性方法 - 分钟精度) - /// - [Obsolete("请使用 GetUsageStats() 获取秒级精度数据")] - public static (int launchCount, long totalMinutes, double avgSessionMinutes, UpdatePriority priority) GetUsageStatsInMinutes() - { - try - { - var stats = LoadUsageStats(); - var totalMinutes = stats.TotalUsageSeconds / 60; - var avgMinutes = stats.AverageSessionSeconds / 60; - return (stats.LaunchCount, totalMinutes, avgMinutes, stats.UpdatePriority); - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"DeviceIdentifier | 获取使用统计失败: {ex.Message}", LogHelper.LogType.Error); - return (0, 0, 0, UpdatePriority.Medium); - } - } + /// /// 加载使用统计 @@ -822,26 +731,27 @@ namespace Ink_Canvas.Helpers var stats = LoadUsageStatsFromFile(UsageStatsFilePath); if (stats != null) { - // 执行数据迁移(如果需要) - stats.MigrateToSecondsPrecision(); return stats; } - // 2. 尝试从备份文件加载 + // 2. 主文件无法读取,尝试从备份文件恢复 + LogHelper.WriteLogToFile("DeviceIdentifier | 主文件无法读取,尝试从备份文件恢复"); + if (RestoreUsageStatsFromBackup()) + { + // 恢复成功后重新尝试加载主文件 + stats = LoadUsageStatsFromFile(UsageStatsFilePath); + if (stats != null) + { + LogHelper.WriteLogToFile("DeviceIdentifier | 从备份文件成功恢复主文件"); + return stats; + } + } + + // 3. 如果备份恢复也失败,尝试直接加载备份文件 stats = LoadUsageStatsFromFile(UsageStatsBackupPath); if (stats != null) { - LogHelper.WriteLogToFile("DeviceIdentifier | 从备份文件恢复使用统计"); - stats.MigrateToSecondsPrecision(); - // 尝试恢复主文件 - try - { - SaveUsageStatsToFile(UsageStatsFilePath, stats); - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"DeviceIdentifier | 恢复主文件失败: {ex.Message}", LogHelper.LogType.Warning); - } + LogHelper.WriteLogToFile("DeviceIdentifier | 直接使用备份文件数据"); return stats; } @@ -853,8 +763,8 @@ namespace Ink_Canvas.Helpers DeviceId = DeviceId, LastLaunchTime = DateTime.Now, LaunchCount = 0, - TotalUsageSeconds = 0, // 保持兼容性 - AverageSessionSeconds = 0, // 保持兼容性 + TotalUsageSeconds = 0, + AverageSessionSeconds = 0, LastUpdateCheck = DateTime.MinValue, UpdatePriority = UpdatePriority.Medium, UsageFrequency = UsageFrequency.Medium @@ -913,21 +823,7 @@ namespace Ink_Canvas.Helpers return stats; } - // 如果解密失败,尝试作为普通JSON文件读取(向后兼容) - try - { - string json = File.ReadAllText(filePath); - var plainStats = JsonConvert.DeserializeObject(json); - if (plainStats != null && !string.IsNullOrEmpty(plainStats.DeviceId)) - { - LogHelper.WriteLogToFile($"DeviceIdentifier | 从普通JSON文件加载使用统计: {filePath}"); - return plainStats; - } - } - catch - { - // 忽略JSON解析错误 - } + } } catch (Exception ex) @@ -997,7 +893,7 @@ namespace Ink_Canvas.Helpers return null; } - /// + /// /// 保存使用统计到文件(加密) /// private static void SaveUsageStatsToFile(string filePath, UsageStats stats) @@ -1062,45 +958,7 @@ namespace Ink_Canvas.Helpers LogHelper.WriteLogToFile($"DeviceIdentifier | 记录更新检查失败: {ex.Message}", LogHelper.LogType.Error); } } - - /// - /// 验证使用统计数据的完整性 - /// - public static bool ValidateUsageStatsIntegrity() - { - try - { - // 检查主文件 - if (File.Exists(UsageStatsFilePath)) - { - var mainStats = LoadUsageStatsFromFile(UsageStatsFilePath); - if (mainStats != null && mainStats.DeviceId == DeviceId) - { - LogHelper.WriteLogToFile("DeviceIdentifier | 主文件数据完整性验证通过"); - return true; - } - } - - // 检查备份文件 - if (File.Exists(UsageStatsBackupPath)) - { - var backupStats = LoadUsageStatsFromFile(UsageStatsBackupPath); - if (backupStats != null && backupStats.DeviceId == DeviceId) - { - LogHelper.WriteLogToFile("DeviceIdentifier | 备份文件数据完整性验证通过"); - return true; - } - } - - LogHelper.WriteLogToFile("DeviceIdentifier | 数据完整性验证失败", LogHelper.LogType.Warning); - return false; - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"DeviceIdentifier | 数据完整性验证失败: {ex.Message}", LogHelper.LogType.Error); - return false; - } - } + /// /// 从备份文件恢复使用统计数据 @@ -1429,26 +1287,6 @@ namespace Ink_Canvas.Helpers } } - /// - /// 检查是否应该进行版本修复(不受分级策略影响) - /// - /// 当前版本 - /// 可用版本 - /// 是否需要版本修复 - public static bool ShouldPerformVersionFix(string currentVersion, string availableVersion) - { - try - { - // 版本修复功能不受使用频率分级策略影响,始终允许 - LogHelper.WriteLogToFile($"DeviceIdentifier | 版本修复检查 - 当前版本: {currentVersion}, 可用版本: {availableVersion}, 结果: 允许"); - return true; - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"DeviceIdentifier | 版本修复检查失败: {ex.Message}", LogHelper.LogType.Error); - return true; // 出错时默认允许 - } - } /// diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index 5e9794d2..af57d460 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -996,14 +996,15 @@ namespace Ink_Canvas // 使用辅助方法设置光标 SetCursorBasedOnEditingMode(sender as InkCanvas); - // 在选择模式下,如果点击的不是UI元素,则取消选择 - if (inkCanvas.EditingMode == InkCanvasEditingMode.Select) + // 检查是否点击了空白区域或其他非图片元素 + var hitTest = e.OriginalSource; + if (!(hitTest is Image) && !(hitTest is MediaElement)) { - var hitTest = e.OriginalSource; - // 如果点击的不是图片或其他UI元素,则取消选择 - if (!(hitTest is Image) && !(hitTest is MediaElement)) + // 如果当前有选中的元素,取消选中状态 + if (currentSelectedElement != null) { - + UnselectElement(currentSelectedElement); + currentSelectedElement = null; } } } diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index 0a0b6b6e..0986d973 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -108,8 +108,6 @@ namespace Ink_Canvas { if (sender is FrameworkElement element) { - - // 取消之前选中的元素 if (currentSelectedElement != null && currentSelectedElement != element) { From 1bc23af61a451a14b17263d188b7c5bb4727c874 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 08:51:50 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/DeviceIdentifier.cs | 4 +-- Ink Canvas/Helpers/GlobalHotkeyManager.cs | 8 ++--- .../HardwareAcceleratedInkProcessor.cs | 2 -- Ink Canvas/MainWindow.xaml | 2 +- Ink Canvas/MainWindow_cs/MW_BoardControls.cs | 36 +++++++++++++++++-- .../MainWindow_cs/MW_FloatingBarIcons.cs | 5 +-- Ink Canvas/MainWindow_cs/MW_PageListView.cs | 14 ++++++++ Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs | 4 +-- Ink Canvas/Windows/CountdownTimerWindow.xaml | 14 ++++---- .../Windows/CountdownTimerWindow.xaml.cs | 14 ++++---- Ink Canvas/Windows/OperatingGuideWindow.xaml | 4 +-- .../Windows/OperatingGuideWindow.xaml.cs | 4 +-- .../Windows/PluginSettingsWindow.xaml.cs | 4 +-- Ink Canvas/Windows/RandWindow.xaml | 8 ++--- Ink Canvas/Windows/RandWindow.xaml.cs | 4 +-- 15 files changed, 81 insertions(+), 46 deletions(-) diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs index 306ff21f..e34c4e4c 100644 --- a/Ink Canvas/Helpers/DeviceIdentifier.cs +++ b/Ink Canvas/Helpers/DeviceIdentifier.cs @@ -1339,9 +1339,7 @@ namespace Ink_Canvas.Helpers return descriptions.Count > 0 ? string.Join(", ", descriptions) : "普通用户"; } - - - + /// /// 关机时保存使用时间数据 /// diff --git a/Ink Canvas/Helpers/GlobalHotkeyManager.cs b/Ink Canvas/Helpers/GlobalHotkeyManager.cs index efa21461..c7f43345 100644 --- a/Ink Canvas/Helpers/GlobalHotkeyManager.cs +++ b/Ink Canvas/Helpers/GlobalHotkeyManager.cs @@ -721,26 +721,22 @@ namespace Ink_Canvas.Helpers // 根据高光位置判断当前选中的工具 // 位置计算基于SetFloatingBarHighlightPosition方法中的逻辑 - bool isMouseMode = false; - string currentTool = "unknown"; - + bool isMouseMode; + // 简化判断:如果位置接近0,说明是鼠标模式 // 如果位置接近28,说明是批注模式 // 如果位置更大,说明是其他工具 if (position < 5) // 鼠标模式:marginOffset + (cursorWidth - actualHighlightWidth) / 2 ≈ 0 { isMouseMode = true; - currentTool = "鼠标"; } else if (position < 35) // 批注模式:marginOffset + cursorWidth + (penWidth - actualHighlightWidth) / 2 ≈ 28 { isMouseMode = false; - currentTool = "批注"; } else // 其他工具(橡皮擦、选择等) { isMouseMode = false; - currentTool = "其他工具"; } return isMouseMode; diff --git a/Ink Canvas/Helpers/HardwareAcceleratedInkProcessor.cs b/Ink Canvas/Helpers/HardwareAcceleratedInkProcessor.cs index 1ca4689f..5342b8f6 100644 --- a/Ink Canvas/Helpers/HardwareAcceleratedInkProcessor.cs +++ b/Ink Canvas/Helpers/HardwareAcceleratedInkProcessor.cs @@ -16,7 +16,6 @@ namespace Ink_Canvas.Helpers { private readonly RenderTargetBitmap _renderTarget; private readonly DrawingVisual _drawingVisual; - private readonly DrawingContext _drawingContext; private bool _isInitialized; public HardwareAcceleratedInkProcessor(int width = 1920, int height = 1080) @@ -191,7 +190,6 @@ namespace Ink_Canvas.Helpers /// public void Dispose() { - _drawingContext?.Close(); _renderTarget?.Clear(); _isInitialized = false; } diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index c00ff977..00b1ac61 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -5159,7 +5159,7 @@ - Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true); if (CurrentWhiteboardIndex >= WhiteboardTotalCount) { - // 在最后一页时,点击“新页面”按钮直接新增一页 + // 在最后一页时,点击"新页面"按钮直接新增一页 BtnWhiteBoardAdd_Click(sender, e); return; } + // 隐藏图片选择工具栏 + if (currentSelectedElement != null) + { + UnselectElement(currentSelectedElement); + currentSelectedElement = null; + } SaveStrokes(); @@ -251,6 +269,13 @@ namespace Ink_Canvas if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true); + // 隐藏图片选择工具栏 + if (currentSelectedElement != null) + { + UnselectElement(currentSelectedElement); + currentSelectedElement = null; + } + SaveStrokes(); ClearStrokes(true); @@ -279,6 +304,13 @@ namespace Ink_Canvas private void BtnWhiteBoardDelete_Click(object sender, RoutedEventArgs e) { + // 隐藏图片选择工具栏 + if (currentSelectedElement != null) + { + UnselectElement(currentSelectedElement); + currentSelectedElement = null; + } + ClearStrokes(true); if (CurrentWhiteboardIndex != WhiteboardTotalCount) diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 0754132c..29e6fd09 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -3096,19 +3096,16 @@ namespace Ink_Canvas // 检查快捷调色盘是否显示及其实际宽度 bool isQuickColorPaletteVisible = false; double quickColorPaletteWidth = 0; - string quickColorPaletteMode = "none"; - + if (QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) { isQuickColorPaletteVisible = true; quickColorPaletteWidth = QuickColorPalettePanel.ActualWidth > 0 ? QuickColorPalettePanel.ActualWidth : 60; - quickColorPaletteMode = "double"; } else if (QuickColorPaletteSingleRowPanel != null && QuickColorPaletteSingleRowPanel.Visibility == Visibility.Visible) { isQuickColorPaletteVisible = true; quickColorPaletteWidth = QuickColorPaletteSingleRowPanel.ActualWidth > 0 ? QuickColorPaletteSingleRowPanel.ActualWidth : 120; - quickColorPaletteMode = "single"; } // 获取实际按钮宽度,如果获取不到则使用默认值,同时考虑按钮的可见性 diff --git a/Ink Canvas/MainWindow_cs/MW_PageListView.cs b/Ink Canvas/MainWindow_cs/MW_PageListView.cs index c82a0113..5b4daa7e 100644 --- a/Ink Canvas/MainWindow_cs/MW_PageListView.cs +++ b/Ink Canvas/MainWindow_cs/MW_PageListView.cs @@ -86,6 +86,13 @@ namespace Ink_Canvas // 只有当选择的页面与当前页面不同时才进行切换 if (index + 1 != CurrentWhiteboardIndex) { + // 隐藏图片选择工具栏 + if (currentSelectedElement != null) + { + UnselectElement(currentSelectedElement); + currentSelectedElement = null; + } + SaveStrokes(); ClearStrokes(true); CurrentWhiteboardIndex = index + 1; @@ -108,6 +115,13 @@ namespace Ink_Canvas // 只有当选择的页面与当前页面不同时才进行切换 if (index + 1 != CurrentWhiteboardIndex) { + // 隐藏图片选择工具栏 + if (currentSelectedElement != null) + { + UnselectElement(currentSelectedElement); + currentSelectedElement = null; + } + SaveStrokes(); ClearStrokes(true); CurrentWhiteboardIndex = index + 1; diff --git a/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs b/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs index 5ca45da5..f72ed6ab 100644 --- a/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs +++ b/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs @@ -74,9 +74,9 @@ namespace Ink_Canvas ToggleSwitchDrawShapeBorderAutoHide.IsOn = !ToggleSwitchDrawShapeBorderAutoHide.IsOn; if (ToggleSwitchDrawShapeBorderAutoHide.IsOn) - ((SymbolIcon)sender).Symbol = Symbol.Pin; + ((FontIcon)sender).Glyph = ""; else - ((SymbolIcon)sender).Symbol = Symbol.UnPin; + ((FontIcon)sender).Glyph = ""; } private object lastMouseDownSender; diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml b/Ink Canvas/Windows/CountdownTimerWindow.xaml index 1a8bfe8e..8c785503 100644 --- a/Ink Canvas/Windows/CountdownTimerWindow.xaml +++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml @@ -179,12 +179,12 @@ - + - + @@ -194,12 +194,12 @@ - + - + @@ -215,7 +215,7 @@ - + - + - + diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs index 5b1ce454..08d2d462 100644 --- a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs +++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs @@ -57,7 +57,7 @@ namespace Ink_Canvas TextBlockSecond.Text = "00"; timer.Stop(); isTimerRunning = false; - SymbolIconStart.Symbol = Symbol.Play; + FontIconStart.Glyph = ""; BtnStartCover.Visibility = Visibility.Visible; TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F")); BorderStopTime.Visibility = Visibility.Collapsed; @@ -208,12 +208,12 @@ namespace Ink_Canvas if (WindowState == WindowState.Normal) { WindowState = WindowState.Maximized; - SymbolIconFullscreen.Symbol = Symbol.BackToWindow; + FontIconFullscreen.Glyph = ""; } else { WindowState = WindowState.Normal; - SymbolIconFullscreen.Symbol = Symbol.FullScreen; + FontIconFullscreen.Glyph = ""; } } @@ -238,7 +238,7 @@ namespace Ink_Canvas BtnStartCover.Visibility = Visibility.Collapsed; BorderStopTime.Visibility = Visibility.Collapsed; TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F")); - SymbolIconStart.Symbol = Symbol.Play; + FontIconStart.Glyph = ""; isTimerRunning = false; timer.Stop(); isPaused = false; @@ -288,7 +288,7 @@ namespace Ink_Canvas startTime += DateTime.Now - pauseTime; ProcessBarTime.IsPaused = false; TextBlockHour.Foreground = Brushes.Black; - SymbolIconStart.Symbol = Symbol.Pause; + FontIconStart.Glyph = ""; isPaused = false; timer.Start(); UpdateStopTime(); @@ -300,7 +300,7 @@ namespace Ink_Canvas pauseTime = DateTime.Now; ProcessBarTime.IsPaused = true; TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F")); - SymbolIconStart.Symbol = Symbol.Play; + FontIconStart.Glyph = ""; BorderStopTime.Visibility = Visibility.Collapsed; isPaused = true; timer.Stop(); @@ -312,7 +312,7 @@ namespace Ink_Canvas totalSeconds = ((hour * 60) + minute) * 60 + second; ProcessBarTime.IsPaused = false; TextBlockHour.Foreground = Brushes.Black; - SymbolIconStart.Symbol = Symbol.Pause; + FontIconStart.Glyph = ""; BtnResetCover.Visibility = Visibility.Collapsed; if (totalSeconds <= 10) diff --git a/Ink Canvas/Windows/OperatingGuideWindow.xaml b/Ink Canvas/Windows/OperatingGuideWindow.xaml index 67c81734..351d6962 100644 --- a/Ink Canvas/Windows/OperatingGuideWindow.xaml +++ b/Ink Canvas/Windows/OperatingGuideWindow.xaml @@ -80,7 +80,7 @@ - + - + diff --git a/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs b/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs index 3357980f..7b129e9c 100644 --- a/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs +++ b/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs @@ -31,12 +31,12 @@ namespace Ink_Canvas if (WindowState == WindowState.Normal) { WindowState = WindowState.Maximized; - SymbolIconFullscreen.Symbol = Symbol.BackToWindow; + FontIconFullscreen.Glyph = ""; } else { WindowState = WindowState.Normal; - SymbolIconFullscreen.Symbol = Symbol.FullScreen; + FontIconFullscreen.Glyph = ""; } } diff --git a/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs b/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs index 3fa180fa..cdaecc4e 100644 --- a/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs +++ b/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs @@ -68,11 +68,11 @@ namespace Ink_Canvas.Windows } } - public string Name => SelectedPlugin?.Name ?? string.Empty; + public new string Name => SelectedPlugin?.Name ?? string.Empty; public string Version => SelectedPlugin?.Version?.ToString() ?? string.Empty; public string Author => SelectedPlugin?.Author ?? string.Empty; public string Description => SelectedPlugin?.Description ?? string.Empty; - public bool IsEnabled => SelectedPlugin is PluginBase plugin && plugin.IsEnabled; + public new bool IsEnabled => SelectedPlugin is PluginBase plugin && plugin.IsEnabled; public bool IsBuiltIn => SelectedPlugin?.IsBuiltIn ?? false; /// diff --git a/Ink Canvas/Windows/RandWindow.xaml b/Ink Canvas/Windows/RandWindow.xaml index f1bada9c..135d1dc2 100644 --- a/Ink Canvas/Windows/RandWindow.xaml +++ b/Ink Canvas/Windows/RandWindow.xaml @@ -98,7 +98,7 @@ - + @@ -113,7 +113,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -137,7 +137,7 @@ - + diff --git a/Ink Canvas/Windows/RandWindow.xaml.cs b/Ink Canvas/Windows/RandWindow.xaml.cs index aa391d8f..ae708f2a 100644 --- a/Ink Canvas/Windows/RandWindow.xaml.cs +++ b/Ink Canvas/Windows/RandWindow.xaml.cs @@ -100,7 +100,7 @@ namespace Ink_Canvas if (RandMaxPeopleOneTime != -1 && TotalCount >= RandMaxPeopleOneTime) return; TotalCount++; LabelNumberCount.Text = TotalCount.ToString(); - SymbolIconStart.Symbol = Symbol.People; + FontIconStart.Glyph = ""; BorderBtnAdd.Opacity = 1; BorderBtnMinus.Opacity = 1; } @@ -112,7 +112,7 @@ namespace Ink_Canvas LabelNumberCount.Text = TotalCount.ToString(); if (TotalCount == 1) { - SymbolIconStart.Symbol = Symbol.Contact; + FontIconStart.Glyph = ""; } } From 26cd125534e781f6d147403bc9d14d928d2a588b Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 09:00:32 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow_cs/MW_ElementsControls.cs | 3 --- Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs | 2 +- Ink Canvas/MainWindow_cs/MW_PPT.cs | 11 ----------- Ink Canvas/MainWindow_cs/MW_TouchEvents.cs | 2 +- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index 0986d973..cb991b8e 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -19,7 +19,6 @@ namespace Ink_Canvas private FrameworkElement currentSelectedElement; private bool isDragging = false; private Point dragStartPoint; - private bool isElementSelected = false; #region Image private async void BtnImageInsert_Click(object sender, RoutedEventArgs e) @@ -253,7 +252,6 @@ namespace Ink_Canvas private void SelectElement(FrameworkElement element) { currentSelectedElement = element; - isElementSelected = true; // 根据元素类型显示不同的选择工具栏 if (element is Image) @@ -307,7 +305,6 @@ namespace Ink_Canvas private void UnselectElement(FrameworkElement element) { // 去除选中效果 - isElementSelected = false; // 隐藏所有选择工具栏 if (BorderImageSelectionControl != null) diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 29e6fd09..2bc43aad 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -2802,7 +2802,7 @@ namespace Ink_Canvas await Task.Delay(100); // Capture screenshot and insert to canvas - await CaptureScreenshotAndInsert(); + CaptureScreenshotAndInsert(); } private async void ImageOptionSelectFile_MouseUp(object sender, MouseButtonEventArgs e) diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index f3c05cab..ea3ac813 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -76,15 +76,11 @@ namespace Ink_Canvas #region PPT State Management private bool wasFloatingBarFoldedWhenEnterSlideShow; - private static bool hasShownWpsForceCloseWarning = false; private bool isEnteredSlideShowEndEvent; //防止重复调用本函数导致墨迹保存失效 private bool isPresentationHaveBlackSpace; - private string pptName; - private bool _isPptClickingBtnTurned; // 长按翻页相关字段 private DispatcherTimer _longPressTimer; - private bool _isLongPressActive = false; private bool _isLongPressNext = true; // true为下一页,false为上一页 private const int LongPressDelay = 15; // 长按延迟时间(毫秒) private const int LongPressInterval = 15; // 长按翻页间隔(毫秒) @@ -202,7 +198,6 @@ namespace Ink_Canvas if (!Settings.PowerPointSettings.EnablePPTButtonLongPressPageTurn) return; _isLongPressNext = isNext; - _isLongPressActive = false; _longPressTimer?.Start(); } @@ -212,7 +207,6 @@ namespace Ink_Canvas private void StopLongPressDetection() { _longPressTimer?.Stop(); - _isLongPressActive = false; } /// @@ -222,7 +216,6 @@ namespace Ink_Canvas { if (!Settings.PowerPointSettings.EnablePPTButtonLongPressPageTurn) return; - _isLongPressActive = true; _longPressTimer.Interval = TimeSpan.FromMilliseconds(LongPressInterval); // 执行翻页 @@ -846,8 +839,6 @@ namespace Ink_Canvas { try { - _isPptClickingBtnTurned = true; - // 保存当前页墨迹 var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0; if (currentSlide > 0) @@ -889,8 +880,6 @@ namespace Ink_Canvas { try { - _isPptClickingBtnTurned = true; - // 保存当前页墨迹 var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0; if (currentSlide > 0) diff --git a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs index a36e7a47..42ae0582 100644 --- a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs +++ b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs @@ -340,7 +340,7 @@ namespace Ink_Canvas #endregion - private int lastTouchDownTime = 0, lastTouchUpTime = 0; + private Point iniP = new Point(0, 0); From 8d76c014c8b9a7777c23be94b518dce1ed52c596 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 09:09:22 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs | 2 +- Ink Canvas/MainWindow_cs/MW_Settings.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 2bc43aad..29e6fd09 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -2802,7 +2802,7 @@ namespace Ink_Canvas await Task.Delay(100); // Capture screenshot and insert to canvas - CaptureScreenshotAndInsert(); + await CaptureScreenshotAndInsert(); } private async void ImageOptionSelectFile_MouseUp(object sender, MouseButtonEventArgs e) diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index 723f056e..7ebcbfe3 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -2742,13 +2742,13 @@ namespace Ink_Canvas private void HyperlinkSourceToPresentRepository_Click(object sender, RoutedEventArgs e) { - Process.Start("https://bgithub.xyz/ChangSakura/Ink-Canvas"); + Process.Start("https://github.com/ChangSakura/Ink-Canvas"); HideSubPanels(); } private void HyperlinkSourceToOringinalRepository_Click(object sender, RoutedEventArgs e) { - Process.Start("https://bgithub.xyz/WXRIW/Ink-Canvas"); + Process.Start("https://github.com/WXRIW/Ink-Canvas"); HideSubPanels(); } From 658d48c17b7130c34ab9956b0829095555cccffd Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 09:12:30 +0800 Subject: [PATCH 07/14] =?UTF-8?q?improve:=E5=9B=BE=E7=89=87=E6=8F=92?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow.xaml.cs | 4 ++++ Ink Canvas/MainWindow_cs/MW_BoardControls.cs | 20 +++++++++++++++++++ .../MainWindow_cs/MW_ElementsControls.cs | 18 +++++++++++------ Ink Canvas/MainWindow_cs/MW_PageListView.cs | 8 ++++++++ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index af57d460..f87d40a8 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -1003,7 +1003,11 @@ namespace Ink_Canvas // 如果当前有选中的元素,取消选中状态 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } } diff --git a/Ink Canvas/MainWindow_cs/MW_BoardControls.cs b/Ink Canvas/MainWindow_cs/MW_BoardControls.cs index f3a90152..1e345f06 100644 --- a/Ink Canvas/MainWindow_cs/MW_BoardControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_BoardControls.cs @@ -133,7 +133,11 @@ namespace Ink_Canvas // 隐藏图片选择工具栏 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } @@ -219,7 +223,11 @@ namespace Ink_Canvas // 隐藏图片选择工具栏 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } @@ -249,7 +257,11 @@ namespace Ink_Canvas // 隐藏图片选择工具栏 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } @@ -272,7 +284,11 @@ namespace Ink_Canvas // 隐藏图片选择工具栏 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } @@ -307,7 +323,11 @@ namespace Ink_Canvas // 隐藏图片选择工具栏 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index cb991b8e..770cbd74 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -110,7 +110,11 @@ namespace Ink_Canvas // 取消之前选中的元素 if (currentSelectedElement != null && currentSelectedElement != element) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; } // 选中当前元素 @@ -323,11 +327,7 @@ namespace Ink_Canvas GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed; } - // 恢复InkCanvas的编辑模式 - if (inkCanvas != null) - { - inkCanvas.EditingMode = InkCanvasEditingMode.Ink; - } + } // 应用矩阵变换到元素 @@ -1179,6 +1179,9 @@ namespace Ink_Canvas { if (currentSelectedElement != null) { + // 保存删除前的编辑模式 + var previousEditingMode = inkCanvas.EditingMode; + // 记录删除历史 timeMachine.CommitElementRemoveHistory(currentSelectedElement); @@ -1189,7 +1192,10 @@ namespace Ink_Canvas UnselectElement(currentSelectedElement); currentSelectedElement = null; - LogHelper.WriteLogToFile($"图片删除完成"); + // 恢复到删除前的编辑模式 + inkCanvas.EditingMode = previousEditingMode; + + LogHelper.WriteLogToFile($"图片删除完成,已恢复到编辑模式: {previousEditingMode}"); } } catch (Exception ex) diff --git a/Ink Canvas/MainWindow_cs/MW_PageListView.cs b/Ink Canvas/MainWindow_cs/MW_PageListView.cs index 5b4daa7e..2a185925 100644 --- a/Ink Canvas/MainWindow_cs/MW_PageListView.cs +++ b/Ink Canvas/MainWindow_cs/MW_PageListView.cs @@ -89,7 +89,11 @@ namespace Ink_Canvas // 隐藏图片选择工具栏 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } @@ -118,7 +122,11 @@ namespace Ink_Canvas // 隐藏图片选择工具栏 if (currentSelectedElement != null) { + // 保存当前编辑模式 + var previousEditingMode = inkCanvas.EditingMode; UnselectElement(currentSelectedElement); + // 恢复编辑模式 + inkCanvas.EditingMode = previousEditingMode; currentSelectedElement = null; } From 3fcc01c2538439b6449e0a5ac79bf93135b85253 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 09:15:53 +0800 Subject: [PATCH 08/14] =?UTF-8?q?improve:=E5=9B=BE=E7=89=87=E6=8F=92?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainWindow_cs/MW_ElementsControls.cs | 114 +++++++++++++++--- 1 file changed, 95 insertions(+), 19 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index 770cbd74..0752af95 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -174,6 +174,12 @@ namespace Ink_Canvas // 使用滚轮缩放的核心机制 ApplyWheelScaleTransform(element, e); + // 如果是图片元素,更新工具栏位置 + if (element is Image && BorderImageSelectionControl?.Visibility == Visibility.Visible) + { + UpdateImageSelectionToolbarPosition(element); + } + e.Handled = true; } } @@ -998,19 +1004,12 @@ namespace Ink_Canvas { if (BorderImageSelectionControl == null || element == null) return; - // 获取元素在画布中的位置 - double elementLeft = InkCanvas.GetLeft(element); - double elementTop = InkCanvas.GetTop(element); - double elementWidth = element.ActualWidth; - double elementHeight = element.ActualHeight; - - // 如果元素位置未设置,使用默认值 - if (double.IsNaN(elementLeft)) elementLeft = 0; - if (double.IsNaN(elementTop)) elementTop = 0; + // 获取元素的实际边界(考虑变换) + Rect elementBounds = GetElementActualBounds(element); // 计算工具栏位置(显示在图片下方) - double toolbarLeft = elementLeft + (elementWidth / 2) - (BorderImageSelectionControl.ActualWidth / 2); - double toolbarTop = elementTop + elementHeight + 10; // 图片下方10像素 + double toolbarLeft = elementBounds.Left + (elementBounds.Width / 2) - (BorderImageSelectionControl.ActualWidth / 2); + double toolbarTop = elementBounds.Bottom + 10; // 图片下方10像素 // 确保工具栏不超出画布边界 double maxLeft = inkCanvas.ActualWidth - BorderImageSelectionControl.ActualWidth; @@ -1028,6 +1027,55 @@ namespace Ink_Canvas } } + // 获取元素的实际边界(考虑变换) + private Rect GetElementActualBounds(FrameworkElement element) + { + try + { + var left = InkCanvas.GetLeft(element); + var top = InkCanvas.GetTop(element); + + if (double.IsNaN(left)) left = 0; + if (double.IsNaN(top)) top = 0; + + var width = element.ActualWidth > 0 ? element.ActualWidth : element.Width; + var height = element.ActualHeight > 0 ? element.ActualHeight : element.Height; + + // 检查是否有RenderTransform + if (element.RenderTransform != null && element.RenderTransform != Transform.Identity) + { + try + { + // 如果有变换,使用变换后的边界 + var transform = element.TransformToAncestor(inkCanvas); + var elementBounds = new Rect(0, 0, width, height); + var transformedBounds = transform.TransformBounds(elementBounds); + return transformedBounds; + } + catch + { + // 变换失败时回退到简单计算 + return new Rect(left, top, width, height); + } + } + else + { + // 没有变换时直接使用位置和大小 + return new Rect(left, top, width, height); + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"获取元素实际边界失败: {ex.Message}", LogHelper.LogType.Error); + // 回退到基本计算 + var left = InkCanvas.GetLeft(element); + var top = InkCanvas.GetTop(element); + if (double.IsNaN(left)) left = 0; + if (double.IsNaN(top)) top = 0; + return new Rect(left, top, element.ActualWidth, element.ActualHeight); + } + } + #region Image Selection Toolbar Event Handlers // 图片克隆功能 @@ -1110,6 +1158,13 @@ namespace Ink_Canvas if (currentSelectedElement != null) { ApplyRotateTransform(currentSelectedElement, -45); + + // 更新工具栏位置 + if (currentSelectedElement is Image && BorderImageSelectionControl?.Visibility == Visibility.Visible) + { + UpdateImageSelectionToolbarPosition(currentSelectedElement); + } + LogHelper.WriteLogToFile($"图片左旋转完成"); } } @@ -1127,6 +1182,13 @@ namespace Ink_Canvas if (currentSelectedElement != null) { ApplyRotateTransform(currentSelectedElement, 45); + + // 更新工具栏位置 + if (currentSelectedElement is Image && BorderImageSelectionControl?.Visibility == Visibility.Visible) + { + UpdateImageSelectionToolbarPosition(currentSelectedElement); + } + LogHelper.WriteLogToFile($"图片右旋转完成"); } } @@ -1145,6 +1207,13 @@ namespace Ink_Canvas { var elementCenter = new Point(currentSelectedElement.ActualWidth / 2, currentSelectedElement.ActualHeight / 2); ApplyScaleTransform(currentSelectedElement, 0.9, elementCenter); + + // 更新工具栏位置 + if (currentSelectedElement is Image && BorderImageSelectionControl?.Visibility == Visibility.Visible) + { + UpdateImageSelectionToolbarPosition(currentSelectedElement); + } + LogHelper.WriteLogToFile($"图片缩放减小完成"); } } @@ -1160,17 +1229,24 @@ namespace Ink_Canvas try { if (currentSelectedElement != null) - { - var elementCenter = new Point(currentSelectedElement.ActualWidth / 2, currentSelectedElement.ActualHeight / 2); - ApplyScaleTransform(currentSelectedElement, 1.1, elementCenter); - LogHelper.WriteLogToFile($"图片缩放增大完成"); - } - } - catch (Exception ex) { - LogHelper.WriteLogToFile($"图片缩放增大失败: {ex.Message}", LogHelper.LogType.Error); + var elementCenter = new Point(currentSelectedElement.ActualWidth / 2, currentSelectedElement.ActualHeight / 2); + ApplyScaleTransform(currentSelectedElement, 1.1, elementCenter); + + // 更新工具栏位置 + if (currentSelectedElement is Image && BorderImageSelectionControl?.Visibility == Visibility.Visible) + { + UpdateImageSelectionToolbarPosition(currentSelectedElement); + } + + LogHelper.WriteLogToFile($"图片缩放增大完成"); } } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"图片缩放增大失败: {ex.Message}", LogHelper.LogType.Error); + } + } // 图片删除 private void BorderImageDelete_MouseUp(object sender, MouseButtonEventArgs e) From b8fe5bbd665945e8a1ab1c16d9b7be24e146fefe Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 09:18:30 +0800 Subject: [PATCH 09/14] =?UTF-8?q?improve:=E5=9B=BE=E7=89=87=E6=8F=92?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs | 4 ++-- Ink Canvas/MainWindow_cs/MW_ImageInsert.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs b/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs index fc8eb43e..f57d34a4 100644 --- a/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs +++ b/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs @@ -163,9 +163,9 @@ namespace Ink_Canvas { // 清除当前选择,避免显示控制点 inkCanvas.Select(new StrokeCollection()); - // 设置编辑模式为Ink模式,这样可以保持图片的交互功能 + // 设置编辑模式为非选择模式,这样可以保持图片的交互功能 // 同时通过图片的IsHitTestVisible和Focusable属性来避免InkCanvas选择系统的干扰 - inkCanvas.EditingMode = InkCanvasEditingMode.Ink; + inkCanvas.EditingMode = InkCanvasEditingMode.None; } // 添加到画布 diff --git a/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs b/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs index 2ebc2189..6f9ece0b 100644 --- a/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs +++ b/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs @@ -320,8 +320,12 @@ namespace Ink_Canvas InkCanvas.SetLeft(image, centerX); InkCanvas.SetTop(image, centerY); - // 清除任何现有的RenderTransform - image.RenderTransform = Transform.Identity; + // 这样可以保持滚轮缩放和拖动功能 + if (image.RenderTransform == null || image.RenderTransform == Transform.Identity) + { + // 只有在没有TransformGroup时才创建 + InitializeScreenshotTransform(image); + } LogHelper.WriteLogToFile($"截图居中完成: 位置({centerX}, {centerY}), 尺寸({newWidth}x{newHeight})"); } From 33948c604c97c9c2a3217558b2ea67e94fd2ca4e Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 09:20:35 +0800 Subject: [PATCH 10/14] =?UTF-8?q?improve:=E5=9B=BE=E7=89=87=E6=8F=92?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainWindow_cs/MW_ClipboardHandler.cs | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs b/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs index f57d34a4..369f5a02 100644 --- a/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs +++ b/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs @@ -141,19 +141,6 @@ namespace Ink_Canvas element.RenderTransform = transformGroup; } - // 设置位置 - if (position.HasValue) - { - // 在指定位置居中显示 - InkCanvas.SetLeft(image, position.Value.X - image.Width / 2); - InkCanvas.SetTop(image, position.Value.Y - image.Height / 2); - } - else - { - // 使用与文件选择相同的居中和缩放逻辑 - CenterAndScaleElement(image); - } - // 设置图片属性,避免被InkCanvas选择系统处理 image.IsHitTestVisible = true; image.Focusable = false; @@ -171,23 +158,42 @@ namespace Ink_Canvas // 添加到画布 inkCanvas.Children.Add(image); - // 绑定事件处理器 - if (image is FrameworkElement elementForEvents) + // 等待图片加载完成后再进行居中处理 + image.Loaded += (sender, e) => { - // 鼠标事件 - elementForEvents.MouseLeftButtonDown += Element_MouseLeftButtonDown; - elementForEvents.MouseLeftButtonUp += Element_MouseLeftButtonUp; - elementForEvents.MouseMove += Element_MouseMove; - elementForEvents.MouseWheel += Element_MouseWheel; + // 确保在UI线程中执行 + Dispatcher.BeginInvoke(new Action(() => + { + // 先进行缩放居中处理 + CenterAndScaleElement(image); + + // 如果有指定位置,调整到指定位置 + if (position.HasValue) + { + // 在指定位置居中显示 + InkCanvas.SetLeft(image, position.Value.X - image.Width / 2); + InkCanvas.SetTop(image, position.Value.Y - image.Height / 2); + } + + // 绑定事件处理器 + if (image is FrameworkElement elementForEvents) + { + // 鼠标事件 + elementForEvents.MouseLeftButtonDown += Element_MouseLeftButtonDown; + elementForEvents.MouseLeftButtonUp += Element_MouseLeftButtonUp; + elementForEvents.MouseMove += Element_MouseMove; + elementForEvents.MouseWheel += Element_MouseWheel; - // 触摸事件 - elementForEvents.IsManipulationEnabled = true; - elementForEvents.ManipulationDelta += Element_ManipulationDelta; - elementForEvents.ManipulationCompleted += Element_ManipulationCompleted; + // 触摸事件 + elementForEvents.IsManipulationEnabled = true; + elementForEvents.ManipulationDelta += Element_ManipulationDelta; + elementForEvents.ManipulationCompleted += Element_ManipulationCompleted; - // 设置光标 - elementForEvents.Cursor = Cursors.Hand; - } + // 设置光标 + elementForEvents.Cursor = Cursors.Hand; + } + }), System.Windows.Threading.DispatcherPriority.Loaded); + }; // 提交到历史记录 timeMachine.CommitElementInsertHistory(image); From 9bb00489feebe265185cc736a24ec24473165195 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 31 Aug 2025 09:54:13 +0800 Subject: [PATCH 11/14] =?UTF-8?q?improve:=E6=88=AA=E5=9B=BE=E5=8F=8A?= =?UTF-8?q?=E6=B5=AE=E5=8A=A8=E6=A0=8F=E5=8F=8A=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/App.xaml.cs | 22 +- Ink Canvas/Helpers/AdvancedBezierSmoothing.cs | 2 +- Ink Canvas/Helpers/AutoUpdateHelper.cs | 16 +- Ink Canvas/Helpers/DeviceIdentifier.cs | 2 +- Ink Canvas/Helpers/GlobalHotkeyManager.cs | 13 +- Ink Canvas/Helpers/InkFadeManager.cs | 8 +- Ink Canvas/Helpers/InkSmoothingConfig.cs | 5 +- Ink Canvas/Helpers/PPTInkManager.cs | 6 +- Ink Canvas/Helpers/PPTManager.cs | 16 +- .../BuiltIn/SuperLauncher/LauncherButton.cs | 2 +- .../BuiltIn/SuperLauncher/LauncherModels.cs | 4 +- .../LauncherSettingsControl.xaml.cs | 4 +- .../Plugins/BuiltIn/SuperLauncherPlugin.cs | 4 +- .../Plugins/PluginConfigurationManager.cs | 20 +- Ink Canvas/Helpers/Plugins/PluginManager.cs | 4 +- .../Helpers/Plugins/PluginServiceManager.cs | 2 +- Ink Canvas/Helpers/SoftwareLauncher.cs | 4 +- Ink Canvas/MainWindow.xaml.cs | 16 +- Ink Canvas/MainWindow_cs/MW_AutoFold.cs | 14 +- Ink Canvas/MainWindow_cs/MW_AutoStart.cs | 4 +- Ink Canvas/MainWindow_cs/MW_AutoTheme.cs | 6 +- Ink Canvas/MainWindow_cs/MW_BoardControls.cs | 4 +- Ink Canvas/MainWindow_cs/MW_BoardIcons.cs | 6 +- .../MainWindow_cs/MW_ClipboardHandler.cs | 29 +- Ink Canvas/MainWindow_cs/MW_Colors.cs | 4 +- .../MainWindow_cs/MW_ElementsControls.cs | 52 +- Ink Canvas/MainWindow_cs/MW_Eraser.cs | 4 +- .../MainWindow_cs/MW_FloatingBarIcons.cs | 57 +- Ink Canvas/MainWindow_cs/MW_ImageInsert.cs | 31 +- Ink Canvas/MainWindow_cs/MW_Notification.cs | 4 +- Ink Canvas/MainWindow_cs/MW_PPT.cs | 10 +- Ink Canvas/MainWindow_cs/MW_PageListView.cs | 4 +- .../MainWindow_cs/MW_Save&OpenStrokes.cs | 57 +- Ink Canvas/MainWindow_cs/MW_Screenshot.cs | 9 +- .../MainWindow_cs/MW_SelectionGestures.cs | 14 +- Ink Canvas/MainWindow_cs/MW_Settings.cs | 11 +- Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs | 10 +- Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs | 28 +- .../MW_SimulatePressure&InkToShape.cs | 4 +- Ink Canvas/MainWindow_cs/MW_TimeMachine.cs | 4 +- Ink Canvas/MainWindow_cs/MW_Timer.cs | 4 +- Ink Canvas/MainWindow_cs/MW_TouchEvents.cs | 9 +- Ink Canvas/MainWindow_cs/MW_TrayIcon.cs | 8 +- Ink Canvas/Resources/Settings.cs | 14 +- .../Windows/AddCustomIconWindow.xaml.cs | 2 +- .../AddPickNameBackgroundWindow.xaml.cs | 2 +- .../Windows/CountdownTimerWindow.xaml.cs | 7 +- Ink Canvas/Windows/HasNewUpdateWindow.xaml.cs | 8 +- .../Windows/HistoryRollbackWindow.xaml.cs | 3 +- Ink Canvas/Windows/HotkeyItem.xaml.cs | 9 +- .../Windows/HotkeySettingsWindow.xaml.cs | 18 +- Ink Canvas/Windows/NamesInputWindow.xaml.cs | 4 +- .../Windows/OperatingGuideWindow.xaml.cs | 5 +- .../Windows/PluginSettingsWindow.xaml.cs | 12 +- Ink Canvas/Windows/RandWindow.xaml.cs | 11 +- .../Windows/ScreenshotSelectorWindow.xaml | 162 ++++-- .../Windows/ScreenshotSelectorWindow.xaml.cs | 506 +++++++++++++++--- 57 files changed, 887 insertions(+), 413 deletions(-) diff --git a/Ink Canvas/App.xaml.cs b/Ink Canvas/App.xaml.cs index 8bcce6b3..b662a247 100644 --- a/Ink Canvas/App.xaml.cs +++ b/Ink Canvas/App.xaml.cs @@ -1,8 +1,3 @@ -using Hardcodet.Wpf.TaskbarNotification; -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern.Controls; -using Microsoft.Win32; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; @@ -18,6 +13,11 @@ using System.Windows; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Threading; +using Hardcodet.Wpf.TaskbarNotification; +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern.Controls; +using Microsoft.Win32; +using Newtonsoft.Json; using Application = System.Windows.Application; using MessageBox = System.Windows.MessageBox; using Timer = System.Threading.Timer; @@ -353,18 +353,18 @@ namespace Ink_Canvas { return $"{timeSpan.Days}天 {timeSpan.Hours}小时 {timeSpan.Minutes}分钟"; } - else if (timeSpan.TotalHours >= 1) + + if (timeSpan.TotalHours >= 1) { return $"{timeSpan.Hours}小时 {timeSpan.Minutes}分钟"; } - else if (timeSpan.TotalMinutes >= 1) + + if (timeSpan.TotalMinutes >= 1) { return $"{timeSpan.Minutes}分钟 {timeSpan.Seconds}秒"; } - else - { - return $"{timeSpan.Seconds}秒"; - } + + return $"{timeSpan.Seconds}秒"; } // 新增:记录崩溃日志 diff --git a/Ink Canvas/Helpers/AdvancedBezierSmoothing.cs b/Ink Canvas/Helpers/AdvancedBezierSmoothing.cs index ab7aa9fd..0948fa44 100644 --- a/Ink Canvas/Helpers/AdvancedBezierSmoothing.cs +++ b/Ink Canvas/Helpers/AdvancedBezierSmoothing.cs @@ -4,10 +4,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using System.Windows; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Threading; -using System.Windows; namespace Ink_Canvas.Helpers { diff --git a/Ink Canvas/Helpers/AutoUpdateHelper.cs b/Ink Canvas/Helpers/AutoUpdateHelper.cs index fe21d61c..397a381b 100644 --- a/Ink Canvas/Helpers/AutoUpdateHelper.cs +++ b/Ink Canvas/Helpers/AutoUpdateHelper.cs @@ -1,5 +1,3 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -17,6 +15,8 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Ink_Canvas.Helpers { @@ -1361,16 +1361,14 @@ namespace Ink_Canvas.Helpers if (oldProcessId > 0 && !string.IsNullOrEmpty(extractPath) && !string.IsNullOrEmpty(targetPath)) { - LogHelper.WriteLogToFile($"AutoUpdate | 参数验证通过,启动更新任务"); + LogHelper.WriteLogToFile("AutoUpdate | 参数验证通过,启动更新任务"); // 启动更新任务 Task.Run(async () => await PerformUpdate(oldProcessId, extractPath, targetPath, isSilence)); return true; // 返回true表示是更新模式 } - else - { - LogHelper.WriteLogToFile($"AutoUpdate | 参数验证失败 - 老进程ID: {oldProcessId}, 解压路径: {extractPath}, 目标路径: {targetPath}", LogHelper.LogType.Error); - return false; - } + + LogHelper.WriteLogToFile($"AutoUpdate | 参数验证失败 - 老进程ID: {oldProcessId}, 解压路径: {extractPath}, 目标路径: {targetPath}", LogHelper.LogType.Error); + return false; } return false; // 返回false表示不是更新模式 } @@ -1483,7 +1481,7 @@ namespace Ink_Canvas.Helpers } // 删除ZIP文件 - string zipFile = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.*.zip"); + string zipFile = Path.Combine(updatesFolderPath, "InkCanvasForClass.CE.*.zip"); string[] zipFiles = Directory.GetFiles(updatesFolderPath, "InkCanvasForClass.CE.*.zip"); foreach (string zip in zipFiles) { diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs index e34c4e4c..f67b5387 100644 --- a/Ink Canvas/Helpers/DeviceIdentifier.cs +++ b/Ink Canvas/Helpers/DeviceIdentifier.cs @@ -1,4 +1,3 @@ -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; @@ -6,6 +5,7 @@ using System.Linq; using System.Reflection; using System.Security.Cryptography; using System.Text; +using Newtonsoft.Json; namespace Ink_Canvas.Helpers { diff --git a/Ink Canvas/Helpers/GlobalHotkeyManager.cs b/Ink Canvas/Helpers/GlobalHotkeyManager.cs index c7f43345..b1f1eefe 100644 --- a/Ink Canvas/Helpers/GlobalHotkeyManager.cs +++ b/Ink Canvas/Helpers/GlobalHotkeyManager.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; -using System.Windows.Input; using System.IO; using System.Reflection; +using System.Text; +using System.Windows.Input; using Newtonsoft.Json; using NHotkey.Wpf; @@ -16,7 +17,7 @@ namespace Ink_Canvas.Helpers #region Private Fields private readonly Dictionary _registeredHotkeys; private readonly MainWindow _mainWindow; - private bool _isDisposed = false; + private bool _isDisposed; private bool _hotkeysShouldBeRegistered = true; // 启动时注册热键 // 配置文件路径 @@ -180,7 +181,7 @@ namespace Ink_Canvas.Helpers } // 读取配置文件内容 - string jsonContent = File.ReadAllText(HotkeyConfigFile, System.Text.Encoding.UTF8); + string jsonContent = File.ReadAllText(HotkeyConfigFile, Encoding.UTF8); if (string.IsNullOrEmpty(jsonContent)) { LogHelper.WriteLogToFile("快捷键配置文件为空", LogHelper.LogType.Warning); @@ -509,7 +510,7 @@ namespace Ink_Canvas.Helpers } // 读取配置文件内容 - string jsonContent = File.ReadAllText(HotkeyConfigFile, System.Text.Encoding.UTF8); + string jsonContent = File.ReadAllText(HotkeyConfigFile, Encoding.UTF8); if (string.IsNullOrEmpty(jsonContent)) { LogHelper.WriteLogToFile("快捷键配置文件为空", LogHelper.LogType.Warning); @@ -607,7 +608,7 @@ namespace Ink_Canvas.Helpers string jsonContent = JsonConvert.SerializeObject(config, settings); // 直接写入原文件,覆盖原有内容 - File.WriteAllText(HotkeyConfigFile, jsonContent, System.Text.Encoding.UTF8); + File.WriteAllText(HotkeyConfigFile, jsonContent, Encoding.UTF8); LogHelper.WriteLogToFile($"快捷键配置已保存到: {HotkeyConfigFile}", LogHelper.LogType.Event); return true; @@ -714,7 +715,7 @@ namespace Ink_Canvas.Helpers var getLeftMethod = canvasType.GetMethod("GetLeft", BindingFlags.Public | BindingFlags.Static); if (getLeftMethod != null) { - var leftPosition = getLeftMethod.Invoke(null, new object[] { floatingbarSelectionBG }); + var leftPosition = getLeftMethod.Invoke(null, new[] { floatingbarSelectionBG }); if (leftPosition != null) { var position = Convert.ToDouble(leftPosition); diff --git a/Ink Canvas/Helpers/InkFadeManager.cs b/Ink Canvas/Helpers/InkFadeManager.cs index b28b9eb4..6f8188f8 100644 --- a/Ink Canvas/Helpers/InkFadeManager.cs +++ b/Ink Canvas/Helpers/InkFadeManager.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; using System.Windows; -using System.Windows.Media.Animation; -using System.Windows.Threading; -using System.Windows.Ink; using System.Windows.Controls; +using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Shapes; +using System.Windows.Threading; namespace Ink_Canvas.Helpers { @@ -20,7 +20,7 @@ namespace Ink_Canvas.Helpers /// /// 是否启用墨迹渐隐功能 /// - public bool IsEnabled { get; set; } = false; + public bool IsEnabled { get; set; } /// /// 墨迹渐隐时间(毫秒) diff --git a/Ink Canvas/Helpers/InkSmoothingConfig.cs b/Ink Canvas/Helpers/InkSmoothingConfig.cs index af8420f8..83533f0e 100644 --- a/Ink Canvas/Helpers/InkSmoothingConfig.cs +++ b/Ink Canvas/Helpers/InkSmoothingConfig.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; namespace Ink_Canvas.Helpers { @@ -63,7 +64,7 @@ namespace Ink_Canvas.Helpers } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"加载平滑配置失败: {ex.Message}"); + Debug.WriteLine($"加载平滑配置失败: {ex.Message}"); } return config; @@ -124,7 +125,7 @@ namespace Ink_Canvas.Helpers } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"保存平滑配置失败: {ex.Message}"); + Debug.WriteLine($"保存平滑配置失败: {ex.Message}"); } } diff --git a/Ink Canvas/Helpers/PPTInkManager.cs b/Ink Canvas/Helpers/PPTInkManager.cs index f8c62ccb..fd43b18f 100644 --- a/Ink Canvas/Helpers/PPTInkManager.cs +++ b/Ink Canvas/Helpers/PPTInkManager.cs @@ -1,9 +1,9 @@ -using Microsoft.Office.Interop.PowerPoint; -using System; +using System; using System.IO; using System.Security.Cryptography; using System.Text; using System.Windows.Ink; +using Microsoft.Office.Interop.PowerPoint; namespace Ink_Canvas.Helpers { @@ -23,7 +23,7 @@ namespace Ink_Canvas.Helpers private int _maxSlides = 100; private string _currentPresentationId = ""; private readonly object _lockObject = new object(); - private bool _disposed = false; + private bool _disposed; // 墨迹锁定机制,防止翻页时的墨迹冲突 private DateTime _inkLockUntil = DateTime.MinValue; diff --git a/Ink Canvas/Helpers/PPTManager.cs b/Ink Canvas/Helpers/PPTManager.cs index 76c3f4e9..fb57c16f 100644 --- a/Ink Canvas/Helpers/PPTManager.cs +++ b/Ink Canvas/Helpers/PPTManager.cs @@ -1,5 +1,4 @@ -using Microsoft.Office.Interop.PowerPoint; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -8,6 +7,7 @@ using System.Text; using System.Threading; using System.Timers; using System.Windows.Threading; +using Microsoft.Office.Interop.PowerPoint; using Application = System.Windows.Application; using Timer = System.Timers.Timer; @@ -101,9 +101,9 @@ namespace Ink_Canvas.Helpers private int _wpsProcessCheckCount; private WpsWindowInfo _lastForegroundWpsWindow; private DateTime _lastWindowCheckTime = DateTime.MinValue; - private bool _lastSlideShowState = false; + private bool _lastSlideShowState; private readonly object _lockObject = new object(); - private bool _disposed = false; + private bool _disposed; #endregion #region Constructor & Initialization @@ -888,11 +888,9 @@ namespace Ink_Canvas.Helpers LogHelper.WriteLogToFile("成功显示幻灯片导航(PowerPoint模式)", LogHelper.LogType.Event); return true; } - else - { - LogHelper.WriteLogToFile("SlideNavigation对象为空,可能是WPS不支持此功能", LogHelper.LogType.Warning); - return false; - } + + LogHelper.WriteLogToFile("SlideNavigation对象为空,可能是WPS不支持此功能", LogHelper.LogType.Warning); + return false; } catch (COMException comEx) { diff --git a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherButton.cs b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherButton.cs index 54eb84bd..1e91a7de 100644 --- a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherButton.cs +++ b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherButton.cs @@ -1,9 +1,9 @@ -using iNKORE.UI.WPF.Modern.Controls; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using iNKORE.UI.WPF.Modern.Controls; namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher { diff --git a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs index 9b6ac63b..2089ca6c 100644 --- a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs +++ b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherModels.cs @@ -1,5 +1,3 @@ -using Microsoft.Win32; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; @@ -10,6 +8,8 @@ using System.Windows; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using Microsoft.Win32; +using Newtonsoft.Json; namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher { diff --git a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherSettingsControl.xaml.cs b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherSettingsControl.xaml.cs index 6666f10d..4b6cda6c 100644 --- a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherSettingsControl.xaml.cs +++ b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncher/LauncherSettingsControl.xaml.cs @@ -1,10 +1,10 @@ -using Ink_Canvas.Windows; -using Microsoft.Win32; using System; using System.ComponentModel; using System.IO; using System.Windows; using System.Windows.Controls; +using Ink_Canvas.Windows; +using Microsoft.Win32; namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher { diff --git a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs index 555c7bf9..2c504bd0 100644 --- a/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs +++ b/Ink Canvas/Helpers/Plugins/BuiltIn/SuperLauncherPlugin.cs @@ -1,5 +1,3 @@ -using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -7,6 +5,8 @@ using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Media; +using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher; +using Newtonsoft.Json; namespace Ink_Canvas.Helpers.Plugins.BuiltIn { diff --git a/Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs b/Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs index dfa342b2..be1efddc 100644 --- a/Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs +++ b/Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs @@ -1,8 +1,8 @@ -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; +using Newtonsoft.Json; namespace Ink_Canvas.Helpers.Plugins { @@ -46,17 +46,15 @@ namespace Ink_Canvas.Helpers.Plugins { return typedValue; } - else + + // 尝试类型转换 + try { - // 尝试类型转换 - try - { - return (T)Convert.ChangeType(value, typeof(T)); - } - catch - { - return defaultValue; - } + return (T)Convert.ChangeType(value, typeof(T)); + } + catch + { + return defaultValue; } } } diff --git a/Ink Canvas/Helpers/Plugins/PluginManager.cs b/Ink Canvas/Helpers/Plugins/PluginManager.cs index 27b7742e..d1a6559f 100644 --- a/Ink Canvas/Helpers/Plugins/PluginManager.cs +++ b/Ink Canvas/Helpers/Plugins/PluginManager.cs @@ -1,5 +1,3 @@ -using Ink_Canvas.Windows; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -10,6 +8,8 @@ using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; using System.Windows; +using Ink_Canvas.Windows; +using Newtonsoft.Json; using Timer = System.Timers.Timer; namespace Ink_Canvas.Helpers.Plugins diff --git a/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs b/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs index e3e2d3e5..fd1b1bf7 100644 --- a/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs +++ b/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using System.Linq; namespace Ink_Canvas.Helpers.Plugins { diff --git a/Ink Canvas/Helpers/SoftwareLauncher.cs b/Ink Canvas/Helpers/SoftwareLauncher.cs index e3dc7188..5f2e405d 100644 --- a/Ink Canvas/Helpers/SoftwareLauncher.cs +++ b/Ink Canvas/Helpers/SoftwareLauncher.cs @@ -1,8 +1,8 @@ -using Microsoft.Win32; -using System; +using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +using Microsoft.Win32; namespace Ink_Canvas.Helpers { diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index f87d40a8..8a2a414d 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -1,9 +1,3 @@ -using Ink_Canvas.Helpers; -using Ink_Canvas.Helpers.Plugins; -using Ink_Canvas.Windows; -using iNKORE.UI.WPF.Modern; -using iNKORE.UI.WPF.Modern.Controls; -using Microsoft.Win32; using System; using System.Collections.Generic; using System.ComponentModel; @@ -22,6 +16,12 @@ using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Threading; +using Ink_Canvas.Helpers; +using Ink_Canvas.Helpers.Plugins; +using Ink_Canvas.Windows; +using iNKORE.UI.WPF.Modern; +using iNKORE.UI.WPF.Modern.Controls; +using Microsoft.Win32; using Application = System.Windows.Application; using Brushes = System.Windows.Media.Brushes; using Button = System.Windows.Controls.Button; @@ -1689,7 +1689,7 @@ namespace Ink_Canvas // 添加定时器来维护置顶状态 private DispatcherTimer topmostMaintenanceTimer; - private bool isTopmostMaintenanceEnabled = false; + private bool isTopmostMaintenanceEnabled; private void ApplyNoFocusMode() { @@ -1753,7 +1753,7 @@ namespace Ink_Canvas // 注意:这里不直接设置Topmost,让其他代码根据模式决定 // 添加调试日志 - LogHelper.WriteLogToFile($"应用窗口置顶: 取消置顶", LogHelper.LogType.Trace); + LogHelper.WriteLogToFile("应用窗口置顶: 取消置顶", LogHelper.LogType.Trace); } } catch (Exception ex) diff --git a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs index 109cd178..98f6b9b0 100644 --- a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs +++ b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs @@ -1,6 +1,4 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern; -using System; +using System; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -8,6 +6,8 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern; namespace Ink_Canvas { @@ -263,10 +263,10 @@ namespace Ink_Canvas { var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString(); var dopsc = dops.ToCharArray(); - if (dopsc[0] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(LeftBottomPanelForPPTNavigation); - if (dopsc[1] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation); - if (dopsc[2] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation); - if (dopsc[3] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation); + if (dopsc[0] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftBottomPanelForPPTNavigation); + if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation); + if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation); + if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation); } if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) diff --git a/Ink Canvas/MainWindow_cs/MW_AutoStart.cs b/Ink Canvas/MainWindow_cs/MW_AutoStart.cs index a86808cc..e38c74d1 100644 --- a/Ink Canvas/MainWindow_cs/MW_AutoStart.cs +++ b/Ink Canvas/MainWindow_cs/MW_AutoStart.cs @@ -1,6 +1,6 @@ -using IWshRuntimeLibrary; -using System; +using System; using System.Windows; +using IWshRuntimeLibrary; using Application = System.Windows.Forms.Application; using File = System.IO.File; diff --git a/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs b/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs index f908c2ad..e41f79fb 100644 --- a/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs +++ b/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs @@ -1,8 +1,8 @@ -using iNKORE.UI.WPF.Modern; -using Microsoft.Win32; -using System; +using System; using System.Windows; using System.Windows.Media; +using iNKORE.UI.WPF.Modern; +using Microsoft.Win32; using Application = System.Windows.Application; namespace Ink_Canvas diff --git a/Ink Canvas/MainWindow_cs/MW_BoardControls.cs b/Ink Canvas/MainWindow_cs/MW_BoardControls.cs index 1e345f06..6c1510e3 100644 --- a/Ink Canvas/MainWindow_cs/MW_BoardControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_BoardControls.cs @@ -1,5 +1,4 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; @@ -7,6 +6,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Media; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/MainWindow_cs/MW_BoardIcons.cs b/Ink Canvas/MainWindow_cs/MW_BoardIcons.cs index f94917af..6f956a9f 100644 --- a/Ink Canvas/MainWindow_cs/MW_BoardIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_BoardIcons.cs @@ -1,5 +1,4 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Diagnostics; using System.Windows; using System.Windows.Controls; @@ -7,6 +6,7 @@ using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using Ink_Canvas.Helpers; namespace Ink_Canvas { @@ -766,7 +766,7 @@ namespace Ink_Canvas { PenIcon_Click(null, null); SymbolIconDelete_MouseUp(null, null); - if (Settings.Canvas.ClearCanvasAndClearTimeMachine == false) timeMachine.ClearStrokeHistory(); + if (!Settings.Canvas.ClearCanvasAndClearTimeMachine) timeMachine.ClearStrokeHistory(); // 根据设置决定是否清空图片 if (Settings.Canvas.ClearCanvasAlsoClearImages) diff --git a/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs b/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs index 369f5a02..99053852 100644 --- a/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs +++ b/Ink Canvas/MainWindow_cs/MW_ClipboardHandler.cs @@ -1,19 +1,26 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Forms; using System.Windows.Ink; using System.Windows.Input; +using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Media; +using System.Windows.Threading; +using Ink_Canvas.Helpers; +using Clipboard = System.Windows.Clipboard; +using ContextMenu = System.Windows.Controls.ContextMenu; +using Cursors = System.Windows.Input.Cursors; +using MenuItem = System.Windows.Controls.MenuItem; namespace Ink_Canvas { public partial class MainWindow : Window { - private bool isClipboardMonitoringEnabled = false; - private BitmapSource lastClipboardImage = null; + private bool isClipboardMonitoringEnabled; + private BitmapSource lastClipboardImage; // 初始化剪贴板监控 private void InitializeClipboardMonitoring() @@ -92,7 +99,7 @@ namespace Ink_Canvas // 显示菜单 contextMenu.IsOpen = true; contextMenu.PlacementTarget = inkCanvas; - contextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint; + contextMenu.Placement = PlacementMode.MousePoint; } catch (Exception ex) { @@ -124,7 +131,7 @@ namespace Ink_Canvas Source = clipboardImage, Width = clipboardImage.PixelWidth, Height = clipboardImage.PixelHeight, - Stretch = System.Windows.Media.Stretch.Fill + Stretch = Stretch.Fill }; // 生成唯一名称 @@ -192,7 +199,7 @@ namespace Ink_Canvas // 设置光标 elementForEvents.Cursor = Cursors.Hand; } - }), System.Windows.Threading.DispatcherPriority.Loaded); + }), DispatcherPriority.Loaded); }; // 提交到历史记录 @@ -272,13 +279,13 @@ namespace Ink_Canvas { public static event Action ClipboardUpdate; - private static System.Windows.Forms.Timer clipboardTimer; + private static Timer clipboardTimer; private static string lastClipboardText = ""; - private static bool lastHadImage = false; + private static bool lastHadImage; static ClipboardNotification() { - clipboardTimer = new System.Windows.Forms.Timer(); + clipboardTimer = new Timer(); clipboardTimer.Interval = 500; // 每500ms检查一次 clipboardTimer.Tick += CheckClipboard; clipboardTimer.Start(); diff --git a/Ink Canvas/MainWindow_cs/MW_Colors.cs b/Ink Canvas/MainWindow_cs/MW_Colors.cs index 57ce6f80..c55e306c 100644 --- a/Ink Canvas/MainWindow_cs/MW_Colors.cs +++ b/Ink Canvas/MainWindow_cs/MW_Colors.cs @@ -1,5 +1,4 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows; @@ -9,6 +8,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index 0752af95..378dc86f 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -1,15 +1,17 @@ -using Microsoft.Win32; -using System; +using System; +using System.Diagnostics; using System.IO; +using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Ink; +using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Threading; using Ink_Canvas.Helpers; -using System.Windows.Input; -using System.Linq; -using System.Windows.Ink; +using Microsoft.Win32; namespace Ink_Canvas { @@ -17,7 +19,7 @@ namespace Ink_Canvas { // 当前选中的可操作元素 private FrameworkElement currentSelectedElement; - private bool isDragging = false; + private bool isDragging; private Point dragStartPoint; #region Image @@ -62,7 +64,7 @@ namespace Ink_Canvas BindElementEvents(image); LogHelper.WriteLogToFile($"图片插入完成: {image.Name}"); - }), System.Windows.Threading.DispatcherPriority.Loaded); + }), DispatcherPriority.Loaded); }; timeMachine.CommitElementInsertHistory(image); @@ -396,7 +398,7 @@ namespace Ink_Canvas } // 保存初始变换状态用于历史记录 - var initialTransform = transformGroup.Clone() as TransformGroup; + var initialTransform = transformGroup.Clone(); // 创建新的 TransformGroup 并添加 MatrixTransform var newTransformGroup = new TransformGroup(); @@ -719,7 +721,7 @@ namespace Ink_Canvas catch (Exception ex) { // 记录错误但不中断程序 - System.Diagnostics.Debug.WriteLine($"旋转图片时发生错误: {ex.Message}"); + Debug.WriteLine($"旋转图片时发生错误: {ex.Message}"); } } @@ -740,7 +742,7 @@ namespace Ink_Canvas Width = image.Width, Height = image.Height, Stretch = image.Stretch, - RenderTransform = image.RenderTransform?.Clone() as Transform + RenderTransform = image.RenderTransform?.Clone() }; // 设置位置,稍微偏移以避免重叠 @@ -790,7 +792,7 @@ namespace Ink_Canvas Width = image.Width, Height = image.Height, Stretch = image.Stretch, - RenderTransform = image.RenderTransform?.Clone() as Transform + RenderTransform = image.RenderTransform?.Clone() }; // 设置位置,稍微偏移以避免重叠 @@ -809,7 +811,7 @@ namespace Ink_Canvas catch (Exception ex) { // 记录错误但不中断程序 - System.Diagnostics.Debug.WriteLine($"克隆图片到新页面时发生错误: {ex.Message}"); + Debug.WriteLine($"克隆图片到新页面时发生错误: {ex.Message}"); } } @@ -862,7 +864,7 @@ namespace Ink_Canvas catch (Exception ex) { // 记录错误但不中断程序 - System.Diagnostics.Debug.WriteLine($"缩放图片时发生错误: {ex.Message}"); + Debug.WriteLine($"缩放图片时发生错误: {ex.Message}"); } } @@ -888,7 +890,7 @@ namespace Ink_Canvas catch (Exception ex) { // 记录错误但不中断程序 - System.Diagnostics.Debug.WriteLine($"删除图片时发生错误: {ex.Message}"); + Debug.WriteLine($"删除图片时发生错误: {ex.Message}"); } } @@ -907,7 +909,7 @@ namespace Ink_Canvas Dispatcher.BeginInvoke(new Action(() => { CenterAndScaleElement(element); - }), System.Windows.Threading.DispatcherPriority.Loaded); + }), DispatcherPriority.Loaded); }; return; } @@ -919,8 +921,8 @@ namespace Ink_Canvas // 如果画布尺寸为0,使用窗口尺寸作为备选 if (canvasWidth <= 0 || canvasHeight <= 0) { - canvasWidth = this.ActualWidth; - canvasHeight = this.ActualHeight; + canvasWidth = ActualWidth; + canvasHeight = ActualHeight; } // 如果仍然为0,使用屏幕尺寸 @@ -1058,11 +1060,9 @@ namespace Ink_Canvas return new Rect(left, top, width, height); } } - else - { - // 没有变换时直接使用位置和大小 - return new Rect(left, top, width, height); - } + + // 没有变换时直接使用位置和大小 + return new Rect(left, top, width, height); } catch (Exception ex) { @@ -1165,7 +1165,7 @@ namespace Ink_Canvas UpdateImageSelectionToolbarPosition(currentSelectedElement); } - LogHelper.WriteLogToFile($"图片左旋转完成"); + LogHelper.WriteLogToFile("图片左旋转完成"); } } catch (Exception ex) @@ -1189,7 +1189,7 @@ namespace Ink_Canvas UpdateImageSelectionToolbarPosition(currentSelectedElement); } - LogHelper.WriteLogToFile($"图片右旋转完成"); + LogHelper.WriteLogToFile("图片右旋转完成"); } } catch (Exception ex) @@ -1214,7 +1214,7 @@ namespace Ink_Canvas UpdateImageSelectionToolbarPosition(currentSelectedElement); } - LogHelper.WriteLogToFile($"图片缩放减小完成"); + LogHelper.WriteLogToFile("图片缩放减小完成"); } } catch (Exception ex) @@ -1239,7 +1239,7 @@ namespace Ink_Canvas UpdateImageSelectionToolbarPosition(currentSelectedElement); } - LogHelper.WriteLogToFile($"图片缩放增大完成"); + LogHelper.WriteLogToFile("图片缩放增大完成"); } } catch (Exception ex) diff --git a/Ink Canvas/MainWindow_cs/MW_Eraser.cs b/Ink Canvas/MainWindow_cs/MW_Eraser.cs index d49cfe1a..4295d9ce 100644 --- a/Ink Canvas/MainWindow_cs/MW_Eraser.cs +++ b/Ink Canvas/MainWindow_cs/MW_Eraser.cs @@ -1,5 +1,4 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Diagnostics; using System.Linq; using System.Windows; @@ -7,6 +6,7 @@ using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 29e6fd09..6d8e3dfe 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -1,5 +1,3 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern; using System; using System.Diagnostics; using System.Threading; @@ -13,6 +11,8 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern; using Application = System.Windows.Application; using Button = System.Windows.Controls.Button; using Cursors = System.Windows.Input.Cursors; @@ -641,6 +641,9 @@ namespace Ink_Canvas ICCWaterMarkWhite.Visibility = Visibility.Visible; ICCWaterMarkDark.Visibility = Visibility.Collapsed; } + + // 新增:确保在白板模式下基础浮动栏被隐藏 + ViewboxFloatingBar.Visibility = Visibility.Collapsed; } else { @@ -651,10 +654,10 @@ namespace Ink_Canvas { var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString(); var dopsc = dops.ToCharArray(); - if (dopsc[0] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(LeftBottomPanelForPPTNavigation); - if (dopsc[1] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation); - if (dopsc[2] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation); - if (dopsc[3] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation); + if (dopsc[0] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftBottomPanelForPPTNavigation); + if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation); + if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation); + if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation); } // 修复PPT放映时点击白板按钮后翻页按钮不显示的问题 if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) @@ -693,6 +696,9 @@ namespace Ink_Canvas BlackBoardWaterMark.Visibility = Visibility.Collapsed; ICCWaterMarkDark.Visibility = Visibility.Collapsed; ICCWaterMarkWhite.Visibility = Visibility.Collapsed; + + // 新增:退出白板模式时恢复基础浮动栏的显示 + ViewboxFloatingBar.Visibility = Visibility.Visible; } BtnSwitch_Click(BtnSwitch, null); @@ -1295,7 +1301,7 @@ namespace Ink_Canvas if (MarginFromEdge == 60) MarginFromEdge = 55; await Dispatcher.InvokeAsync(() => { - if (Topmost == false) + if (!Topmost) MarginFromEdge = -60; else ViewboxFloatingBar.Visibility = Visibility.Visible; @@ -1337,7 +1343,7 @@ namespace Ink_Canvas pos.X = (screenWidth - floatingBarWidth) / 2; - if (PosXCaculatedWithTaskbarHeight == false) + if (!PosXCaculatedWithTaskbarHeight) { // 如果任务栏高度为0(隐藏状态),则使用固定边距 if (toolbarHeight == 0) @@ -1405,7 +1411,7 @@ namespace Ink_Canvas await Dispatcher.InvokeAsync(() => { ViewboxFloatingBar.Margin = new Thickness(pos.X, pos.Y, -2000, -200); - if (Topmost == false) ViewboxFloatingBar.Visibility = Visibility.Hidden; + if (!Topmost) ViewboxFloatingBar.Visibility = Visibility.Hidden; }); } @@ -2560,6 +2566,9 @@ namespace Ink_Canvas ClearStrokes(true); RestoreStrokes(true); + // 新增:在屏幕模式下恢复基础浮动栏的显示 + ViewboxFloatingBar.Visibility = Visibility.Visible; + if (BtnSwitchTheme.Content.ToString() == "浅色") { BtnSwitch.Content = "黑板"; @@ -2598,6 +2607,9 @@ namespace Ink_Canvas // PPT墨迹和白板墨迹应该分别管理,不应该互相影响 RestoreStrokes(); + // 新增:在白板模式下隐藏基础浮动栏 + ViewboxFloatingBar.Visibility = Visibility.Collapsed; + BtnSwitch.Content = "屏幕"; if (BtnSwitchTheme.Content.ToString() == "浅色") { @@ -2737,11 +2749,23 @@ namespace Ink_Canvas StackPanelCanvasControls.Visibility = Visibility.Collapsed; CheckEnableTwoFingerGestureBtnVisibility(false); HideSubPanels("cursor"); + + // 新增:在屏幕模式下显示基础浮动栏 + if (currentMode == 0) + { + ViewboxFloatingBar.Visibility = Visibility.Visible; + } } else { AnimationsHelper.ShowWithSlideFromLeftAndFade(StackPanelCanvasControls); CheckEnableTwoFingerGestureBtnVisibility(true); + + // 新增:在批注模式下显示基础浮动栏 + if (currentMode == 0) + { + ViewboxFloatingBar.Visibility = Visibility.Visible; + } } } @@ -3224,26 +3248,27 @@ namespace Ink_Canvas { return "select"; } - else if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink) + + if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink) { // 检查是否是荧光笔模式 if (drawingAttributes != null && drawingAttributes.IsHighlighter) { return "color"; } - else - { - return "pen"; - } + + return "pen"; } - else if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) + + if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) { // 检查是面积擦还是线擦 if (Eraser_Icon != null && Eraser_Icon.Visibility == Visibility.Visible) { return "eraser"; } - else if (EraserByStrokes_Icon != null && EraserByStrokes_Icon.Visibility == Visibility.Visible) + + if (EraserByStrokes_Icon != null && EraserByStrokes_Icon.Visibility == Visibility.Visible) { return "eraserByStrokes"; } diff --git a/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs b/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs index 6f9ece0b..9b1a6592 100644 --- a/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs +++ b/Ink Canvas/MainWindow_cs/MW_ImageInsert.cs @@ -1,4 +1,3 @@ -using Ink_Canvas.Helpers; using System; using System.Collections.Generic; using System.Drawing; @@ -11,8 +10,14 @@ using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Threading; +using Ink_Canvas.Helpers; using Application = System.Windows.Application; +using Color = System.Drawing.Color; +using Cursors = System.Windows.Input.Cursors; +using Image = System.Windows.Controls.Image; using PixelFormat = System.Drawing.Imaging.PixelFormat; +using Point = System.Windows.Point; using Size = System.Drawing.Size; namespace Ink_Canvas @@ -21,9 +26,9 @@ namespace Ink_Canvas public struct ScreenshotResult { public Rectangle Area; - public List Path; + public List Path; - public ScreenshotResult(Rectangle area, List path = null) + public ScreenshotResult(Rectangle area, List path = null) { Area = area; Path = path; @@ -172,7 +177,7 @@ namespace Ink_Canvas var bitmapSource = ConvertBitmapToBitmapSource(bitmap); // 创建WPF Image控件 - var image = new System.Windows.Controls.Image + var image = new Image { Source = bitmapSource, Stretch = Stretch.Uniform @@ -202,7 +207,7 @@ namespace Ink_Canvas CenterAndScaleScreenshot(image); // 绑定事件处理器 BindScreenshotEvents(image); - }), System.Windows.Threading.DispatcherPriority.Loaded); + }), DispatcherPriority.Loaded); }; // 添加到画布 @@ -221,7 +226,7 @@ namespace Ink_Canvas } // 初始化截图的TransformGroup - private void InitializeScreenshotTransform(System.Windows.Controls.Image image) + private void InitializeScreenshotTransform(Image image) { var transformGroup = new TransformGroup(); transformGroup.Children.Add(new ScaleTransform(1, 1)); @@ -231,7 +236,7 @@ namespace Ink_Canvas } // 绑定截图事件处理器 - private void BindScreenshotEvents(System.Windows.Controls.Image image) + private void BindScreenshotEvents(Image image) { // 鼠标事件 image.MouseLeftButtonDown += Element_MouseLeftButtonDown; @@ -245,7 +250,7 @@ namespace Ink_Canvas image.ManipulationCompleted += Element_ManipulationCompleted; // 设置光标 - image.Cursor = System.Windows.Input.Cursors.Hand; + image.Cursor = Cursors.Hand; // 禁用InkCanvas对截图的选择处理 image.IsHitTestVisible = true; @@ -253,7 +258,7 @@ namespace Ink_Canvas } // 专门为截图优化的居中缩放方法 - private void CenterAndScaleScreenshot(System.Windows.Controls.Image image) + private void CenterAndScaleScreenshot(Image image) { try { @@ -270,8 +275,8 @@ namespace Ink_Canvas // 如果画布尺寸为0,使用窗口尺寸作为备选 if (canvasWidth <= 0 || canvasHeight <= 0) { - canvasWidth = this.ActualWidth; - canvasHeight = this.ActualHeight; + canvasWidth = ActualWidth; + canvasHeight = ActualHeight; } // 如果仍然为0,使用屏幕尺寸 @@ -338,7 +343,7 @@ namespace Ink_Canvas } // 应用形状遮罩到截图 - private Bitmap ApplyShapeMask(Bitmap bitmap, List path, Rectangle area) + private Bitmap ApplyShapeMask(Bitmap bitmap, List path, Rectangle area) { try { @@ -360,7 +365,7 @@ namespace Ink_Canvas using (var resultGraphics = Graphics.FromImage(resultBitmap)) { // 清除位图,设置为完全透明 - resultGraphics.Clear(System.Drawing.Color.Transparent); + resultGraphics.Clear(Color.Transparent); // 设置高质量渲染 resultGraphics.SmoothingMode = SmoothingMode.AntiAlias; diff --git a/Ink Canvas/MainWindow_cs/MW_Notification.cs b/Ink Canvas/MainWindow_cs/MW_Notification.cs index e1e69945..c473b859 100644 --- a/Ink Canvas/MainWindow_cs/MW_Notification.cs +++ b/Ink Canvas/MainWindow_cs/MW_Notification.cs @@ -1,8 +1,8 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Linq; using System.Threading; using System.Windows; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index ea3ac813..065def08 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -1,8 +1,4 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern; -using Microsoft.Office.Core; -using Microsoft.Office.Interop.PowerPoint; -using System; +using System; using System.IO; using System.Runtime.InteropServices; using System.Security.Cryptography; @@ -12,6 +8,10 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using System.Windows.Threading; +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern; +using Microsoft.Office.Core; +using Microsoft.Office.Interop.PowerPoint; using Application = System.Windows.Application; using File = System.IO.File; using MessageBox = System.Windows.MessageBox; diff --git a/Ink Canvas/MainWindow_cs/MW_PageListView.cs b/Ink Canvas/MainWindow_cs/MW_PageListView.cs index 2a185925..c7ea6c80 100644 --- a/Ink Canvas/MainWindow_cs/MW_PageListView.cs +++ b/Ink Canvas/MainWindow_cs/MW_PageListView.cs @@ -1,10 +1,10 @@ -using Ink_Canvas.Helpers; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Input; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs index bf233c24..fb242d97 100644 --- a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs +++ b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs @@ -1,15 +1,22 @@ -using Ink_Canvas.Helpers; -using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; using System.IO; +using System.IO.Compression; +using System.Text; using System.Windows; using System.Windows.Controls; +using System.Windows.Forms; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using Ink_Canvas.Helpers; +using Newtonsoft.Json; +using Color = System.Drawing.Color; using File = System.IO.File; +using Image = System.Windows.Controls.Image; using OpenFileDialog = Microsoft.Win32.OpenFileDialog; namespace Ink_Canvas @@ -150,7 +157,7 @@ namespace Ink_Canvas catch (Exception ex) { ShowNotification("墨迹保存失败"); - LogHelper.WriteLogToFile("墨迹保存失败 | " + ex.ToString(), LogHelper.LogType.Error); + LogHelper.WriteLogToFile("墨迹保存失败 | " + ex, LogHelper.LogType.Error); } } @@ -191,7 +198,7 @@ namespace Ink_Canvas // 保存元数据信息 string metadataFile = Path.Combine(tempDir, "metadata.txt"); - using (var writer = new StreamWriter(metadataFile, false, System.Text.Encoding.UTF8)) + using (var writer = new StreamWriter(metadataFile, false, Encoding.UTF8)) { writer.WriteLine($"保存时间: {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); writer.WriteLine($"总页数: {allPageStrokes.Count}"); @@ -219,7 +226,7 @@ namespace Ink_Canvas File.Delete(zipFileName); // 使用System.IO.Compression.FileSystem来创建ZIP - System.IO.Compression.ZipFile.CreateFromDirectory(tempDir, zipFileName); + ZipFile.CreateFromDirectory(tempDir, zipFileName); if (newNotice) ShowNotification($"多页面墨迹成功保存至压缩包 {zipFileName}"); } @@ -233,13 +240,13 @@ namespace Ink_Canvas } catch (Exception ex) { - LogHelper.WriteLogToFile($"清理临时目录失败: {ex.ToString()}", LogHelper.LogType.Warning); + LogHelper.WriteLogToFile($"清理临时目录失败: {ex}", LogHelper.LogType.Warning); } } } catch (Exception ex) { - LogHelper.WriteLogToFile($"保存多页面墨迹压缩包失败: {ex.ToString()}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"保存多页面墨迹压缩包失败: {ex}", LogHelper.LogType.Error); throw; } } @@ -250,16 +257,16 @@ namespace Ink_Canvas private void SaveSinglePageStrokesAsImage(string savePathWithName, bool newNotice) { // 全页面保存模式 - 保存整个墨迹页面的图像 - var bitmap = new System.Drawing.Bitmap( - (int)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, - (int)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height); + var bitmap = new Bitmap( + Screen.PrimaryScreen.Bounds.Width, + Screen.PrimaryScreen.Bounds.Height); - using (var g = System.Drawing.Graphics.FromImage(bitmap)) + using (var g = Graphics.FromImage(bitmap)) { // 创建黑色或透明背景 - System.Drawing.Color bgColor = Settings.Canvas.UsingWhiteboard - ? System.Drawing.Color.White - : System.Drawing.Color.FromArgb(22, 41, 36); // 黑板背景色 + Color bgColor = Settings.Canvas.UsingWhiteboard + ? Color.White + : Color.FromArgb(22, 41, 36); // 黑板背景色 g.Clear(bgColor); // 将InkCanvas墨迹渲染到Visual @@ -287,7 +294,7 @@ namespace Ink_Canvas { encoder.Save(ms); ms.Seek(0, SeekOrigin.Begin); - var imgBitmap = new System.Drawing.Bitmap(ms); + var imgBitmap = new Bitmap(ms); // 将生成的墨迹图像绘制到屏幕截图上 // 居中绘制,确保墨迹位于屏幕中央 @@ -297,7 +304,7 @@ namespace Ink_Canvas // 保存为PNG string imagePathWithName = Path.ChangeExtension(savePathWithName, "png"); - bitmap.Save(imagePathWithName, System.Drawing.Imaging.ImageFormat.Png); + bitmap.Save(imagePathWithName, ImageFormat.Png); // 仍然保存墨迹文件以兼容旧版本 var fs = new FileStream(savePathWithName, FileMode.Create); @@ -337,7 +344,7 @@ namespace Ink_Canvas } catch (Exception ex) { - LogHelper.WriteLogToFile($"保存页面图像失败: {ex.ToString()}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"保存页面图像失败: {ex}", LogHelper.LogType.Error); throw; } } @@ -376,7 +383,7 @@ namespace Ink_Canvas catch (Exception ex) { ShowNotification("墨迹打开失败"); - LogHelper.WriteLogToFile($"墨迹打开失败: {ex.ToString()}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"墨迹打开失败: {ex}", LogHelper.LogType.Error); } } @@ -394,7 +401,7 @@ namespace Ink_Canvas try { // 解压ZIP文件 - System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, tempDir); + ZipFile.ExtractToDirectory(zipFilePath, tempDir); // 读取元数据文件 string metadataFile = Path.Combine(tempDir, "metadata.txt"); @@ -447,13 +454,13 @@ namespace Ink_Canvas } catch (Exception ex) { - LogHelper.WriteLogToFile($"清理临时目录失败: {ex.ToString()}", LogHelper.LogType.Warning); + LogHelper.WriteLogToFile($"清理临时目录失败: {ex}", LogHelper.LogType.Warning); } } } catch (Exception ex) { - LogHelper.WriteLogToFile($"打开ICC压缩包失败: {ex.ToString()}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"打开ICC压缩包失败: {ex}", LogHelper.LogType.Error); throw; } } @@ -465,7 +472,7 @@ namespace Ink_Canvas { var metadata = new Dictionary(); - using (var reader = new StreamReader(metadataPath, System.Text.Encoding.UTF8)) + using (var reader = new StreamReader(metadataPath, Encoding.UTF8)) { string line; while ((line = reader.ReadLine()) != null) @@ -556,7 +563,7 @@ namespace Ink_Canvas } catch (Exception ex) { - LogHelper.WriteLogToFile($"恢复PPT墨迹失败: {ex.ToString()}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"恢复PPT墨迹失败: {ex}", LogHelper.LogType.Error); throw; } } @@ -609,7 +616,7 @@ namespace Ink_Canvas { // 创建历史记录 var history = new TimeMachineHistory(strokes, TimeMachineHistoryType.UserInput, false); - TimeMachineHistories[pageNumber] = new TimeMachineHistory[] { history }; + TimeMachineHistories[pageNumber] = new[] { history }; } } } @@ -628,7 +635,7 @@ namespace Ink_Canvas } catch (Exception ex) { - LogHelper.WriteLogToFile($"恢复白板墨迹失败: {ex.ToString()}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"恢复白板墨迹失败: {ex}", LogHelper.LogType.Error); throw; } } diff --git a/Ink Canvas/MainWindow_cs/MW_Screenshot.cs b/Ink Canvas/MainWindow_cs/MW_Screenshot.cs index 05b5cf89..f398a4e9 100644 --- a/Ink Canvas/MainWindow_cs/MW_Screenshot.cs +++ b/Ink Canvas/MainWindow_cs/MW_Screenshot.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; using System.Windows; @@ -42,10 +43,10 @@ namespace Ink_Canvas using (var memoryGraphics = Graphics.FromImage(bitmap)) { // 设置高质量渲染 - memoryGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; - memoryGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; - memoryGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; - memoryGraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; + memoryGraphics.CompositingQuality = CompositingQuality.HighQuality; + memoryGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + memoryGraphics.SmoothingMode = SmoothingMode.HighQuality; + memoryGraphics.CompositingMode = CompositingMode.SourceOver; memoryGraphics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy); diff --git a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs index 88daa927..f8547b85 100644 --- a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs +++ b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs @@ -1,13 +1,13 @@ -using iNKORE.UI.WPF.Modern.Controls; using System; using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; +using iNKORE.UI.WPF.Modern.Controls; using Point = System.Windows.Point; -using System.Linq; namespace Ink_Canvas { @@ -308,7 +308,7 @@ namespace Ink_Canvas // 检查是否有图片元素被选中 var selectedElements = inkCanvas.GetSelectedElements(); - bool hasImageElement = selectedElements.Any(element => element is System.Windows.Controls.Image); + bool hasImageElement = selectedElements.Any(element => element is Image); // 如果有图片元素被选中,不显示选择框 if (hasImageElement) @@ -551,11 +551,9 @@ namespace Ink_Canvas return new Rect(left, top, width, height); } } - else - { - // 没有变换时直接使用位置和大小 - return new Rect(left, top, width, height); - } + + // 没有变换时直接使用位置和大小 + return new Rect(left, top, width, height); } return new Rect(0, 0, 0, 0); diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index 7ebcbfe3..6f100340 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -1,7 +1,3 @@ -using Hardcodet.Wpf.TaskbarNotification; -using Ink_Canvas.Helpers; -using Newtonsoft.Json; -using OSVersionExtension; using System; using System.Diagnostics; using System.IO; @@ -13,6 +9,11 @@ using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Threading; +using Hardcodet.Wpf.TaskbarNotification; +using Ink_Canvas.Helpers; +using Newtonsoft.Json; +using OSVersionExtension; using Application = System.Windows.Application; using CheckBox = System.Windows.Controls.CheckBox; using ComboBox = System.Windows.Controls.ComboBox; @@ -2709,7 +2710,7 @@ namespace Ink_Canvas { LogHelper.WriteLogToFile($"重新计算高光位置和浮动栏位置失败: {ex.Message}", LogHelper.LogType.Error); } - }), System.Windows.Threading.DispatcherPriority.Loaded); + }), DispatcherPriority.Loaded); } catch (Exception ex) { diff --git a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs index a423b3c2..5501b884 100644 --- a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs +++ b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs @@ -1,8 +1,4 @@ -using Hardcodet.Wpf.TaskbarNotification; -using Ink_Canvas.Helpers; -using Newtonsoft.Json; -using OSVersionExtension; -using System; +using System; using System.Reflection; using System.Windows; using System.Windows.Controls; @@ -10,6 +6,10 @@ using System.Windows.Ink; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using Hardcodet.Wpf.TaskbarNotification; +using Ink_Canvas.Helpers; +using Newtonsoft.Json; +using OSVersionExtension; using File = System.IO.File; using OperatingSystem = OSVersionExtension.OperatingSystem; diff --git a/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs b/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs index f72ed6ab..4b8ca738 100644 --- a/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs +++ b/Ink Canvas/MainWindow_cs/MW_ShapeDrawing.cs @@ -1,6 +1,4 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern.Controls; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; @@ -10,6 +8,8 @@ using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern.Controls; using MessageBox = System.Windows.MessageBox; using Point = System.Windows.Point; @@ -499,20 +499,18 @@ namespace Ink_Canvas catch { } return; } - else + + // 其他情况正常删除临时笔画 + try { - // 其他情况正常删除临时笔画 - try - { - inkCanvas.Strokes.Remove(lastTempStroke); - inkCanvas.Strokes.Remove(lastTempStrokeCollection); - } - catch - { - Trace.WriteLine("lastTempStrokeCollection failed."); - } - return; + inkCanvas.Strokes.Remove(lastTempStroke); + inkCanvas.Strokes.Remove(lastTempStrokeCollection); } + catch + { + Trace.WriteLine("lastTempStrokeCollection failed."); + } + return; } // 修复:双曲线绘制时,第二笔应该基于第一笔的起点,而不是触摸实时位置 diff --git a/Ink Canvas/MainWindow_cs/MW_SimulatePressure&InkToShape.cs b/Ink Canvas/MainWindow_cs/MW_SimulatePressure&InkToShape.cs index e25bb882..8e14c503 100644 --- a/Ink Canvas/MainWindow_cs/MW_SimulatePressure&InkToShape.cs +++ b/Ink Canvas/MainWindow_cs/MW_SimulatePressure&InkToShape.cs @@ -1,5 +1,4 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -9,6 +8,7 @@ using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; +using Ink_Canvas.Helpers; using Point = System.Windows.Point; namespace Ink_Canvas diff --git a/Ink Canvas/MainWindow_cs/MW_TimeMachine.cs b/Ink Canvas/MainWindow_cs/MW_TimeMachine.cs index c663f058..541d2068 100644 --- a/Ink Canvas/MainWindow_cs/MW_TimeMachine.cs +++ b/Ink Canvas/MainWindow_cs/MW_TimeMachine.cs @@ -1,5 +1,4 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Windows; @@ -7,6 +6,7 @@ using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/MainWindow_cs/MW_Timer.cs b/Ink Canvas/MainWindow_cs/MW_Timer.cs index 3c9e0e4b..4988c444 100644 --- a/Ink Canvas/MainWindow_cs/MW_Timer.cs +++ b/Ink Canvas/MainWindow_cs/MW_Timer.cs @@ -1,5 +1,4 @@ -using Ink_Canvas.Helpers; -using System; +using System; using System.ComponentModel; using System.Diagnostics; using System.IO; @@ -12,6 +11,7 @@ using System.Threading.Tasks; using System.Timers; using System.Windows; using System.Windows.Controls; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs index 42ae0582..7aedfd43 100644 --- a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs +++ b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs @@ -1,4 +1,3 @@ -using Ink_Canvas.Helpers; using System; using System.Collections.Generic; using System.Linq; @@ -8,6 +7,8 @@ using System.Windows.Controls; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Threading; +using Ink_Canvas.Helpers; using Point = System.Windows.Point; namespace Ink_Canvas @@ -398,10 +399,10 @@ namespace Ink_Canvas private InkCanvasEditingMode palmEraserLastEditingMode = InkCanvasEditingMode.Ink; private bool palmEraserLastIsHighlighter; private bool palmEraserWasEnabledBeforeMultiTouch; - private bool palmEraserTouchDownHandled = false; // 新增:标记手掌擦触摸按下是否已处理 + private bool palmEraserTouchDownHandled; // 新增:标记手掌擦触摸按下是否已处理 private DateTime palmEraserActivationTime; // 新增:记录手掌擦激活时间 private const int PALM_ERASER_TIMEOUT_MS = 3000; // 修改:减少手掌擦超时时间(3秒) - private System.Windows.Threading.DispatcherTimer palmEraserRecoveryTimer; // 新增:手掌擦恢复定时器 + private DispatcherTimer palmEraserRecoveryTimer; // 新增:手掌擦恢复定时器 private HashSet palmEraserTouchIds = new HashSet(); // 新增:记录参与手掌擦的触摸点ID private void inkCanvas_PreviewTouchDown(object sender, TouchEventArgs e) @@ -983,7 +984,7 @@ namespace Ink_Canvas { if (palmEraserRecoveryTimer == null) { - palmEraserRecoveryTimer = new System.Windows.Threading.DispatcherTimer(); + palmEraserRecoveryTimer = new DispatcherTimer(); palmEraserRecoveryTimer.Interval = TimeSpan.FromMilliseconds(1000); // 每秒检查一次 palmEraserRecoveryTimer.Tick += PalmEraserRecoveryTimer_Tick; } diff --git a/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs index 96796023..b20cb2d7 100644 --- a/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs +++ b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs @@ -1,12 +1,12 @@ -using Hardcodet.Wpf.TaskbarNotification; -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern.Controls; -using System; +using System; using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Interop; +using Hardcodet.Wpf.TaskbarNotification; +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern.Controls; using Application = System.Windows.Application; using ContextMenu = System.Windows.Controls.ContextMenu; using MenuItem = System.Windows.Controls.MenuItem; diff --git a/Ink Canvas/Resources/Settings.cs b/Ink Canvas/Resources/Settings.cs index fc4e687a..8efdf432 100644 --- a/Ink Canvas/Resources/Settings.cs +++ b/Ink Canvas/Resources/Settings.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.IO; +using Newtonsoft.Json; namespace Ink_Canvas { @@ -93,11 +93,11 @@ namespace Ink_Canvas [JsonProperty("clearCanvasAlsoClearImages")] public bool ClearCanvasAlsoClearImages { get; set; } = true; [JsonProperty("showCircleCenter")] - public bool ShowCircleCenter { get; set; } = false; + public bool ShowCircleCenter { get; set; } // 墨迹渐隐功能设置 [JsonProperty("enableInkFade")] - public bool EnableInkFade { get; set; } = false; // 是否启用墨迹渐隐功能 + public bool EnableInkFade { get; set; } // 是否启用墨迹渐隐功能 [JsonProperty("inkFadeTime")] public int InkFadeTime { get; set; } = 3000; // 墨迹渐隐时间(毫秒) @@ -152,7 +152,7 @@ namespace Ink_Canvas [JsonProperty("skippedVersion")] public string SkippedVersion { get; set; } = ""; [JsonProperty("isEnableNibMode")] - public bool IsEnableNibMode { get; set; } = false; + public bool IsEnableNibMode { get; set; } [JsonProperty("isFoldAtStartup")] public bool IsFoldAtStartup { get; set; } [JsonProperty("crashAction")] @@ -225,10 +225,10 @@ namespace Ink_Canvas public bool IsShowClearAndMouseButton { get; set; } = true; [JsonProperty("eraserDisplayOption")] - public int EraserDisplayOption { get; set; } = 0; + public int EraserDisplayOption { get; set; } [JsonProperty("isShowQuickColorPalette")] - public bool IsShowQuickColorPalette { get; set; } = false; + public bool IsShowQuickColorPalette { get; set; } [JsonProperty("quickColorPaletteDisplayMode")] public int QuickColorPaletteDisplayMode { get; set; } = 1; diff --git a/Ink Canvas/Windows/AddCustomIconWindow.xaml.cs b/Ink Canvas/Windows/AddCustomIconWindow.xaml.cs index a214c9f2..060c5b9d 100644 --- a/Ink Canvas/Windows/AddCustomIconWindow.xaml.cs +++ b/Ink Canvas/Windows/AddCustomIconWindow.xaml.cs @@ -1,8 +1,8 @@ -using Microsoft.Win32; using System; using System.IO; using System.Windows; using System.Windows.Media.Imaging; +using Microsoft.Win32; namespace Ink_Canvas { diff --git a/Ink Canvas/Windows/AddPickNameBackgroundWindow.xaml.cs b/Ink Canvas/Windows/AddPickNameBackgroundWindow.xaml.cs index bc602748..f9aa8951 100644 --- a/Ink Canvas/Windows/AddPickNameBackgroundWindow.xaml.cs +++ b/Ink Canvas/Windows/AddPickNameBackgroundWindow.xaml.cs @@ -1,8 +1,8 @@ -using Microsoft.Win32; using System; using System.IO; using System.Windows; using System.Windows.Media.Imaging; +using Microsoft.Win32; namespace Ink_Canvas { diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs index 08d2d462..6e00b4c5 100644 --- a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs +++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs @@ -1,6 +1,4 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern.Controls; -using System; +using System; using System.ComponentModel; using System.Media; using System.Timers; @@ -9,6 +7,7 @@ using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; +using Ink_Canvas.Helpers; using Application = System.Windows.Application; using MouseEventArgs = System.Windows.Input.MouseEventArgs; using Timer = System.Timers.Timer; @@ -92,7 +91,7 @@ namespace Ink_Canvas private void Grid_MouseUp(object sender, MouseButtonEventArgs e) { if (isTimerRunning) return; - if (ProcessBarTime.Visibility == Visibility.Visible && isTimerRunning == false) + if (ProcessBarTime.Visibility == Visibility.Visible && !isTimerRunning) { ProcessBarTime.Visibility = Visibility.Collapsed; GridAdjustHour.Visibility = Visibility.Visible; diff --git a/Ink Canvas/Windows/HasNewUpdateWindow.xaml.cs b/Ink Canvas/Windows/HasNewUpdateWindow.xaml.cs index 53a4a06b..41a7b7c8 100644 --- a/Ink Canvas/Windows/HasNewUpdateWindow.xaml.cs +++ b/Ink Canvas/Windows/HasNewUpdateWindow.xaml.cs @@ -1,7 +1,4 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern.Controls; -using MdXaml; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -13,6 +10,9 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Interop; using System.Windows.Media; +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern.Controls; +using MdXaml; namespace Ink_Canvas { diff --git a/Ink Canvas/Windows/HistoryRollbackWindow.xaml.cs b/Ink Canvas/Windows/HistoryRollbackWindow.xaml.cs index 15e96c61..b9a749a4 100644 --- a/Ink Canvas/Windows/HistoryRollbackWindow.xaml.cs +++ b/Ink Canvas/Windows/HistoryRollbackWindow.xaml.cs @@ -1,4 +1,3 @@ -using Ink_Canvas.Helpers; using System; using System.Collections.Generic; using System.ComponentModel; @@ -8,6 +7,8 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using Ink_Canvas.Helpers; + // Added for OrderByDescending namespace Ink_Canvas diff --git a/Ink Canvas/Windows/HotkeyItem.xaml.cs b/Ink Canvas/Windows/HotkeyItem.xaml.cs index 4f498877..146791e3 100644 --- a/Ink Canvas/Windows/HotkeyItem.xaml.cs +++ b/Ink Canvas/Windows/HotkeyItem.xaml.cs @@ -2,6 +2,7 @@ using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Media; namespace Ink_Canvas.Windows { @@ -79,20 +80,20 @@ namespace Ink_Canvas.Windows if (_currentKey == Key.None) { CurrentHotkeyTextBlock.Text = "未设置"; - CurrentHotkeyTextBlock.Foreground = System.Windows.Media.Brushes.Gray; + CurrentHotkeyTextBlock.Foreground = Brushes.Gray; } else { var modifiersText = _currentModifiers == ModifierKeys.None ? "" : $"{_currentModifiers}+"; CurrentHotkeyTextBlock.Text = $"{modifiersText}{_currentKey}"; - CurrentHotkeyTextBlock.Foreground = System.Windows.Media.Brushes.Black; + CurrentHotkeyTextBlock.Foreground = Brushes.Black; } } private void StartHotkeyCapture() { BtnSetHotkey.Content = "请按键..."; - BtnSetHotkey.Background = System.Windows.Media.Brushes.Orange; + BtnSetHotkey.Background = Brushes.Orange; // 设置焦点以捕获键盘事件 Focus(); @@ -105,7 +106,7 @@ namespace Ink_Canvas.Windows private void StopHotkeyCapture() { BtnSetHotkey.Content = "设置"; - BtnSetHotkey.Background = System.Windows.Media.Brushes.DodgerBlue; + BtnSetHotkey.Background = Brushes.DodgerBlue; // 移除键盘事件处理器 KeyDown -= HotkeyItem_KeyDown; diff --git a/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs b/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs index 14ca4c9c..b21ee2c5 100644 --- a/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs +++ b/Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Windows; +using System.Windows.Controls; using System.Windows.Input; using Ink_Canvas.Helpers; @@ -324,11 +326,11 @@ namespace Ink_Canvas.Windows // 立即保存到配置文件 _hotkeyManager.SaveHotkeysToSettings(); - LogHelper.WriteLogToFile($"已保存快捷键配置"); + LogHelper.WriteLogToFile("已保存快捷键配置"); // 更新UI显示 LoadCurrentHotkeys(); - LogHelper.WriteLogToFile($"已更新UI显示"); + LogHelper.WriteLogToFile("已更新UI显示"); LogHelper.WriteLogToFile($"快捷键 {hotkeyName} 已更新为 {modifiers}+{key} 并保存", LogHelper.LogType.Event); } @@ -403,7 +405,7 @@ namespace Ink_Canvas.Windows { // 通过反射访问主窗口的penType字段 var penTypeField = _mainWindow.GetType().GetField("penType", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + BindingFlags.NonPublic | BindingFlags.Instance); if (penTypeField != null) { @@ -411,7 +413,7 @@ namespace Ink_Canvas.Windows // 调用CheckPenTypeUIState方法更新UI状态 var checkPenTypeMethod = _mainWindow.GetType().GetMethod("CheckPenTypeUIState", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + BindingFlags.NonPublic | BindingFlags.Instance); if (checkPenTypeMethod != null) { @@ -436,7 +438,7 @@ namespace Ink_Canvas.Windows { // 通过反射访问主窗口的设置面板 var settingsBorder = _mainWindow.GetType().GetField("BorderSettings", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(_mainWindow) as System.Windows.Controls.Border; + BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border; if (settingsBorder != null) { @@ -445,7 +447,7 @@ namespace Ink_Canvas.Windows // 隐藏设置蒙版 var settingsMask = _mainWindow.GetType().GetField("BorderSettingsMask", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(_mainWindow) as System.Windows.Controls.Border; + BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border; if (settingsMask != null) { @@ -467,7 +469,7 @@ namespace Ink_Canvas.Windows { // 通过反射访问主窗口的设置面板 var settingsBorder = _mainWindow.GetType().GetField("BorderSettings", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(_mainWindow) as System.Windows.Controls.Border; + BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border; if (settingsBorder != null) { @@ -476,7 +478,7 @@ namespace Ink_Canvas.Windows // 显示设置蒙版 var settingsMask = _mainWindow.GetType().GetField("BorderSettingsMask", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(_mainWindow) as System.Windows.Controls.Border; + BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border; if (settingsMask != null) { diff --git a/Ink Canvas/Windows/NamesInputWindow.xaml.cs b/Ink Canvas/Windows/NamesInputWindow.xaml.cs index ab020adc..9e9a637a 100644 --- a/Ink Canvas/Windows/NamesInputWindow.xaml.cs +++ b/Ink Canvas/Windows/NamesInputWindow.xaml.cs @@ -1,7 +1,7 @@ -using Ink_Canvas.Helpers; -using System.ComponentModel; +using System.ComponentModel; using System.IO; using System.Windows; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs b/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs index 7b129e9c..566ab053 100644 --- a/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs +++ b/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs @@ -1,7 +1,6 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern.Controls; -using System.Windows; +using System.Windows; using System.Windows.Input; +using Ink_Canvas.Helpers; namespace Ink_Canvas { diff --git a/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs b/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs index cdaecc4e..96395e9b 100644 --- a/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs +++ b/Ink Canvas/Windows/PluginSettingsWindow.xaml.cs @@ -1,9 +1,3 @@ -using Ink_Canvas.Helpers; -using Ink_Canvas.Helpers.Plugins; -using Ink_Canvas.Helpers.Plugins.BuiltIn; -using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher; -using iNKORE.UI.WPF.Modern.Controls; -using Microsoft.Win32; using System; using System.Collections.ObjectModel; using System.ComponentModel; @@ -12,6 +6,12 @@ using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Threading; +using Ink_Canvas.Helpers; +using Ink_Canvas.Helpers.Plugins; +using Ink_Canvas.Helpers.Plugins.BuiltIn; +using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher; +using iNKORE.UI.WPF.Modern.Controls; +using Microsoft.Win32; using MessageBox = System.Windows.MessageBox; namespace Ink_Canvas.Windows diff --git a/Ink Canvas/Windows/RandWindow.xaml.cs b/Ink Canvas/Windows/RandWindow.xaml.cs index ae708f2a..c4e07ac7 100644 --- a/Ink Canvas/Windows/RandWindow.xaml.cs +++ b/Ink Canvas/Windows/RandWindow.xaml.cs @@ -1,7 +1,4 @@ -using Ink_Canvas.Helpers; -using iNKORE.UI.WPF.Modern.Controls; -using Microsoft.VisualBasic; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -11,6 +8,8 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using Ink_Canvas.Helpers; +using Microsoft.VisualBasic; using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox; namespace Ink_Canvas @@ -24,7 +23,7 @@ namespace Ink_Canvas { InitializeComponent(); AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25); - BorderBtnHelp.Visibility = settings.RandSettings.DisplayRandWindowNamesInputBtn == false ? Visibility.Collapsed : Visibility.Visible; + BorderBtnHelp.Visibility = !settings.RandSettings.DisplayRandWindowNamesInputBtn ? Visibility.Collapsed : Visibility.Visible; RandMaxPeopleOneTime = settings.RandSettings.RandWindowOnceMaxStudents; RandDoneAutoCloseWaitTime = (int)settings.RandSettings.RandWindowOnceCloseLatency * 1000; @@ -69,7 +68,7 @@ namespace Ink_Canvas isAutoClose = IsAutoClose; PeopleControlPane.Opacity = 0.4; PeopleControlPane.IsHitTestVisible = false; - BorderBtnHelp.Visibility = settings.RandSettings.DisplayRandWindowNamesInputBtn == false ? Visibility.Collapsed : Visibility.Visible; + BorderBtnHelp.Visibility = !settings.RandSettings.DisplayRandWindowNamesInputBtn ? Visibility.Collapsed : Visibility.Visible; RandMaxPeopleOneTime = settings.RandSettings.RandWindowOnceMaxStudents; RandDoneAutoCloseWaitTime = (int)settings.RandSettings.RandWindowOnceCloseLatency * 1000; diff --git a/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml b/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml index 00b0bf05..d82fcbd6 100644 --- a/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml +++ b/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml @@ -20,71 +20,157 @@ Fill="Black" Opacity="0.3" /> + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - -