From e7347a1a268f98e510036a4fc76a1770d6595436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E5=82=91?= Date: Tue, 8 Nov 2022 20:22:44 +0800 Subject: [PATCH] Update Save Window location and size --- Source/GrasscutterTools/App.config | 6 ++++ Source/GrasscutterTools/Forms/FormMain.cs | 28 +++++++++++++++++-- .../Properties/Settings.Designer.cs | 24 ++++++++++++++++ .../Properties/Settings.settings | 6 ++++ 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/Source/GrasscutterTools/App.config b/Source/GrasscutterTools/App.config index 9b49c11..6e22014 100644 --- a/Source/GrasscutterTools/App.config +++ b/Source/GrasscutterTools/App.config @@ -52,6 +52,12 @@ + + 0, 0 + + + 0, 0 + \ No newline at end of file diff --git a/Source/GrasscutterTools/Forms/FormMain.cs b/Source/GrasscutterTools/Forms/FormMain.cs index f87c32d..35c2f72 100644 --- a/Source/GrasscutterTools/Forms/FormMain.cs +++ b/Source/GrasscutterTools/Forms/FormMain.cs @@ -60,6 +60,9 @@ namespace GrasscutterTools.Forms #endif } + /// + /// 窗体载入时触发(切换语言时会重新载入) + /// private void FormMain_Load(object sender, EventArgs e) { Text += " - by jie65535 - v" + AppVersion.ToString(3); @@ -85,8 +88,26 @@ namespace GrasscutterTools.Forms ChangeTPArtifact(); } + /// + /// 第一次显示窗体时触发 + /// + protected override void OnShown(EventArgs e) + { + // 还原窗体位置 + if (Settings.Default.MainFormLocation != default) + Location = Settings.Default.MainFormLocation; + // 还原窗体大小 + if (Settings.Default.MainFormSize != default) + Size = Settings.Default.MainFormSize; + base.OnShown(e); + } + + /// + /// 窗口关闭后触发 + /// private void FormMain_FormClosed(object sender, FormClosedEventArgs e) { + // 保存当前设置 SaveSettings(); } @@ -112,8 +133,8 @@ namespace GrasscutterTools.Forms try { // 恢复自动复制选项状态 - ChkAutoCopy.Checked = Settings.Default.AutoCopy; - + ChkAutoCopy.Checked = Settings.Default.AutoCopy; + // 初始化首页设置 InitHomeSettings(); @@ -142,7 +163,10 @@ namespace GrasscutterTools.Forms { try { + // 记录界面状态 Settings.Default.AutoCopy = ChkAutoCopy.Checked; + Settings.Default.MainFormLocation = Location; + Settings.Default.MainFormSize = Size; // 保存自定义命令 SaveCustomCommands(); diff --git a/Source/GrasscutterTools/Properties/Settings.Designer.cs b/Source/GrasscutterTools/Properties/Settings.Designer.cs index 98b6ef1..c55d6ff 100644 --- a/Source/GrasscutterTools/Properties/Settings.Designer.cs +++ b/Source/GrasscutterTools/Properties/Settings.Designer.cs @@ -190,5 +190,29 @@ namespace GrasscutterTools.Properties { this["ShopJsonPath"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0, 0")] + public global::System.Drawing.Point MainFormLocation { + get { + return ((global::System.Drawing.Point)(this["MainFormLocation"])); + } + set { + this["MainFormLocation"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0, 0")] + public global::System.Drawing.Size MainFormSize { + get { + return ((global::System.Drawing.Size)(this["MainFormSize"])); + } + set { + this["MainFormSize"] = value; + } + } } } diff --git a/Source/GrasscutterTools/Properties/Settings.settings b/Source/GrasscutterTools/Properties/Settings.settings index d5bcfdd..cb4375f 100644 --- a/Source/GrasscutterTools/Properties/Settings.settings +++ b/Source/GrasscutterTools/Properties/Settings.settings @@ -44,5 +44,11 @@ + + 0, 0 + + + 0, 0 + \ No newline at end of file