Add HotKey Page (close #190)

This commit is contained in:
2023-07-22 00:10:40 +08:00
parent 9524ea5ab4
commit c82ce1ea35
23 changed files with 1761 additions and 438 deletions

View File

@ -44,6 +44,9 @@ namespace GrasscutterTools.Forms
if (DesignMode) return;
Common.KeyGo = new KeyGo(Handle);
Common.KeyGo.HotKeyTriggerEvent += OnHotKeyTrigger;
try
{
var location = Settings.Default.MainFormLocation;
@ -94,7 +97,21 @@ namespace GrasscutterTools.Forms
ph.OnLanguageChanged = () => FormMain_Load(this, EventArgs.Empty);
var poc = CreatePage<PageOpenCommand>();
poc.ShowTipInRunButton = msg => ShowTip(msg, BtnInvokeOpenCommand);
CreatePage<PageCustomCommands>();
var pcc = CreatePage<PageCustomCommands>();
var phk = CreatePage<PageHotKey>();
pcc.OnAddHotKey = tag =>
{
phk.AddNewHotKey(tag);
// 跳转到快捷键界面
for (var i = 0; i < TCMain.Controls.Count; i++)
{
if (TCMain.Controls[i].Controls[0] == phk)
{
ListPages.SelectedIndex = i;
break;
}
}
};
CreatePage<PageGiveArtifact>();
CreatePage<PageSpawn>();
CreatePage<PageGiveItem>();
@ -126,6 +143,7 @@ namespace GrasscutterTools.Forms
Resources.PageHomeTitle,
Resources.PageOpenCommandTitle,
Resources.PageCustomCommandsTitle,
Resources.PageHotKey,
Resources.PageGetArtifactTitle,
Resources.PageSpawnTitle,
Resources.PageGiveItemTitle,
@ -274,6 +292,33 @@ namespace GrasscutterTools.Forms
#endregion - Init -
#region - HotKey -
/// <summary>
/// 快捷键触发时执行
/// </summary>
private void OnHotKeyTrigger(object sender, HotKeyTriggerEventArgs e)
{
BeginInvoke(new Func<Task>(() => RunRawCommands(e.HotKeyItem.Commands)));
e.Handle = true;
}
private const int WM_HOTKEY = 0x312;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case WM_HOTKEY:
Common.KeyGo.ProcessHotKey(m.WParam.ToInt32());
break;
}
}
#endregion - HotKey -
#region - Command -
/// <summary>
@ -375,10 +420,20 @@ namespace GrasscutterTools.Forms
ShowTip(Resources.CommandContentCannotBeEmpty, CmbCommand);
return;
}
if (cmd.IndexOf('|') == -1)
await RunCommands(FormatCommand(cmd));
else
await RunCommands(cmd.Split('|').Select(FormatCommand).ToArray());
await RunRawCommands(cmd);
}
/// <summary>
/// 运行原始命令
/// </summary>
/// <param name="commands">命令字符串</param>
/// <returns>是否执行成功</returns>
private async Task<bool> RunRawCommands(string commands)
{
if (commands.IndexOf('|') == -1)
return await RunCommands(FormatCommand(commands));
return await RunCommands(commands.Split('|').Select(FormatCommand).ToArray());
}
/// <summary>

View File

@ -219,6 +219,12 @@
<Compile Include="Pages\PageHome.Designer.cs">
<DependentUpon>PageHome.cs</DependentUpon>
</Compile>
<Compile Include="Pages\PageHotKey.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Pages\PageHotKey.Designer.cs">
<DependentUpon>PageHotKey.cs</DependentUpon>
</Compile>
<Compile Include="Pages\PageMail.cs">
<SubType>UserControl</SubType>
</Compile>
@ -284,7 +290,7 @@
<Compile Include="Utils\ArtifactUtils.cs" />
<Compile Include="Utils\Common.cs" />
<Compile Include="Utils\GuiRedirect.cs" />
<Compile Include="Utils\HotKey.cs" />
<Compile Include="Utils\KeyGo.cs" />
<Compile Include="Utils\HotKeyItem.cs" />
<Compile Include="Utils\HttpHelper.cs" />
<Compile Include="Utils\Logger.cs" />
@ -490,6 +496,18 @@
<EmbeddedResource Include="Pages\PageHome.zh-TW.resx">
<DependentUpon>PageHome.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Pages\PageHotKey.en-US.resx">
<DependentUpon>PageHotKey.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Pages\PageHotKey.resx">
<DependentUpon>PageHotKey.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Pages\PageHotKey.ru-RU.resx">
<DependentUpon>PageHotKey.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Pages\PageHotKey.zh-TW.resx">
<DependentUpon>PageHotKey.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Pages\PageMail.en-US.resx">
<DependentUpon>PageMail.cs</DependentUpon>
</EmbeddedResource>

View File

@ -38,6 +38,7 @@
this.BtnRemoveCustomCommand = new System.Windows.Forms.Button();
this.BtnSaveCustomCommand = new System.Windows.Forms.Button();
this.TxtCustomName = new System.Windows.Forms.TextBox();
this.BtnAddHotKey = new System.Windows.Forms.Button();
this.GrpCustomCommands.SuspendLayout();
this.SuspendLayout();
//
@ -100,10 +101,18 @@
this.TxtCustomName.Name = "TxtCustomName";
this.TxtCustomName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtCustomName_KeyDown);
//
// BtnAddHotKey
//
resources.ApplyResources(this.BtnAddHotKey, "BtnAddHotKey");
this.BtnAddHotKey.Name = "BtnAddHotKey";
this.BtnAddHotKey.UseVisualStyleBackColor = true;
this.BtnAddHotKey.Click += new System.EventHandler(this.BtnAddHotKey_Click);
//
// PageCustomCommands
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.BtnAddHotKey);
this.Controls.Add(this.BtnExportCustomCommands);
this.Controls.Add(this.BtnLoadCustomCommands);
this.Controls.Add(this.LblCustomName);
@ -130,5 +139,6 @@
private System.Windows.Forms.Button BtnRemoveCustomCommand;
private System.Windows.Forms.Button BtnSaveCustomCommand;
private System.Windows.Forms.TextBox TxtCustomName;
private System.Windows.Forms.Button BtnAddHotKey;
}
}

View File

@ -248,5 +248,18 @@ namespace GrasscutterTools.Pages
LoadCustomCommandControls(Resources.CustomCommands);
}
}
public Action<string> OnAddHotKey;
private void BtnAddHotKey_Click(object sender, EventArgs e)
{
var name = TxtCustomName.Text.Trim();
if (string.IsNullOrEmpty(name))
{
MessageBox.Show(Resources.CommandTagCannotBeEmpty, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
OnAddHotKey?.Invoke(name);
}
}
}

View File

