From ab9a6176199852e5b61c0b3685396edf13269376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E5=82=91?= Date: Tue, 25 Jul 2023 21:17:02 +0800 Subject: [PATCH] Allows setting individual key as HotKey --- .../Pages/PageHotKey.Designer.cs | 2 +- Source/GrasscutterTools/Pages/PageHotKey.cs | 7 +- Source/GrasscutterTools/Pages/PageHotKey.resx | 477 +++++++++--------- Source/GrasscutterTools/Utils/KeyGo.cs | 5 +- 4 files changed, 248 insertions(+), 243 deletions(-) diff --git a/Source/GrasscutterTools/Pages/PageHotKey.Designer.cs b/Source/GrasscutterTools/Pages/PageHotKey.Designer.cs index 065762a..fdc0dcd 100644 --- a/Source/GrasscutterTools/Pages/PageHotKey.Designer.cs +++ b/Source/GrasscutterTools/Pages/PageHotKey.Designer.cs @@ -45,12 +45,12 @@ // // LvHotKeyList // - resources.ApplyResources(this.LvHotKeyList, "LvHotKeyList"); this.LvHotKeyList.CheckBoxes = true; this.LvHotKeyList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.ColTag, this.ColHotKey, this.ColCommand}); + resources.ApplyResources(this.LvHotKeyList, "LvHotKeyList"); this.LvHotKeyList.HideSelection = false; this.LvHotKeyList.Name = "LvHotKeyList"; this.LvHotKeyList.UseCompatibleStateImageBehavior = false; diff --git a/Source/GrasscutterTools/Pages/PageHotKey.cs b/Source/GrasscutterTools/Pages/PageHotKey.cs index b4038c1..2d43319 100644 --- a/Source/GrasscutterTools/Pages/PageHotKey.cs +++ b/Source/GrasscutterTools/Pages/PageHotKey.cs @@ -177,9 +177,10 @@ namespace GrasscutterTools.Pages return; } - // 必须带功能键 - if (e.Modifiers == Keys.None) - return; + // 可选的功能键 + //// 必须带功能键 + //if (e.Modifiers == Keys.None) + // return; // 必须是组合键 if (e.KeyCode == Keys.ControlKey || e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.Menu) diff --git a/Source/GrasscutterTools/Pages/PageHotKey.resx b/Source/GrasscutterTools/Pages/PageHotKey.resx index e5bcc15..d5f2662 100644 --- a/Source/GrasscutterTools/Pages/PageHotKey.resx +++ b/Source/GrasscutterTools/Pages/PageHotKey.resx @@ -117,268 +117,271 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 0 - - - - 100, 30 + + 标签 - - 3 - - - GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.11.0.0, Culture=neutral, PublicKeyToken=de2b1c089621e923 - - - 212, 213 - - - BtnAddOrUpdate - - - 543, 206 - - - 1 - - - $this - - - System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 387, 206 - - - 165, 23 - - - $this - - - 44, 17 - - - 快捷执行列表 - - - $this - - - 100 - - - 4 - - - 150, 30 - - - TxtHotKey - - - 5 - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - Bottom, Left, Right - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 3 - - - True - - - 0 - - - Bottom, Left - - - $this - - - TxtTag - - - 2 - - - 634, 178 - - - GrpHotKeyList - - - 6 - - - LvHotKeyList - - - ColTag - - - 262, 210 - - - 命令 - - - 119, 23 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - PageHotKey - - - 41, 210 - - - 3, 213 - - - 5 - - - Fill - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - GrpHotKeyList + + 150 快捷键 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 100 - - 3, 19 - - - BtnRemove - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 标签 - - - 640, 200 - - - √ 添加或更新 - - - 7, 17 - - - 150 - - - 快捷键 - - - LblTagLabel - - - True - - - 2 - - - 4 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Bottom, Left, Right - - - 1 - - - Top, Bottom, Left, Right - - - LblHotKeyLabel - - - 标签 - - - ColCommand - - - 0 - - - 32, 17 - - - $this - - - - 删除 - - - Bottom, Right - - - Bottom, Right + + 命令 350 - - $this + + + Fill - + + + 3, 19 + + + 634, 178 + + 0 - - ColHotKey + + LvHotKeyList - - 1 + + System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GrpHotKeyList + + + 0 + + + Top, Bottom, Left, Right 3, 3 - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 640, 200 - - Bottom, Left, Right + + 1 + + + 快捷执行列表 + + + GrpHotKeyList + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this + + 2 + + + Bottom, Right + + + 543, 206 + + + 100, 30 + + + 5 + + + - 删除 + + + BtnRemove + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + Bottom, Right + + + 387, 206 + + + 150, 30 + + + 4 + + + √ 添加或更新 + + + BtnAddOrUpdate + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + Bottom, Left, Right + + + 262, 210 + + + 119, 23 + + + 3 + + + Center + + + TxtHotKey + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + Bottom, Left, Right + + + True + + + 212, 213 + + + 44, 17 + + + 2 + + + 快捷键 + + + LblHotKeyLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + Bottom, Left, Right + + + 41, 210 + + + 165, 23 + + + 1 + + + TxtTag + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + Bottom, Left + + + True + + + 3, 213 + + + 32, 17 + + + 0 + + + 标签 + + + LblTagLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 6 + True + + 7, 17 + + + ColTag + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ColHotKey + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ColCommand + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + PageHotKey + + + GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.11.0.0, Culture=neutral, PublicKeyToken=de2b1c089621e923 + \ No newline at end of file diff --git a/Source/GrasscutterTools/Utils/KeyGo.cs b/Source/GrasscutterTools/Utils/KeyGo.cs index 8be34e1..29e54a2 100644 --- a/Source/GrasscutterTools/Utils/KeyGo.cs +++ b/Source/GrasscutterTools/Utils/KeyGo.cs @@ -120,8 +120,9 @@ namespace GrasscutterTools.Utils } } - if (keyModifiers == AppHotKey.KeyModifiers.None) - throw new InvalidOperationException("功能键不能为空!"); + // 允许功能键为空 + //if (keyModifiers == AppHotKey.KeyModifiers.None) + // throw new InvalidOperationException("功能键不能为空!"); if (keyCode == Keys.None) throw new InvalidOperationException("快捷键不能为空!");