# HG changeset patch
# User moel.mich
# Date 1274826783 0
# Node ID cea5477b4d72d1d27c6500daf6a49defd35155fc
# Parent  76aaf45a01c7108f4febdc5de512bd1dc32e3647
Added an event handler to save the configuration when the user logs off without closing the application first (http://blogs.msdn.com/b/oldnewthing/archive/2008/04/21/8413175.aspx), because FormClosed is not called in that case.
diff -r 76aaf45a01c7 -r cea5477b4d72 GUI/CrashReportForm.cs
--- a/GUI/CrashReportForm.cs	Tue May 25 18:57:28 2010 +0000
+++ b/GUI/CrashReportForm.cs	Tue May 25 22:33:03 2010 +0000
@@ -38,7 +38,6 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
-using System.Data;
 using System.Drawing;
 using System.IO;
 using System.Net;
diff -r 76aaf45a01c7 -r cea5477b4d72 GUI/MainForm.cs
--- a/GUI/MainForm.cs	Tue May 25 18:57:28 2010 +0000
+++ b/GUI/MainForm.cs	Tue May 25 22:33:03 2010 +0000
@@ -173,8 +173,14 @@
 
       // Create a handle, otherwise calling Close() does not fire FormClosed     
       IntPtr handle = Handle;
+
+      // Make sure the settings are saved when the user logs off
+      Microsoft.Win32.SystemEvents.SessionEnded +=
+        delegate(object sender, Microsoft.Win32.SessionEndedEventArgs e) {
+          SaveConfiguration();
+        };
     }
-
+    
     private void SubHardwareAdded(IHardware hardware, Node node) {
       Node hardwareNode = new HardwareNode(hardware);
       node.Nodes.Add(hardwareNode);
@@ -262,8 +268,7 @@
       sensorSystemTray.Redraw();
     }
 
-    private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
-      
+    private void SaveConfiguration() {
       Config.Set(hiddenMenuItem.Name, hiddenMenuItem.Checked);
       Config.Set(plotMenuItem.Name, plotMenuItem.Checked);
 
@@ -274,7 +279,7 @@
 
       Config.Set(startMinMenuItem.Name, startMinMenuItem.Checked);
       Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked);
-      Config.Set(hddMenuItem.Name, hddMenuItem.Checked);   
+      Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
 
       if (WindowState != FormWindowState.Minimized) {
         Config.Set("mainForm.Location.X", Location.X);
@@ -283,12 +288,17 @@
         Config.Set("mainForm.Height", Height);
       }
 
-      foreach (TreeColumn column in treeView.Columns) 
-        Config.Set("treeView.Columns." + column.Header + ".Width", 
+      foreach (TreeColumn column in treeView.Columns)
+        Config.Set("treeView.Columns." + column.Header + ".Width",
           column.Width);
 
+      Config.Save();
+    }
+
+    private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
+      SaveConfiguration();
+
       timer.Enabled = false;
-
       sensorSystemTray.Dispose();
       notifyIcon.Dispose();
       computer.Close();
diff -r 76aaf45a01c7 -r cea5477b4d72 OpenHardwareMonitor.csproj
--- a/OpenHardwareMonitor.csproj	Tue May 25 18:57:28 2010 +0000
+++ b/OpenHardwareMonitor.csproj	Tue May 25 22:33:03 2010 +0000
@@ -52,12 +52,10 @@
     
     
     
-    
     
     
     
     
-    
   
   
     
diff -r 76aaf45a01c7 -r cea5477b4d72 Properties/AssemblyInfo.cs
--- a/Properties/AssemblyInfo.cs	Tue May 25 18:57:28 2010 +0000
+++ b/Properties/AssemblyInfo.cs	Tue May 25 22:33:03 2010 +0000
@@ -69,5 +69,5 @@
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.1.35.0")]
-[assembly: AssemblyFileVersion("0.1.35.0")]
+[assembly: AssemblyVersion("0.1.36.0")]
+[assembly: AssemblyFileVersion("0.1.36.0")]
diff -r 76aaf45a01c7 -r cea5477b4d72 Utilities/Config.cs
--- a/Utilities/Config.cs	Tue May 25 18:57:28 2010 +0000
+++ b/Utilities/Config.cs	Tue May 25 22:33:03 2010 +0000
@@ -60,7 +60,7 @@
         System.Configuration.ConfigurationUserLevel.None);
     }
 
-    ~Config() {
+    private void SaveConfig() {
       string tempName = Path.ChangeExtension(fileName, ".tmp");
 
       if (File.Exists(tempName))
@@ -73,6 +73,10 @@
       } catch (System.Configuration.ConfigurationErrorsException) { }
     }
 
+    public static void Save() {
+      instance.SaveConfig();
+    }
+
     public static Config Settings {
       get {
         return instance;