mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-08-02 16:59:14 +08:00
Optimized restore window state
This commit is contained in:
parent
63ebaa5df8
commit
db13f82bfc
@ -41,10 +41,33 @@ namespace GrasscutterTools.Forms
|
||||
Icon = Resources.IconGrasscutter;
|
||||
|
||||
if (DesignMode) return;
|
||||
// 初始化页面
|
||||
InitPages();
|
||||
// 加载设置
|
||||
LoadSettings();
|
||||
|
||||
try
|
||||
{
|
||||
// 还原窗体位置
|
||||
if (Settings.Default.MainFormLocation != default)
|
||||
{
|
||||
StartPosition = FormStartPosition.Manual;
|
||||
Location = Settings.Default.MainFormLocation;
|
||||
Console.WriteLine("Restore window location: " + Location.ToString());
|
||||
}
|
||||
|
||||
// 还原窗体大小
|
||||
if (Settings.Default.MainFormSize != default)
|
||||
{
|
||||
Size = Settings.Default.MainFormSize;
|
||||
Console.WriteLine("Restore window size: " + Size.ToString());
|
||||
}
|
||||
|
||||
// 初始化页面
|
||||
InitPages();
|
||||
// 恢复自动复制选项状态
|
||||
ChkAutoCopy.Checked = Settings.Default.AutoCopy;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(Resources.SettingLoadError + ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
Console.WriteLine("FormMain ctor completed");
|
||||
}
|
||||
|
||||
@ -93,22 +116,6 @@ namespace GrasscutterTools.Forms
|
||||
return page;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 载入设置
|
||||
/// </summary>
|
||||
private void LoadSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 恢复自动复制选项状态
|
||||
ChkAutoCopy.Checked = Settings.Default.AutoCopy;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(Resources.SettingLoadError + ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗体载入时触发(切换语言时会重新载入)
|
||||
/// </summary>
|
||||
@ -131,26 +138,6 @@ namespace GrasscutterTools.Forms
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 第一次显示窗体时触发
|
||||
/// </summary>
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
// 还原窗体位置
|
||||
if (Settings.Default.MainFormLocation != default)
|
||||
{
|
||||
Location = Settings.Default.MainFormLocation;
|
||||
Console.WriteLine("Restore window location: " + Location.ToString());
|
||||
}
|
||||
// 还原窗体大小
|
||||
if (Settings.Default.MainFormSize != default)
|
||||
{
|
||||
Size = Settings.Default.MainFormSize;
|
||||
Console.WriteLine("Restore window size: " + Size.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口关闭后触发
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user