@ -119,19 +119,19 @@
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="BtnExportCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>573, 209</value>
<value>573, 206</value>
</data>
<data name="BtnExportCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 23</value>
<value>70, 30</value>
</data>
<data name="BtnExportCustomCommands.Text" xml:space="preserve">
<value>Export</value>
</data>
<data name="BtnLoadCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>497, 209</value>
<value>497, 206</value>
</data>
<data name="BtnLoadCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 23</value>
<value>70, 30</value>
</data>
<data name="BtnLoadCustomCommands.Text" xml:space="preserve">
<value>Load</value>
@ -155,24 +155,30 @@
<value>Restore</value>
</data>
<data name="BtnRemoveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>421, 209</value>
<value>421, 206</value>
</data>
<data name="BtnRemoveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 23</value>
<value>70, 30</value>
</data>
<data name="BtnRemoveCustomCommand.Text" xml:space="preserve">
<value>× Delete</value>
</data>
<data name="BtnSaveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>345, 209</value>
<value>345, 206</value>
</data>
<data name="BtnSaveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>70, 23</value>
<value>70, 30</value>
</data>
<data name="BtnSaveCustomCommand.Text" xml:space="preserve">
<value>√ Save</value>
</data>
<data name="TxtCustomName.Size" type="System.Drawing.Size, System.Drawing">
<value>298, 23</value>
<value>217, 23</value>
</data>
<data name="BtnAddHotKey.Location" type="System.Drawing.Point, System.Drawing">
<value>264, 206</value>
</data>
<data name="BtnAddHotKey.Text" xml:space="preserve">
<value>HotKey</value>
</data>
</root>

View File

