From 68cfae1d58852fee399340b6ecc368d897635192 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Fri, 28 Feb 2025 12:04:49 -0700 Subject: [PATCH] Fix ever-widening Form1 when form size is restored. --- Source/LibationWinForms/Form1.ProcessQueue.cs | 3 ++- Source/LibationWinForms/Form1.cs | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/LibationWinForms/Form1.ProcessQueue.cs b/Source/LibationWinForms/Form1.ProcessQueue.cs index ab9c1147..306aba39 100644 --- a/Source/LibationWinForms/Form1.ProcessQueue.cs +++ b/Source/LibationWinForms/Form1.ProcessQueue.cs @@ -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) diff --git a/Source/LibationWinForms/Form1.cs b/Source/LibationWinForms/Form1.cs index 50232c5c..33b06b0e 100644 --- a/Source/LibationWinForms/Form1.cs +++ b/Source/LibationWinForms/Form1.cs @@ -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)