# HG changeset patch # User moel.mich # Date 1289510544 0 # Node ID 52007c404f3241550930bb48bc649ed214fb88e3 # Parent 631ab73d1ae125bcc08bd2b8677ecdec21f33bf8 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. diff -r 631ab73d1ae1 -r 52007c404f32 GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Thu Nov 11 20:48:19 2010 +0000 +++ b/GUI/MainForm.Designer.cs Thu Nov 11 21:22:24 2010 +0000 @@ -467,6 +467,8 @@ 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 -r 631ab73d1ae1 -r 52007c404f32 GUI/MainForm.cs --- a/GUI/MainForm.cs Thu Nov 11 20:48:19 2010 +0000 +++ b/GUI/MainForm.cs Thu Nov 11 21:22:24 2010 +0000 @@ -338,13 +338,6 @@ } 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 @@ 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); + } + } } }