GUI/MainForm.cs
changeset 128 cea5477b4d72
parent 126 2354fdb91ac4
child 133 9ad699538c89
     1.1 --- a/GUI/MainForm.cs	Tue May 25 18:57:28 2010 +0000
     1.2 +++ b/GUI/MainForm.cs	Tue May 25 22:33:03 2010 +0000
     1.3 @@ -173,8 +173,14 @@
     1.4  
     1.5        // Create a handle, otherwise calling Close() does not fire FormClosed     
     1.6        IntPtr handle = Handle;
     1.7 +
     1.8 +      // Make sure the settings are saved when the user logs off
     1.9 +      Microsoft.Win32.SystemEvents.SessionEnded +=
    1.10 +        delegate(object sender, Microsoft.Win32.SessionEndedEventArgs e) {
    1.11 +          SaveConfiguration();
    1.12 +        };
    1.13      }
    1.14 -
    1.15 +    
    1.16      private void SubHardwareAdded(IHardware hardware, Node node) {
    1.17        Node hardwareNode = new HardwareNode(hardware);
    1.18        node.Nodes.Add(hardwareNode);
    1.19 @@ -262,8 +268,7 @@
    1.20        sensorSystemTray.Redraw();
    1.21      }
    1.22  
    1.23 -    private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
    1.24 -      
    1.25 +    private void SaveConfiguration() {
    1.26        Config.Set(hiddenMenuItem.Name, hiddenMenuItem.Checked);
    1.27        Config.Set(plotMenuItem.Name, plotMenuItem.Checked);
    1.28  
    1.29 @@ -274,7 +279,7 @@
    1.30  
    1.31        Config.Set(startMinMenuItem.Name, startMinMenuItem.Checked);
    1.32        Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked);
    1.33 -      Config.Set(hddMenuItem.Name, hddMenuItem.Checked);   
    1.34 +      Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
    1.35  
    1.36        if (WindowState != FormWindowState.Minimized) {
    1.37          Config.Set("mainForm.Location.X", Location.X);
    1.38 @@ -283,12 +288,17 @@
    1.39          Config.Set("mainForm.Height", Height);
    1.40        }
    1.41  
    1.42 -      foreach (TreeColumn column in treeView.Columns) 
    1.43 -        Config.Set("treeView.Columns." + column.Header + ".Width", 
    1.44 +      foreach (TreeColumn column in treeView.Columns)
    1.45 +        Config.Set("treeView.Columns." + column.Header + ".Width",
    1.46            column.Width);
    1.47  
    1.48 +      Config.Save();
    1.49 +    }
    1.50 +
    1.51 +    private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
    1.52 +      SaveConfiguration();
    1.53 +
    1.54        timer.Enabled = false;
    1.55 -
    1.56        sensorSystemTray.Dispose();
    1.57        notifyIcon.Dispose();
    1.58        computer.Close();