From 7ee8cea14ef32becbcc732ccc4ae684da289b8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Thu, 11 Nov 2010 21:22:24 +0000 Subject: [PATCH] Fixed a problem, where the MainForm location and size was lost when the application is started minimized and exited without ever showing the form. This caused MainForm_Load to be never called (location and size was not loaded), but the default size and location were still saved. The new implementation only saves the location and size when one of the two is changed. --- GUI/MainForm.Designer.cs | 2 ++ GUI/MainForm.cs | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/GUI/MainForm.Designer.cs b/GUI/MainForm.Designer.cs index 3f88cb0..3d2b7ec 100644 --- a/GUI/MainForm.Designer.cs +++ b/GUI/MainForm.Designer.cs @@ -467,6 +467,8 @@ namespace OpenHardwareMonitor.GUI { this.Text = "Open Hardware Monitor"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed); this.Load += new System.EventHandler(this.MainForm_Load); + this.ResizeEnd += new System.EventHandler(this.MainForm_MoveOrResize); + this.Move += new System.EventHandler(this.MainForm_MoveOrResize); this.splitContainer.Panel1.ResumeLayout(false); this.splitContainer.Panel2.ResumeLayout(false); this.splitContainer.ResumeLayout(false); diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index a52700a..56f7d98 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -338,13 +338,6 @@ namespace OpenHardwareMonitor.GUI { } private void SaveConfiguration() { - if (WindowState != FormWindowState.Minimized) { - settings.SetValue("mainForm.Location.X", Bounds.X); - settings.SetValue("mainForm.Location.Y", Bounds.Y); - settings.SetValue("mainForm.Width", Bounds.Width); - settings.SetValue("mainForm.Height", Bounds.Height); - } - foreach (TreeColumn column in treeView.Columns) settings.SetValue("treeView.Columns." + column.Header + ".Width", column.Width); @@ -559,5 +552,14 @@ namespace OpenHardwareMonitor.GUI { sensor.ResetMax(); })); } + + private void MainForm_MoveOrResize(object sender, EventArgs e) { + if (WindowState != FormWindowState.Minimized) { + settings.SetValue("mainForm.Location.X", Bounds.X); + settings.SetValue("mainForm.Location.Y", Bounds.Y); + settings.SetValue("mainForm.Width", Bounds.Width); + settings.SetValue("mainForm.Height", Bounds.Height); + } + } } }