Fix ever-widening Form1 when form size is restored.

This commit is contained in:
Michael Bucari-Tovo 2025-02-28 12:04:49 -07:00
parent a790c7535c
commit 68cfae1d58
2 changed files with 11 additions and 2 deletions

View File

@ -105,13 +105,14 @@ namespace LibationWinForms
splitContainer1.Panel2Collapsed = false;
processBookQueue1.popoutBtn.Visible = true;
}
Configuration.Instance.SetNonString(splitContainer1.Panel2Collapsed, nameof(splitContainer1.Panel2Collapsed));
toggleQueueHideBtn.Text = splitContainer1.Panel2Collapsed ? "❰❰❰" : "❱❱❱";
}
private void ToggleQueueHideBtn_Click(object sender, EventArgs e)
{
SetQueueCollapseState(!splitContainer1.Panel2Collapsed);
Configuration.Instance.SetNonString(splitContainer1.Panel2Collapsed, nameof(splitContainer1.Panel2Collapsed));
}
private void ProcessBookQueue1_PopOut(object sender, EventArgs e)

View File

@ -17,7 +17,7 @@ namespace LibationWinForms
//Set this size before restoring form size and position
splitContainer1.Panel2MinSize = this.DpiScale(350);
this.RestoreSizeAndLocation(Configuration.Instance);
this.FormClosing += (_, _) => this.SaveSizeAndLocation(Configuration.Instance);
FormClosing += Form1_FormClosing;
// this looks like a perfect opportunity to refactor per below.
// since this loses design-time tooling and internal access, for now I'm opting for partial classes
@ -58,6 +58,14 @@ namespace LibationWinForms
Shown += Form1_Shown;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//Always close the queue before saving the form to prevent
//Form1 from getting excessively wide when it's restored.
SetQueueCollapseState(true);
this.SaveSizeAndLocation(Configuration.Instance);
}
private async void Form1_Shown(object sender, EventArgs e)
{
if (Configuration.Instance.FirstLaunch)