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