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.
1.1 --- a/GUI/MainForm.Designer.cs Thu Nov 11 20:48:19 2010 +0000
1.2 +++ b/GUI/MainForm.Designer.cs Thu Nov 11 21:22:24 2010 +0000
1.3 @@ -467,6 +467,8 @@
1.4 this.Text = "Open Hardware Monitor";
1.5 this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
1.6 this.Load += new System.EventHandler(this.MainForm_Load);
1.7 + this.ResizeEnd += new System.EventHandler(this.MainForm_MoveOrResize);
1.8 + this.Move += new System.EventHandler(this.MainForm_MoveOrResize);
1.9 this.splitContainer.Panel1.ResumeLayout(false);
1.10 this.splitContainer.Panel2.ResumeLayout(false);
1.11 this.splitContainer.ResumeLayout(false);
2.1 --- a/GUI/MainForm.cs Thu Nov 11 20:48:19 2010 +0000
2.2 +++ b/GUI/MainForm.cs Thu Nov 11 21:22:24 2010 +0000
2.3 @@ -338,13 +338,6 @@
2.4 }
2.5
2.6 private void SaveConfiguration() {
2.7 - if (WindowState != FormWindowState.Minimized) {
2.8 - settings.SetValue("mainForm.Location.X", Bounds.X);
2.9 - settings.SetValue("mainForm.Location.Y", Bounds.Y);
2.10 - settings.SetValue("mainForm.Width", Bounds.Width);
2.11 - settings.SetValue("mainForm.Height", Bounds.Height);
2.12 - }
2.13 -
2.14 foreach (TreeColumn column in treeView.Columns)
2.15 settings.SetValue("treeView.Columns." + column.Header + ".Width",
2.16 column.Width);
2.17 @@ -559,5 +552,14 @@
2.18 sensor.ResetMax();
2.19 }));
2.20 }
2.21 +
2.22 + private void MainForm_MoveOrResize(object sender, EventArgs e) {
2.23 + if (WindowState != FormWindowState.Minimized) {
2.24 + settings.SetValue("mainForm.Location.X", Bounds.X);
2.25 + settings.SetValue("mainForm.Location.Y", Bounds.Y);
2.26 + settings.SetValue("mainForm.Width", Bounds.Width);
2.27 + settings.SetValue("mainForm.Height", Bounds.Height);
2.28 + }
2.29 + }
2.30 }
2.31 }