@ -117,283 +117,310 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="BtnExportCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="BtnExportCustomCommands.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="BtnExportCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>590, 209</value>
</data>
<data name="BtnExportCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 23</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="BtnExportCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
</data>
<data name="BtnExportCustomCommands.Text" xml:space="preserve">
<value>导出</value>
</data>
<data name="&gt;&gt;BtnExportCustomCommands.Name" xml:space="preserve">
<value>BtnExportCustomCommands</value>
</data>
<data name="&gt;&gt;BtnExportCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BtnExportCustomCommands.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;BtnExportCustomCommands.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="BtnLoadCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="BtnLoadCustomCommands.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="BtnLoadCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>534, 209</value>
</data>
<data name="BtnLoadCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 23</value>
</data>
<data name="BtnLoadCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="BtnLoadCustomCommands.Text" xml:space="preserve">
<value>载入</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.Name" xml:space="preserve">
<value>BtnLoadCustomCommands</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="LblCustomName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
</data>
<data name="LblCustomName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="LblCustomName.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="LblCustomName.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 212</value>
</data>
<data name="LblCustomName.Size" type="System.Drawing.Size, System.Drawing">
<value>32, 17</value>
</data>
<data name="LblCustomName.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="LblCustomName.Text" xml:space="preserve">
<value>标签</value>
</data>
<data name="&gt;&gt;LblCustomName.Name" xml:space="preserve">
<value>LblCustomName</value>
</data>
<data name="&gt;&gt;LblCustomName.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;LblCustomName.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;LblCustomName.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="GrpCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="LnkResetCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="LnkResetCustomCommands.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="LnkResetCustomCommands.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="LnkResetCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>602, -1</value>
</data>
<data name="LnkResetCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>32, 17</value>
</data>
<data name="LnkResetCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
<data name="BtnAddHotKey.Text" xml:space="preserve">
<value>快捷键</value>
</data>
<data name="LnkResetCustomCommands.Text" xml:space="preserve">
<value>重置</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.Name" xml:space="preserve">
<value>LnkResetCustomCommands</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.Parent" xml:space="preserve">
<value>GrpCustomCommands</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="FLPCustomCommands.AutoScroll" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="FLPCustomCommands.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="FLPCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 19</value>
</data>
<data name="FLPCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>634, 174</value>
</data>
<data name="FLPCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.Name" xml:space="preserve">
<value>FLPCustomCommands</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.Parent" xml:space="preserve">
<value>GrpCustomCommands</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="GrpCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 7</value>
</data>
<data name="GrpCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>640, 196</value>
</data>
<data name="GrpCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="GrpCustomCommands.Text" xml:space="preserve">
<value>列表</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.Name" xml:space="preserve">
<value>GrpCustomCommands</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="BtnRemoveCustomCommand.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="BtnRemoveCustomCommand.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="BtnRemoveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>468, 209</value>
</data>
<data name="BtnRemoveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>60, 23</value>
</data>
<data name="BtnRemoveCustomCommand.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="BtnRemoveCustomCommand.Text" xml:space="preserve">
<value>× 删除</value>
</data>
<data name="&gt;&gt;BtnRemoveCustomCommand.Name" xml:space="preserve">
<value>BtnRemoveCustomCommand</value>
</data>
<data name="&gt;&gt;BtnRemoveCustomCommand.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BtnRemoveCustomCommand.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;BtnRemoveCustomCommand.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="BtnSaveCustomCommand.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="BtnSaveCustomCommand.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="BtnSaveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>402, 209</value>
</data>
<data name="BtnSaveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>60, 23</value>
</data>
<data name="BtnSaveCustomCommand.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="BtnSaveCustomCommand.Text" xml:space="preserve">
<value>√ 保存</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.Name" xml:space="preserve">
<value>BtnSaveCustomCommand</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="TxtCustomName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
</data>
<data name="TxtCustomName.Location" type="System.Drawing.Point, System.Drawing">
<value>41, 209</value>
</data>
<data name="TxtCustomName.Size" type="System.Drawing.Size, System.Drawing">
<value>355, 23</value>
</data>
<data name="TxtCustomName.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="&gt;&gt;TxtCustomName.Name" xml:space="preserve">
<value>TxtCustomName</value>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.11.0.0, Culture=neutral, PublicKeyToken=de2b1c089621e923</value>
</data>
<data name="&gt;&gt;TxtCustomName.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="BtnSaveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>405, 206</value>
</data>
<data name="BtnRemoveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>471, 206</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="BtnLoadCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="LnkResetCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>32, 17</value>
</data>
<data name="&gt;&gt;BtnExportCustomCommands.Name" xml:space="preserve">
<value>BtnExportCustomCommands</value>
</data>
<data name="BtnLoadCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>537, 206</value>
</data>
<data name="LnkResetCustomCommands.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="GrpCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>
<data name="BtnRemoveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>60, 30</value>
</data>
<data name="TxtCustomName.Location" type="System.Drawing.Point, System.Drawing">
<value>41, 210</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="LnkResetCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="&gt;&gt;BtnExportCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="BtnExportCustomCommands.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.Name" xml:space="preserve">
<value>BtnLoadCustomCommands</value>
</data>
<data name="BtnRemoveCustomCommand.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="FLPCustomCommands.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="LblCustomName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="BtnAddHotKey.TabIndex" type="System.Int32, mscorlib">
<value>15</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;LblCustomName.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="TxtCustomName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
</data>
<data name="BtnExportCustomCommands.Text" xml:space="preserve">
<value>导出</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.Name" xml:space="preserve">
<value>LnkResetCustomCommands</value>
</data>
<data name="LblCustomName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="LnkResetCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="&gt;&gt;BtnRemoveCustomCommand.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="LblCustomName.Size" type="System.Drawing.Size, System.Drawing">
<value>32, 17</value>
</data>
<data name="BtnLoadCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 30</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="BtnLoadCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="LblCustomName.Text" xml:space="preserve">
<value>标签</value>
</data>
<data name="&gt;&gt;TxtCustomName.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;TxtCustomName.ZOrder" xml:space="preserve">
<data name="BtnSaveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>60, 30</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.Name" xml:space="preserve">
<value>GrpCustomCommands</value>
</data>
<data name="&gt;&gt;BtnAddHotKey.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="&gt;&gt;BtnRemoveCustomCommand.Name" xml:space="preserve">
<value>BtnRemoveCustomCommand</value>
</data>
<data name="BtnAddHotKey.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="BtnExportCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 30</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.Name" xml:space="preserve">
<value>FLPCustomCommands</value>
</data>
<data name="BtnExportCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
</data>
<data name="BtnExportCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>593, 206</value>
</data>
<data name="&gt;&gt;BtnLoadCustomCommands.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="FLPCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="LblCustomName.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="FLPCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 19</value>
</data>
<data name="TxtCustomName.Size" type="System.Drawing.Size, System.Drawing">
<value>277, 23</value>
</data>
<data name="LnkResetCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>602, -1</value>
</data>
<data name="GrpCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="BtnSaveCustomCommand.Text" xml:space="preserve">
<value>√ 保存</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.Parent" xml:space="preserve">
<value>GrpCustomCommands</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>7, 17</value>
</data>
<data name="BtnAddHotKey.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 30</value>
</data>
<data name="&gt;&gt;LblCustomName.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="&gt;&gt;TxtCustomName.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="&gt;&gt;BtnRemoveCustomCommand.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="BtnAddHotKey.Location" type="System.Drawing.Point, System.Drawing">
<value>324, 206</value>
</data>
<data name="&gt;&gt;FLPCustomCommands.Parent" xml:space="preserve">
<value>GrpCustomCommands</value>
</data>
<data name="&gt;&gt;LnkResetCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="LnkResetCustomCommands.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="BtnExportCustomCommands.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="FLPCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>634, 178</value>
</data>
<data name="GrpCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>640, 200</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>PageCustomCommands</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.7.4.0, Culture=neutral, PublicKeyToken=de2b1c089621e923</value>
<data name="GrpCustomCommands.Text" xml:space="preserve">
<value>列表</value>
</data>
<data name="BtnRemoveCustomCommand.Text" xml:space="preserve">
<value>× 删除</value>
</data>
<data name="&gt;&gt;LblCustomName.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BtnExportCustomCommands.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="&gt;&gt;TxtCustomName.Name" xml:space="preserve">
<value>TxtCustomName</value>
</data>
<data name="TxtCustomName.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="FLPCustomCommands.AutoScroll" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="&gt;&gt;GrpCustomCommands.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="BtnSaveCustomCommand.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="BtnSaveCustomCommand.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="BtnRemoveCustomCommand.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="&gt;&gt;BtnAddHotKey.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="LblCustomName.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 213</value>
</data>
<data name="&gt;&gt;BtnAddHotKey.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;BtnSaveCustomCommand.Name" xml:space="preserve">
<value>BtnSaveCustomCommand</value>
</data>
<data name="BtnRemoveCustomCommand.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="BtnLoadCustomCommands.Text" xml:space="preserve">
<value>载入</value>
</data>
<data name="GrpCustomCommands.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="BtnSaveCustomCommand.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="LblCustomName.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="BtnLoadCustomCommands.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="&gt;&gt;LblCustomName.Name" xml:space="preserve">
<value>LblCustomName</value>
</data>
<data name="&gt;&gt;BtnAddHotKey.Name" xml:space="preserve">
<value>BtnAddHotKey</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -119,19 +119,19 @@
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="BtnExportCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>545, 209</value>
<value>548, 206</value>
</data>
<data name="BtnExportCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>95, 23</value>
<value>95, 30</value>
</data>
<data name="BtnExportCustomCommands.Text" xml:space="preserve">
<value>Экспорт</value>
</data>
<data name="BtnLoadCustomCommands.Location" type="System.Drawing.Point, System.Drawing">
<value>444, 209</value>
<value>447, 206</value>
</data>
<data name="BtnLoadCustomCommands.Size" type="System.Drawing.Size, System.Drawing">
<value>95, 23</value>
<value>95, 30</value>
</data>
<data name="BtnLoadCustomCommands.Text" xml:space="preserve">
<value>Загрузить</value>
@ -155,24 +155,33 @@
<value>Сбросить</value>
</data>
<data name="BtnRemoveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>343, 209</value>
<value>346, 206</value>
</data>
<data name="BtnRemoveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>95, 23</value>
<value>95, 30</value>
</data>
<data name="BtnRemoveCustomCommand.Text" xml:space="preserve">
<value>x Удалить</value>
</data>
<data name="BtnSaveCustomCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>242, 209</value>
<value>245, 206</value>
</data>
<data name="BtnSaveCustomCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>95, 23</value>
<value>95, 30</value>
</data>
<data name="BtnSaveCustomCommand.Text" xml:space="preserve">
<value>√ Сохранить</value>
</data>
<data name="TxtCustomName.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 23</value>
<value>120, 23</value>
</data>
<data name="BtnAddHotKey.Location" type="System.Drawing.Point, System.Drawing">
<value>167, 206</value>
</data>
<data name="BtnAddHotKey.Size" type="System.Drawing.Size, System.Drawing">
<value>72, 30</value>
</data>
<data name="BtnAddHotKey.Text" xml:space="preserve">
<value>Горячая.</value>
</data>
</root>

View File

@ -129,4 +129,7 @@
<data name="BtnRemoveCustomCommand.Text" xml:space="preserve">
<value>× 刪除</value>
</data>
<data name="BtnAddHotKey.Text" xml:space="preserve">
<value>快捷鍵</value>
</data>
</root>

View File

