Update Save Window location and size

This commit is contained in:
2022-11-08 20:22:44 +08:00
parent a4cf38dd71
commit e7347a1a26
4 changed files with 62 additions and 2 deletions

View File

@ -52,6 +52,12 @@
<setting name="ShopJsonPath" serializeAs="String"> <setting name="ShopJsonPath" serializeAs="String">
<value /> <value />
</setting> </setting>
<setting name="MainFormLocation" serializeAs="String">
<value>0, 0</value>
</setting>
<setting name="MainFormSize" serializeAs="String">
<value>0, 0</value>
</setting>
</GrasscutterTools.Properties.Settings> </GrasscutterTools.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@ -60,6 +60,9 @@ namespace GrasscutterTools.Forms
#endif #endif
} }
/// <summary>
/// 窗体载入时触发(切换语言时会重新载入)
/// </summary>
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
Text += " - by jie65535 - v" + AppVersion.ToString(3); Text += " - by jie65535 - v" + AppVersion.ToString(3);
@ -85,8 +88,26 @@ namespace GrasscutterTools.Forms
ChangeTPArtifact(); ChangeTPArtifact();
} }
/// <summary>
/// 第一次显示窗体时触发
/// </summary>
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);
}
/// <summary>
/// 窗口关闭后触发
/// </summary>
private void FormMain_FormClosed(object sender, FormClosedEventArgs e) private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
{ {
// 保存当前设置
SaveSettings(); SaveSettings();
} }
@ -112,8 +133,8 @@ namespace GrasscutterTools.Forms
try try
{ {
// 恢复自动复制选项状态 // 恢复自动复制选项状态
ChkAutoCopy.Checked = Settings.Default.AutoCopy; ChkAutoCopy.Checked = Settings.Default.AutoCopy;
// 初始化首页设置 // 初始化首页设置
InitHomeSettings(); InitHomeSettings();
@ -142,7 +163,10 @@ namespace GrasscutterTools.Forms
{ {
try try
{ {
// 记录界面状态
Settings.Default.AutoCopy = ChkAutoCopy.Checked; Settings.Default.AutoCopy = ChkAutoCopy.Checked;
Settings.Default.MainFormLocation = Location;
Settings.Default.MainFormSize = Size;
// 保存自定义命令 // 保存自定义命令
SaveCustomCommands(); SaveCustomCommands();

View File

@ -190,5 +190,29 @@ namespace GrasscutterTools.Properties {
this["ShopJsonPath"] = value; 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;
}
}
} }
} }

View File

@ -44,5 +44,11 @@
<Setting Name="ShopJsonPath" Type="System.String" Scope="User"> <Setting Name="ShopJsonPath" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="MainFormLocation" Type="System.Drawing.Point" Scope="User">
<Value Profile="(Default)">0, 0</Value>
</Setting>
<Setting Name="MainFormSize" Type="System.Drawing.Size" Scope="User">
<Value Profile="(Default)">0, 0</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>