From c873b66cd90e13bac11379c0ef6de97263ee1725 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Wed, 28 Mar 2018 00:47:40 -0700 Subject: [PATCH] Update main form to save and restore split distance. (#35) Restoring split distance also requires restoring the window bounds earlier during initialization. --- GUI/MainForm.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index 9340faf..64f9c82 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -101,6 +101,15 @@ namespace OpenHardwareMonitor.GUI { this.Font = SystemFonts.MessageBoxFont; treeView.Font = SystemFonts.MessageBoxFont; + // Set the bounds immediately, so that our child components can be + // properly placed. + this.Bounds = new Rectangle { + X = settings.GetValue("mainForm.Location.X", Location.X), + Y = settings.GetValue("mainForm.Location.Y", Location.Y), + Width = settings.GetValue("mainForm.Width", 470), + Height = settings.GetValue("mainForm.Height", 640) + }; + plotPanel = new PlotPanel(settings, unitManager); plotPanel.Font = SystemFonts.MessageBoxFont; plotPanel.Dock = DockStyle.Fill; @@ -311,6 +320,7 @@ namespace OpenHardwareMonitor.GUI { }; InitializePlotForm(); + InitializeSplitter(); startupMenuItem.Visible = startupManager.IsAvailable; @@ -335,6 +345,13 @@ namespace OpenHardwareMonitor.GUI { }; } + private void InitializeSplitter() { + splitContainer.SplitterDistance = settings.GetValue("splitContainer.SplitterDistance", 400); + splitContainer.SplitterMoved += delegate (object sender, System.Windows.Forms.SplitterEventArgs e) { + settings.SetValue("splitContainer.SplitterDistance", splitContainer.SplitterDistance); + }; + } + private void InitializePlotForm() { plotForm = new Form(); plotForm.FormBorderStyle = FormBorderStyle.SizableToolWindow;