From 243201502ba263beb10d066b8f6f3d4316a72f87 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 5 Apr 2026 21:32:01 +0800 Subject: [PATCH] add:issue #402 --- Ink Canvas/Helpers/GlobalHotkeyManager.cs | 12 ++++++++++++ Ink Canvas/MainWindow.xaml.cs | 16 ++++++++++++++++ Ink Canvas/Windows/HotkeySettingsWindow.xaml | 5 +++++ Ink Canvas/Windows/HotkeySettingsWindow.xaml.cs | 8 ++++++++ 4 files changed, 41 insertions(+) diff --git a/Ink Canvas/Helpers/GlobalHotkeyManager.cs b/Ink Canvas/Helpers/GlobalHotkeyManager.cs index e9bfcd97..e0516650 100644 --- a/Ink Canvas/Helpers/GlobalHotkeyManager.cs +++ b/Ink Canvas/Helpers/GlobalHotkeyManager.cs @@ -285,6 +285,7 @@ namespace Ink_Canvas.Helpers // 功能快捷键 RegisterHotkey("DrawLine", Key.L, ModifierKeys.Alt, () => _mainWindow.BtnDrawLine_Click(null, null)); RegisterHotkey("Screenshot", Key.C, ModifierKeys.Alt, () => _mainWindow.SaveScreenShotToDesktop()); + RegisterHotkey("QuickDraw", Key.K, ModifierKeys.Alt, () => _mainWindow.OpenQuickDrawFromHotkey()); RegisterHotkey("Hide", Key.V, ModifierKeys.Alt, () => _mainWindow.SymbolIconEmoji_MouseUp(null, null)); // 退出快捷键 @@ -1033,6 +1034,7 @@ namespace Ink_Canvas.Helpers new HotkeyConfigItem { Name = "Pen5", Key = Key.D5, Modifiers = ModifierKeys.Alt }, new HotkeyConfigItem { Name = "DrawLine", Key = Key.L, Modifiers = ModifierKeys.Alt }, new HotkeyConfigItem { Name = "Screenshot", Key = Key.C, Modifiers = ModifierKeys.Alt }, + new HotkeyConfigItem { Name = "QuickDraw", Key = Key.K, Modifiers = ModifierKeys.Alt }, new HotkeyConfigItem { Name = "Hide", Key = Key.V, Modifiers = ModifierKeys.Alt }, new HotkeyConfigItem { Name = "Exit", Key = Key.Escape, Modifiers = ModifierKeys.None } }); @@ -1111,6 +1113,14 @@ namespace Ink_Canvas.Helpers } } + // 旧版 HotkeyConfig.json 无「快抽」项时补注册默认组合,避免升级后无快捷键 + if (successCount > 0 && !IsHotkeyRegistered("QuickDraw")) + { + var quickDrawAction = GetActionByName("QuickDraw"); + if (quickDrawAction != null && RegisterHotkey("QuickDraw", Key.K, ModifierKeys.Alt, quickDrawAction)) + successCount++; + } + if (successCount > 0) { _hotkeysShouldBeRegistered = true; @@ -1221,6 +1231,8 @@ namespace Ink_Canvas.Helpers return () => _mainWindow.BtnDrawLine_Click(null, null); case "Screenshot": return () => _mainWindow.SaveScreenShotToDesktop(); + case "QuickDraw": + return () => _mainWindow.OpenQuickDrawFromHotkey(); case "Hide": return () => _mainWindow.SymbolIconEmoji_MouseUp(null, null); case "Exit": diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index da7c2853..4b5a2e7c 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -4711,6 +4711,22 @@ namespace Ink_Canvas } } + internal void OpenQuickDrawFromHotkey() + { + try + { + if (Settings?.RandSettings?.EnableQuickDraw != true) + return; + + var quickDrawWindow = new QuickDrawWindow(); + quickDrawWindow.ShowDialog(); + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"打开快抽窗口失败: {ex.Message}", LogHelper.LogType.Error); + } + } + /// /// 显示快抽悬浮按钮 /// diff --git a/Ink Canvas/Windows/HotkeySettingsWindow.xaml b/Ink Canvas/Windows/HotkeySettingsWindow.xaml index 60928011..249de7b1 100644 --- a/Ink Canvas/Windows/HotkeySettingsWindow.xaml +++ b/Ink Canvas/Windows/HotkeySettingsWindow.xaml @@ -177,6 +177,11 @@ Description="保存屏幕截图到桌面" DefaultKey="C" DefaultModifiers="Alt"/> + _mainWindow.BtnDrawLine_Click(null, null); case "Screenshot": return () => _mainWindow.SaveScreenShotToDesktop(); + case "QuickDraw": + return () => _mainWindow.OpenQuickDrawFromHotkey(); case "Hide": return () => _mainWindow.SymbolIconEmoji_MouseUp(null, null); case "Exit":