@ -0,0 +1,149 @@
namespace GrasscutterTools.Pages
{
partial class PageHotKey
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PageHotKey));
this.LvHotKeyList = new System.Windows.Forms.ListView();
this.ColTag = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ColHotKey = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ColCommand = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.GrpHotKeyList = new System.Windows.Forms.GroupBox();
this.BtnRemove = new System.Windows.Forms.Button();
this.BtnAddOrUpdate = new System.Windows.Forms.Button();
this.TxtHotKey = new System.Windows.Forms.TextBox();
this.LblHotKeyLabel = new System.Windows.Forms.Label();
this.TxtTag = new System.Windows.Forms.TextBox();
this.LblTagLabel = new System.Windows.Forms.Label();
this.GrpHotKeyList.SuspendLayout();
this.SuspendLayout();
//
// 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});
this.LvHotKeyList.HideSelection = false;
this.LvHotKeyList.Name = "LvHotKeyList";
this.LvHotKeyList.UseCompatibleStateImageBehavior = false;
this.LvHotKeyList.View = System.Windows.Forms.View.Details;
this.LvHotKeyList.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.LvHotKeyList_ItemCheck);
this.LvHotKeyList.SelectedIndexChanged += new System.EventHandler(this.LvHotKeyList_SelectedIndexChanged);
//
// ColTag
//
resources.ApplyResources(this.ColTag, "ColTag");
//
// ColHotKey
//
resources.ApplyResources(this.ColHotKey, "ColHotKey");
//
// ColCommand
//
resources.ApplyResources(this.ColCommand, "ColCommand");
//
// GrpHotKeyList
//
resources.ApplyResources(this.GrpHotKeyList, "GrpHotKeyList");
this.GrpHotKeyList.Controls.Add(this.LvHotKeyList);
this.GrpHotKeyList.Name = "GrpHotKeyList";
this.GrpHotKeyList.TabStop = false;
//
// BtnRemove
//
resources.ApplyResources(this.BtnRemove, "BtnRemove");
this.BtnRemove.Name = "BtnRemove";
this.BtnRemove.UseVisualStyleBackColor = true;
this.BtnRemove.Click += new System.EventHandler(this.BtnRemove_Click);
//
// BtnAddOrUpdate
//
resources.ApplyResources(this.BtnAddOrUpdate, "BtnAddOrUpdate");
this.BtnAddOrUpdate.Name = "BtnAddOrUpdate";
this.BtnAddOrUpdate.UseVisualStyleBackColor = true;
this.BtnAddOrUpdate.Click += new System.EventHandler(this.BtnAddOrUpdate_Click);
//
// TxtHotKey
//
resources.ApplyResources(this.TxtHotKey, "TxtHotKey");
this.TxtHotKey.BackColor = System.Drawing.Color.White;
this.TxtHotKey.Name = "TxtHotKey";
this.TxtHotKey.ReadOnly = true;
this.TxtHotKey.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtHotKey_KeyDown);
//
// LblHotKeyLabel
//
resources.ApplyResources(this.LblHotKeyLabel, "LblHotKeyLabel");
this.LblHotKeyLabel.Name = "LblHotKeyLabel";
//
// TxtTag
//
resources.ApplyResources(this.TxtTag, "TxtTag");
this.TxtTag.Name = "TxtTag";
//
// LblTagLabel
//
resources.ApplyResources(this.LblTagLabel, "LblTagLabel");
this.LblTagLabel.Name = "LblTagLabel";
//
// PageHotKey
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.BtnRemove);
this.Controls.Add(this.BtnAddOrUpdate);
this.Controls.Add(this.GrpHotKeyList);
this.Controls.Add(this.TxtHotKey);
this.Controls.Add(this.TxtTag);
this.Controls.Add(this.LblHotKeyLabel);
this.Controls.Add(this.LblTagLabel);
this.Name = "PageHotKey";
this.GrpHotKeyList.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListView LvHotKeyList;
private System.Windows.Forms.ColumnHeader ColHotKey;
private System.Windows.Forms.ColumnHeader ColTag;
private System.Windows.Forms.ColumnHeader ColCommand;
private System.Windows.Forms.GroupBox GrpHotKeyList;
private System.Windows.Forms.Button BtnRemove;
private System.Windows.Forms.Button BtnAddOrUpdate;
private System.Windows.Forms.TextBox TxtHotKey;
private System.Windows.Forms.Label LblHotKeyLabel;
private System.Windows.Forms.TextBox TxtTag;
private System.Windows.Forms.Label LblTagLabel;
}
}

View File

