From fd0bd0b34374b7035c52a1f171841a403e47865c Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sat, 13 Sep 2025 14:33:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=89=98=E7=9B=98=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/App.xaml | 2 +- Ink Canvas/MainWindow_cs/MW_TrayIcon.cs | 55 +++++++++++++++++++ .../Windows/ScreenshotSelectorWindow.xaml.cs | 2 +- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Ink Canvas/App.xaml b/Ink Canvas/App.xaml index 1ba8b030..0eecad8a 100644 --- a/Ink Canvas/App.xaml +++ b/Ink Canvas/App.xaml @@ -32,7 +32,7 @@ - + diff --git a/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs index 21a9de2b..e1f3bbaf 100644 --- a/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs +++ b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs @@ -201,5 +201,60 @@ namespace Ink_Canvas } } + private void DisableAllHotkeysMenuItem_Clicked(object sender, RoutedEventArgs e) + { + var mainWin = (MainWindow)Current.MainWindow; + if (mainWin.IsLoaded) + { + try + { + // 获取全局快捷键管理器 + var hotkeyManagerField = typeof(MainWindow).GetField("_globalHotkeyManager", + System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + var hotkeyManager = hotkeyManagerField?.GetValue(mainWin) as GlobalHotkeyManager; + + if (hotkeyManager != null) + { + // 禁用所有快捷键 + hotkeyManager.DisableHotkeyRegistration(); + + // 更新菜单项文本和状态 + var menuItem = sender as MenuItem; + if (menuItem != null) + { + var headerPanel = menuItem.Header as iNKORE.UI.WPF.Modern.Controls.SimpleStackPanel; + if (headerPanel != null) + { + var textBlock = headerPanel.Children[0] as TextBlock; + if (textBlock != null) + { + if (textBlock.Text == "禁用所有快捷键") + { + textBlock.Text = "启用所有快捷键"; + LogHelper.WriteLogToFile("已禁用所有快捷键", LogHelper.LogType.Event); + } + else + { + textBlock.Text = "禁用所有快捷键"; + // 重新启用快捷键 + hotkeyManager.EnableHotkeyRegistration(); + LogHelper.WriteLogToFile("已启用所有快捷键", LogHelper.LogType.Event); + } + } + } + } + } + else + { + LogHelper.WriteLogToFile("无法获取全局快捷键管理器", LogHelper.LogType.Error); + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"禁用/启用快捷键时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + } + } } diff --git a/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml.cs b/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml.cs index 5a93c484..46ef5225 100644 --- a/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml.cs +++ b/Ink Canvas/Windows/ScreenshotSelectorWindow.xaml.cs @@ -34,7 +34,7 @@ namespace Ink_Canvas private Rect _currentSelection; private ControlPointType _activeControlPoint = ControlPointType.None; private CameraService _cameraService; - private Bitmap _capturedCameraImage; + private Bitmap _capturedCameraImage = null; // 控制点类型枚举 private enum ControlPointType