@ -0,0 +1,242 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using GrasscutterTools.Properties;
using GrasscutterTools.Utils;
using Newtonsoft.Json;
namespace GrasscutterTools.Pages
{
internal partial class PageHotKey : BasePage
{
private const string TAG = nameof(PageHotKey);
public PageHotKey()
{
InitializeComponent();
LvHotKeyList.FullRowSelect = true;
if (DesignMode) return;
InitHotKeys();
}
/// <summary>
/// 热键保存位置
/// </summary>
private readonly string HotKeysFilePath = Common.GetAppDataFile("HotKeys.json");
/// <summary>
/// 热键配置是否存在更改
/// </summary>
private bool HotKeysChanged;
/// <summary>
/// 初始化快捷键
/// </summary>
private void InitHotKeys()
{
if (!File.Exists(HotKeysFilePath))
return;
try
{
Logger.I(TAG, "Loading HotKey json file from: " + HotKeysFilePath);
Common.KeyGo.Items = JsonConvert.DeserializeObject<List<HotKeyItem>>(File.ReadAllText(HotKeysFilePath));
LvHotKeyList.Items.AddRange(Common.KeyGo.Items.Select(HotKeyItemToViewItem).ToArray());
Logger.I(TAG, "Start Register All HotKeys");
Common.KeyGo.RegAllKey();
}
catch (Exception ex)
{
Logger.W(TAG, "Parsing HotKeys.json failed.", ex);
}
}
/// <summary>
/// 关闭时触发,取消注册并保存更改
/// </summary>
public override void OnClosed()
{
Logger.I(TAG, "Cancel all HotKeys");
Common.KeyGo.UnRegAllKey();
if (!HotKeysChanged) return;
Logger.I(TAG, "Save all HotKeys to: " + HotKeysFilePath);
File.WriteAllText(HotKeysFilePath, JsonConvert.SerializeObject(Common.KeyGo.Items));
}
/// <summary>
/// 将实体转为视图对象
/// </summary>
private static ListViewItem HotKeyItemToViewItem(HotKeyItem item) => new ListViewItem(new[]
{
item.Tag,
item.HotKey,
item.Commands
}) { Checked = item.IsEnabled };
/// <summary>
/// 列表选中项改变时触发
/// </summary>
private void LvHotKeyList_SelectedIndexChanged(object sender, EventArgs e)
{
if (LvHotKeyList.SelectedIndices.Count == 0) return;
var i = LvHotKeyList.SelectedIndices[0];
var hotKeyItem = Common.KeyGo.Items[i];
TxtTag.Text = hotKeyItem.Tag;
TxtHotKey.Text = hotKeyItem.HotKey;
SetCommand(hotKeyItem.Commands);
}
/// <summary>
/// 点击添加或更新按钮时触发
/// </summary>
private void BtnAddOrUpdate_Click(object sender, EventArgs e)
{
var tag = TxtTag.Text.Trim();
var commands = GetCommand();
var hotKey = TxtHotKey.Text;
if (string.IsNullOrEmpty(tag) || string.IsNullOrEmpty(commands) || string.IsNullOrEmpty(hotKey))
{
MessageBox.Show(Resources.EmptyInputTip, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var i = Common.KeyGo.Items.FindIndex(it => it.Tag == tag);
if (i == -1)
{
var item = new HotKeyItem
{
Tag = tag,
Commands = commands,
HotKey = hotKey
};
Logger.I(TAG, $"New HotKey item [{hotKey}]");
Common.KeyGo.AddHotKey(item);
LvHotKeyList.Items.Add(HotKeyItemToViewItem(item));
}
else
{
var item = Common.KeyGo.Items[i];
item.Commands = commands;
if (item.HotKey != hotKey)
{
Logger.I(TAG, $"Update HotKey from [{item.HotKey}] to [{hotKey}]");
item.HotKey = hotKey;
Common.KeyGo.ChangeHotKey(item);
}
LvHotKeyList.Items[i] = HotKeyItemToViewItem(item);
}
HotKeysChanged = true;
}
catch (Exception ex)
{
Logger.E(TAG, "AddOrUpdate HotKey failed", ex);
MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// 点击移除按钮时触发
/// </summary>
private void BtnRemove_Click(object sender, EventArgs e)
{
try
{
var tag = TxtTag.Text.Trim();
var i = Common.KeyGo.Items.FindIndex(it => it.Tag == tag);
if (i == -1) return;
var item = Common.KeyGo.Items[i];
Logger.I(TAG, $"Remove HotKey [{item.HotKey}] \"{item.Tag}\"");
Common.KeyGo.DelHotKey(item);
LvHotKeyList.Items.RemoveAt(i);
HotKeysChanged = true;
}
catch (Exception ex)
{
Logger.E(TAG, "Remove HotKey failed", ex);
MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// 快捷键选项卡按键按下时触发
/// </summary>
private void TxtHotKey_KeyDown(object sender, KeyEventArgs e)
{
// ESC键清空当前快捷键
if (e.KeyCode == Keys.Escape)
{
TxtHotKey.Text = "";
return;
}
// 必须带功能键
if (e.Modifiers == Keys.None)
return;
// 必须是组合键
if (e.KeyCode == Keys.ControlKey || e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.Menu)
return;
var text = e.KeyCode.ToString();
if (e.Control)
text = "Ctrl + " + text;
if (e.Shift)
text = "Shift + " + text;
if (e.Alt)
text = "Alt + " + text;
TxtHotKey.Text = text;
}
/// <summary>
/// 列表中的复选框改变时触发
/// </summary>
private void LvHotKeyList_ItemCheck(object sender, ItemCheckEventArgs e)
{
var isEnable = e.NewValue == CheckState.Checked;
try
{
var item = Common.KeyGo.Items[e.Index];
if (isEnable)
{
// 尝试注册快捷键
Logger.I(TAG, $"Register hotKey [{item.HotKey}] as \"{item.Tag}\"");
Common.KeyGo.RegKey(item);
}
else
{
// 尝试注销快捷键
Logger.I(TAG, $"Cancel hotKey [{item.HotKey}]");
Common.KeyGo.UnRegKey(item);
}
// 更新使能状态
item.IsEnabled = isEnable;
}
catch (Exception ex)
{
// 如果操作失败,还原选项,禁止设置
e.NewValue = e.CurrentValue;
Logger.E(TAG, (isEnable ? "Enable" : "Disable") +" HotKey failed", ex);
MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// 添加热键快捷设置方法
/// </summary>
/// <param name="tag">标签名</param>
public void AddNewHotKey(string tag)
{
TxtHotKey.Tag = "";
TxtTag.Text = tag;
}
}
}

View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ColTag.Text" xml:space="preserve">
<value>Tag</value>
</data>
<data name="ColHotKey.Text" xml:space="preserve">
<value>HotKey</value>
</data>
<data name="ColCommand.Text" xml:space="preserve">
<value>Commands</value>
</data>
<data name="GrpHotKeyList.Text" xml:space="preserve">
<value>HotKeys</value>
</data>
<data name="BtnRemove.Text" xml:space="preserve">
<value>- Remove</value>
</data>
<data name="BtnAddOrUpdate.Text" xml:space="preserve">
<value>√ AddOrUpdate</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="LblHotKeyLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 17</value>
</data>
<data name="LblHotKeyLabel.Text" xml:space="preserve">
<value>HotKey</value>
</data>
<data name="LblTagLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>30, 17</value>
</data>
<data name="LblTagLabel.Text" xml:space="preserve">
<value>Tag</value>
</data>
</root>

View File

@ -0,0 +1,384 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="&gt;&gt;BtnRemove.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="BtnRemove.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 30</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="TxtHotKey.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.11.0.0, Culture=neutral, PublicKeyToken=de2b1c089621e923</value>
</data>
<data name="LblHotKeyLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>212, 213</value>
</data>
<data name="&gt;&gt;BtnAddOrUpdate.Name" xml:space="preserve">
<value>BtnAddOrUpdate</value>
</data>
<data name="BtnRemove.Location" type="System.Drawing.Point, System.Drawing">
<value>543, 206</value>
</data>
<data name="TxtTag.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;BtnRemove.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;LvHotKeyList.Type" xml:space="preserve">
<value>System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="BtnAddOrUpdate.Location" type="System.Drawing.Point, System.Drawing">
<value>387, 206</value>
</data>
<data name="TxtTag.Size" type="System.Drawing.Size, System.Drawing">
<value>165, 23</value>
</data>
<data name="&gt;&gt;BtnAddOrUpdate.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="LblHotKeyLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>44, 17</value>
</data>
<data name="GrpHotKeyList.Text" xml:space="preserve">
<value>快捷执行列表</value>
</data>
<data name="&gt;&gt;LblTagLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="ColHotKey.Width" type="System.Int32, mscorlib">
<value>100</value>
</data>
<data name="&gt;&gt;TxtTag.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="BtnAddOrUpdate.Size" type="System.Drawing.Size, System.Drawing">
<value>150, 30</value>
</data>
<data name="&gt;&gt;TxtHotKey.Name" xml:space="preserve">
<value>TxtHotKey</value>
</data>
<data name="&gt;&gt;LblHotKeyLabel.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="&gt;&gt;ColCommand.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="TxtTag.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
</data>
<data name="&gt;&gt;ColTag.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ColHotKey.Type" xml:space="preserve">
<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;TxtHotKey.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="LblTagLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="LvHotKeyList.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="LblTagLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
</data>
<data name="&gt;&gt;LblHotKeyLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;TxtTag.Name" xml:space="preserve">
<value>TxtTag</value>
</data>
<data name="&gt;&gt;GrpHotKeyList.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="LvHotKeyList.Size" type="System.Drawing.Size, System.Drawing">
<value>634, 178</value>
</data>
<data name="&gt;&gt;LvHotKeyList.Parent" xml:space="preserve">
<value>GrpHotKeyList</value>
</data>
<data name="&gt;&gt;LblTagLabel.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="&gt;&gt;LvHotKeyList.Name" xml:space="preserve">
<value>LvHotKeyList</value>
</data>
<data name="&gt;&gt;ColTag.Name" xml:space="preserve">
<value>ColTag</value>
</data>
<data name="TxtHotKey.Location" type="System.Drawing.Point, System.Drawing">
<value>262, 210</value>
</data>
<data name="ColCommand.Text" xml:space="preserve">
<value>命令</value>
</data>
<data name="TxtHotKey.Size" type="System.Drawing.Size, System.Drawing">
<value>119, 23</value>
</data>
<data name="&gt;&gt;BtnRemove.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>PageHotKey</value>
</data>
<data name="TxtTag.Location" type="System.Drawing.Point, System.Drawing">
<value>41, 210</value>
</data>
<data name="LblTagLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 213</value>
</data>
<data name="BtnRemove.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="LvHotKeyList.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="&gt;&gt;GrpHotKeyList.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;GrpHotKeyList.Name" xml:space="preserve">
<value>GrpHotKeyList</value>
</data>
<data name="ColHotKey.Text" xml:space="preserve">
<value>快捷键</value>
</data>
<data name="&gt;&gt;TxtTag.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="LvHotKeyList.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 19</value>
</data>
<data name="&gt;&gt;BtnRemove.Name" xml:space="preserve">
<value>BtnRemove</value>
</data>
<data name="&gt;&gt;TxtHotKey.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="LblTagLabel.Text" xml:space="preserve">
<value>标签</value>
</data>
<data name="GrpHotKeyList.Size" type="System.Drawing.Size, System.Drawing">
<value>640, 200</value>
</data>
<data name="BtnAddOrUpdate.Text" xml:space="preserve">
<value>√ 添加或更新</value>
</data>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>7, 17</value>
</data>
<data name="ColTag.Width" type="System.Int32, mscorlib">
<value>150</value>
</data>
<data name="LblHotKeyLabel.Text" xml:space="preserve">
<value>快捷键</value>
</data>
<data name="&gt;&gt;LblTagLabel.Name" xml:space="preserve">
<value>LblTagLabel</value>
</data>
<data name="LblHotKeyLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="LblHotKeyLabel.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="BtnAddOrUpdate.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="&gt;&gt;LblHotKeyLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;LblTagLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="LblHotKeyLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
</data>
<data name="&gt;&gt;BtnAddOrUpdate.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="GrpHotKeyList.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="&gt;&gt;LblHotKeyLabel.Name" xml:space="preserve">
<value>LblHotKeyLabel</value>
</data>
<data name="ColTag.Text" xml:space="preserve">
<value>标签</value>
</data>
<data name="&gt;&gt;ColCommand.Name" xml:space="preserve">
<value>ColCommand</value>
</data>
<data name="&gt;&gt;LvHotKeyList.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="LblTagLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>32, 17</value>
</data>
<data name="&gt;&gt;TxtTag.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="BtnRemove.Text" xml:space="preserve">
<value>- 删除</value>
</data>
<data name="BtnRemove.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="BtnAddOrUpdate.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="ColCommand.Width" type="System.Int32, mscorlib">
<value>350</value>
</data>
<data name="&gt;&gt;TxtHotKey.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="LblTagLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;ColHotKey.Name" xml:space="preserve">
<value>ColHotKey</value>
</data>
<data name="GrpHotKeyList.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="GrpHotKeyList.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>
<data name="&gt;&gt;BtnAddOrUpdate.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="TxtHotKey.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
</data>
<data name="&gt;&gt;GrpHotKeyList.Parent" xml:space="preserve">
<value>$this</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ColTag.Text" xml:space="preserve">
<value>Tag</value>
</data>
<data name="ColHotKey.Text" xml:space="preserve">
<value>HotKey</value>
</data>
<data name="ColCommand.Text" xml:space="preserve">
<value>Commands</value>
</data>
<data name="GrpHotKeyList.Text" xml:space="preserve">
<value>HotKeys</value>
</data>
<data name="BtnRemove.Text" xml:space="preserve">
<value>- Remove</value>
</data>
<data name="BtnAddOrUpdate.Text" xml:space="preserve">
<value>√ AddOrUpdate</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="LblHotKeyLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 17</value>
</data>
<data name="LblHotKeyLabel.Text" xml:space="preserve">
<value>HotKey</value>
</data>
<data name="LblTagLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>30, 17</value>
</data>
<data name="LblTagLabel.Text" xml:space="preserve">
<value>Tag</value>
</data>
</root>

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ColTag.Text" xml:space="preserve">
<value>標籤</value>
</data>
<data name="ColHotKey.Text" xml:space="preserve">
<value>快捷鍵</value>
</data>
<data name="GrpHotKeyList.Text" xml:space="preserve">
<value>快捷執行列表</value>
</data>
<data name="BtnRemove.Text" xml:space="preserve">
<value>- 刪除</value>
</data>
<data name="LblHotKeyLabel.Text" xml:space="preserve">
<value>快捷鍵</value>
</data>
<data name="LblTagLabel.Text" xml:space="preserve">
<value>標籤</value>
</data>
</root>

View File

@ -78,7 +78,7 @@ namespace GrasscutterTools.Pages
try
{
Tasks = JsonConvert.DeserializeObject<List<LoopTask>>(File.ReadAllText(TasksJsonPath));
ListTasks.Items.AddRange(Tasks.Select(t => TaskToViewItem(t)).ToArray());
ListTasks.Items.AddRange(Tasks.Select(TaskToViewItem).ToArray());
}
catch (Exception ex)
{

View File

@ -88,45 +88,42 @@ namespace GrasscutterTools.Properties {
}
/// <summary>
/// 查找类似 //Activity ids-3.7 by dplek
///// Activity
///2001:1.1未归的熄星
///2002:1.3海灯节
///2003:1.4风花节
///2004:1.5导能原盘-诸论
///2005:1.6盛夏!海岛?大冒险!
///2006:2.0谒索雷痕
///2007:2.1韶光抚月
///2008:2.2雾海悬谜境
///2009:2.3皑尘与雪影
///2010:2.4飞彩镌流年
///2011:2.5三界路飨祭
///2012:2.6堇庭华彩
///2013:2.7荒梦藏虞渊
///2014:2.8远海诗夏游纪
///2015:3.0雕琢童心
///2016:3.1杯中遥吟之歌
///2017:3.2智巧灵蕈大竞逐
///2018:3.3秋津森夜试胆会
///2019:3.4磬弦奏华夜
///2020:3.5风花的呼吸
///2021:3.6盛典与慧业
///2022:3.7决战!召唤之巅!
///// 1.0
///1001:海灯节
///5001:元素烘炉test
///5002:且试身手
///5003:百货奇货
///// 1.1
///5004:映天之章
///5005:元素烘炉
///5006:佳肴尚温
///5007:飞行挑战
///5009:古闻之章(钟离传说-1
///5010:鲸天之章(公子传说-1
///// 1.2
///3001:白垩与黑龙
///5 [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// 查找类似 //Activity ids-3.8 by dplek
///// Activity
///2001:1.1未归的熄星
///2002:1.3海灯节
///2003:1.4风花节
///2004:1.5导能原盘-诸论
///2005:1.6盛夏!海岛?大冒险!
///2006:2.0谒索雷痕
///2007:2.1韶光抚月
///2008:2.2雾海悬谜境
///2009:2.3皑尘与雪影
///2010:2.4飞彩镌流年
///2011:2.5三界路飨祭
///2012:2.6堇庭华彩
///2013:2.7荒梦藏虞渊
///2014:2.8远海诗夏游纪
///2015:3.0雕琢童心
///2016:3.1杯中遥吟之歌
///2017:3.2智巧灵蕈大竞逐
///2018:3.3秋津森夜试胆会
///2019:3.4磬弦奏华夜
///2020:3.5风花的呼吸
///2021:3.6盛典与慧业
///2022:3.7决战!召唤之巅!
///// 1.0
///1001:海灯节
///5001:元素烘炉test
///5002:且试身手
///5003:百货奇货
///// 1.1
///5004:映天之章
///5005:元素烘炉
///5006:佳肴尚温
///5007:飞行挑战
///5009:古闻之章(钟离传说-1
///50 [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string Activity {
get {
@ -638,28 +635,40 @@ namespace GrasscutterTools.Properties {
}
/// <summary>
/// 查找类似 1:TEST_Chest_CutSence
///2:TEST_GoddessLvUp_CutSence
///3:Cs_Scene_GoddessUpgrade_01
///4:Cs_Scene_DungeonGate_01
///5:Cs_Scene_DungeonGate_02
///6:Cs_Scene_GoddessActive
///7:Cs_Scene_GoddessUpgradeDefault
///8:Cs_Scene_DragonNestSealGate
///9:Cs_MDAQ501_SwordBreak01
///200201:Cs_MDAQ071_DvalinCombat2
///10:特瓦林秘境解锁1
///11:特瓦林秘境解锁2
///12:特瓦林秘境解锁3
///13:Cs_RecyclableDungeon_GetReward
///14:Cs_Scene_GoddessUpgradeDefault_SFX
///15:Cs_Scene_Goddess_Chord_Wind
///16:Cs_Scene_Goddess_Chord_Rock
/// 查找类似 1:[测试]空画面
///2:[测试]空画面
///3:[疑似剧情]风起地七天神像激活
///4:未知秘境内某门开启
///5:未知秘境内某门开启
///6:无画面(UI会闪一下)
///7:未知区域画面旋转
///8:进入风龙废墟秘境
///9:达达乌帕谷剑屏障解锁
///200201:[剧情]蒙德主线特瓦林最后战斗 秘境ID:20018(测试)或20025(正式)
///10:风龙废墟解除三层封印1
///11:风龙废墟解除三层封印2
///12:风龙废墟解除三层封印3
///13:秘境奖励领取时
///14:未知区域画面旋转
///15:不明地下视角
///16:不明地下视角
///17:忍冬之树普通
///18:忍冬之树形态1
///19:忍冬之树1升级2
///20:忍冬之树形态2
/// [字符串的其余部分被截断]&quot;; 的本地化字符串。
///21:忍冬之树2升级3
///22:雪山冰本进入时
///23:不明地下视角
///24:不明地下视角
///25:稻妻神樱树远景
///26:[世界任务]神樱大祓净化进度1
///27:[世界任务]神樱大祓净化进度2
///28:[世界任务]神樱大祓净化进度3
///29:[世界任务]神樱大祓净化进度4
///30:[世界任务]神樱大祓净化进度5
///31:稻妻荒海机关解锁
///32:稻妻八酝岛阵代屋敷秘境解锁
///33:稻妻清籁岛木 [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string Cutscene {
get {
@ -1151,6 +1160,15 @@ namespace GrasscutterTools.Properties {
}
}
/// <summary>
/// 查找类似 快捷键 的本地化字符串。
/// </summary>
internal static string PageHotKey {
get {
return ResourceManager.GetString("PageHotKey", resourceCulture);
}
}
/// <summary>
/// 查找类似 邮件 的本地化字符串。
/// </summary>

View File

@ -360,4 +360,7 @@ Improvement suggestions have been submitted, please use caution to send emails t
<data name="Activity" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\en-us\Activity.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="PageHotKey" xml:space="preserve">
<value>HotKey</value>
</data>
</root>

View File

@ -372,4 +372,7 @@
<data name="Cutscene" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\zh-cn\Cutscene.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="PageHotKey" xml:space="preserve">
<value>快捷键</value>
</data>
</root>

View File

@ -348,4 +348,7 @@
<data name="Activity" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ru-ru\Activity.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="PageHotKey" xml:space="preserve">
<value>Горячая клавиша</value>
</data>
</root>

View File

@ -354,4 +354,7 @@
<data name="Activity" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\zh-tw\Activity.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="PageHotKey" xml:space="preserve">
<value>快捷鍵</value>
</data>
</root>

View File

@ -41,5 +41,8 @@ namespace GrasscutterTools.Utils
{
return Path.Combine(AppDataFolder, filename);
}
public static KeyGo KeyGo { get; set; }
}
}

View File

@ -1,5 +1,5 @@
using System;
using System.Xml.Serialization;
using Newtonsoft.Json;
namespace GrasscutterTools.Utils
{
@ -14,8 +14,8 @@ namespace GrasscutterTools.Utils
/// <value>
/// The hot key identifier.
/// </value>
[XmlIgnore]
public int HotKeyID { get; set; }
[JsonIgnore]
public int HotKeyId { get; set; }
/// <summary>
/// Gets or sets the name of the Tag.
@ -48,30 +48,6 @@ namespace GrasscutterTools.Utils
/// <value>
/// <c>true</c> if enabled; otherwise, <c>false</c>.
/// </value>
public bool Enabled { get; set; } = true;
/// <summary>
/// Gets or sets the trigger counter.
/// </summary>
/// <value>
/// The trigger counter.
/// </value>
public int TriggerCounter { get; set; }
/// <summary>
/// Gets or sets the creation time.
/// </summary>
/// <value>
/// The creation time.
/// </value>
public DateTime CreationTime { get; set; } = DateTime.Now;
/// <summary>
/// Gets or sets the last modified time.
/// </summary>
/// <value>
/// The last modified time.
/// </value>
public DateTime LastModifiedTime { get; set; } = DateTime.Now;
public bool IsEnabled { get; set; } = true;
}
}

View File

@ -1,82 +1,40 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace GrasscutterTools.Utils
{
/// <summary>
/// KeyGo 核心功能类
/// </summary>
public class KeyGo
internal class KeyGo
{
public KeyGo(IntPtr formHandle)
{
FormHandle = formHandle;
}
#region Member
private static int _RegMaxID;
private static int _regMaxId;
[XmlIgnore]
public IntPtr FormHandle { get; set; }
private readonly IntPtr FormHandle;
public List<HotKeyItem> Items { get; set; } = new List<HotKeyItem>();
#endregion Member
#region FILE IO
/// <summary>
/// Loads the XML.
/// </summary>
/// <param name="filePath">The file path.</param>
/// <returns></returns>
public static KeyGo LoadXml(string filePath)
{
KeyGo data = null;
if (File.Exists(filePath))
{
XmlSerializer formatter = new XmlSerializer(typeof(KeyGo));
using (var stream = File.OpenRead(filePath))
{
if (stream.Length > 0)
{
data = formatter.Deserialize(stream) as KeyGo;
}
}
}
return data;
}
/// <summary>
/// Saves the XML.
/// </summary>
/// <param name="filePath">The file path.</param>
public void SaveXml(string filePath)
{
if (!File.Exists(filePath))
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
XmlSerializer formatter = new XmlSerializer(typeof(KeyGo));
using (var stream = File.Create(filePath))
{
formatter.Serialize(stream, this);
}
}
#endregion FILE IO
#region HotKey Register
/// <summary>
/// Regs all key.
/// 注册所有启用的快捷键
/// </summary>
public void RegAllKey()
{
foreach (var item in Items)
foreach (var item in Items.Where(item => item.IsEnabled))
{
if (!item.Enabled)
continue;
try
{
RegKey(item);
@ -89,7 +47,7 @@ namespace GrasscutterTools.Utils
}
/// <summary>
/// Uns the reg all key.
/// 取消所有快捷键
/// </summary>
public void UnRegAllKey()
{
@ -107,7 +65,7 @@ namespace GrasscutterTools.Utils
}
/// <summary>
/// 注册热键 - 成功后,会设置 HotKeyID
/// 注册热键 - 成功后,会设置 HotKeyId
/// </summary>
/// <param name="item">The item.</param>
/// <exception cref="ArgumentNullException">
@ -128,17 +86,17 @@ namespace GrasscutterTools.Utils
throw new ArgumentNullException(nameof(item.HotKey), "热键不能为空!");
// 如果注册过该热键ID不为0。卸载热键会将ID置零。
if (item.HotKeyID != 0)
if (item.HotKeyId != 0)
return;
int id = Interlocked.Increment(ref _RegMaxID);
var id = Interlocked.Increment(ref _regMaxId);
var keys = item.HotKey.Split('+');
Keys keyCode = Keys.None;
AppHotKey.KeyModifiers keyModifiers = AppHotKey.KeyModifiers.None;
var keyCode = Keys.None;
var keyModifiers = AppHotKey.KeyModifiers.None;
foreach (var key in keys)
{
switch (key.ToLower())
switch (key.Trim().ToLower())
{
case "ctrl":
keyModifiers |= AppHotKey.KeyModifiers.Ctrl;
@ -168,11 +126,11 @@ namespace GrasscutterTools.Utils
throw new InvalidOperationException("快捷键不能为空!");
AppHotKey.RegKey(FormHandle, id, keyModifiers, keyCode);
item.HotKeyID = id;
item.HotKeyId = id;
}
/// <summary>
/// 注销热键 - 完成后,会清零 HotKeyID
/// 注销热键 - 完成后,会清零 HotKeyId
/// </summary>
/// <param name="item">The item.</param>
/// <exception cref="ArgumentNullException">item</exception>
@ -180,11 +138,11 @@ namespace GrasscutterTools.Utils
{
if (item is null)
throw new ArgumentNullException(nameof(item));
if (item.HotKeyID == 0)
if (item.HotKeyId == 0)
return;
AppHotKey.UnRegKey(FormHandle, item.HotKeyID);
item.HotKeyID = 0;
AppHotKey.UnRegKey(FormHandle, item.HotKeyId);
item.HotKeyId = 0;
}
#endregion HotKey Register
@ -207,15 +165,15 @@ namespace GrasscutterTools.Utils
/// Processes the hotkey.
/// </summary>
/// <param name="hotKey_id">The hot key identifier.</param>
public void ProcessHotkey(int hotKey_id)
public void ProcessHotKey(int hotKeyId)
{
var hotkey = Items.Find(k => k.HotKeyID == hotKey_id);
if (hotkey != null)
var hotKey = Items.Find(k => k.HotKeyId == hotKeyId);
if (hotKey != null)
{
//Console.WriteLine($"ID:{hotkey.HotKeyID} Keys:{hotkey.HotKey} ProcessName:{hotkey.ProcessName}\nStartupPath:{hotkey.StartupPath}");
++hotkey.TriggerCounter;
//Console.WriteLine($"ID:{hotKey.HotKeyId} Keys:{hotKey.HotKey} ProcessName:{hotKey.ProcessName}\nStartupPath:{hotKey.StartupPath}");
//++hotKey.TriggerCounter;
// 触发事件,若被外部处理,则内部不再执行
OnHotKeyTrigger(hotkey);
OnHotKeyTrigger(hotKey);
}
}
@ -242,7 +200,7 @@ namespace GrasscutterTools.Utils
if (item is null)
throw new ArgumentNullException(nameof(item));
if (item.Enabled)
if (item.IsEnabled)
RegKey(item);
Items.Add(item);
}
@ -256,7 +214,7 @@ namespace GrasscutterTools.Utils
if (item is null)
throw new ArgumentNullException(nameof(item));
if (item.HotKeyID != 0)
if (item.HotKeyId != 0)
UnRegKey(item);
Items.Remove(item);
}
@ -271,9 +229,9 @@ namespace GrasscutterTools.Utils
throw new ArgumentNullException(nameof(item));
// 重新注册
if (item.HotKeyID != 0)
if (item.HotKeyId != 0)
UnRegKey(item);
if (item.Enabled)
if (item.IsEnabled)
RegKey(item);
}