# HG changeset patch
# User moel.mich
# Date 1266609007 0
# Node ID 898935080fd64c6ab5571106609759d144ec2a37
# Parent  f940fe2a7c2b12bc30e01e25300fdf003366b771
New option to start the application minimized.

diff -r f940fe2a7c2b -r 898935080fd6 GUI/MainForm.Designer.cs
--- a/GUI/MainForm.Designer.cs	Fri Feb 19 18:33:08 2010 +0000
+++ b/GUI/MainForm.Designer.cs	Fri Feb 19 19:50:07 2010 +0000
@@ -94,6 +94,7 @@
       this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
       this.plotMenuItem = new System.Windows.Forms.ToolStripMenuItem();
       this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.startMinMenuItem = new System.Windows.Forms.ToolStripMenuItem();
       this.minTrayMenuItem = new System.Windows.Forms.ToolStripMenuItem();
       this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
       this.hddMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -101,12 +102,12 @@
       this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
       this.timer = new System.Windows.Forms.Timer(this.components);
       this.splitContainer = new System.Windows.Forms.SplitContainer();
+      this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel();
       this.notifyContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
       this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
       this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
       this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
       this.sensorContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
-      this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel();
       this.columnsContextMenuStrip.SuspendLayout();
       this.menuStrip.SuspendLayout();
       this.splitContainer.Panel1.SuspendLayout();
@@ -411,6 +412,7 @@
       // optionsToolStripMenuItem
       // 
       this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.startMinMenuItem,
             this.minTrayMenuItem,
             this.toolStripMenuItem3,
             this.hddMenuItem});
@@ -418,6 +420,13 @@
       this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
       this.optionsToolStripMenuItem.Text = "Options";
       // 
+      // startMinimizedMenuItem
+      // 
+      this.startMinMenuItem.CheckOnClick = true;
+      this.startMinMenuItem.Name = "startMinimizedMenuItem";
+      this.startMinMenuItem.Size = new System.Drawing.Size(166, 22);
+      this.startMinMenuItem.Text = "Start Minimized";
+      // 
       // minTrayMenuItem
       // 
       this.minTrayMenuItem.Checked = true;
@@ -480,6 +489,16 @@
       this.splitContainer.SplitterWidth = 3;
       this.splitContainer.TabIndex = 3;
       // 
+      // plotPanel
+      // 
+      this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+      this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F);
+      this.plotPanel.Location = new System.Drawing.Point(0, 0);
+      this.plotPanel.Name = "plotPanel";
+      this.plotPanel.Size = new System.Drawing.Size(478, 198);
+      this.plotPanel.TabIndex = 0;
+      // 
       // notifyContextMenuStrip
       // 
       this.notifyContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -514,16 +533,6 @@
       this.sensorContextMenuStrip.Name = "sensorContextMenuStrip";
       this.sensorContextMenuStrip.Size = new System.Drawing.Size(61, 4);
       // 
-      // plotPanel
-      // 
-      this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
-      this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill;
-      this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F);
-      this.plotPanel.Location = new System.Drawing.Point(0, 0);
-      this.plotPanel.Name = "plotPanel";
-      this.plotPanel.Size = new System.Drawing.Size(478, 198);
-      this.plotPanel.TabIndex = 0;
-      // 
       // MainForm
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@@ -597,6 +606,7 @@
     private System.Windows.Forms.ToolStripMenuItem minTrayMenuItem;
     private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
     private System.Windows.Forms.ContextMenuStrip sensorContextMenuStrip;
+    private System.Windows.Forms.ToolStripMenuItem startMinMenuItem;
   }
 }
 
diff -r f940fe2a7c2b -r 898935080fd6 GUI/MainForm.cs
--- a/GUI/MainForm.cs	Fri Feb 19 18:33:08 2010 +0000
+++ b/GUI/MainForm.cs	Fri Feb 19 19:50:07 2010 +0000
@@ -134,6 +134,7 @@
       maxMenuItem.Checked = Config.Get(maxMenuItem.Name, true);
       limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false);
 
+      startMinMenuItem.Checked = Config.Get(startMinMenuItem.Name, false); 
       minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true);
       hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true);
 
@@ -143,7 +144,18 @@
       tempMenuItem.Checked = Config.Get(tempMenuItem.Name, true);
       fansMenuItem.Checked = Config.Get(fansMenuItem.Name, true);
      
-      timer.Enabled = true;   
+      timer.Enabled = true;
+
+      if (startMinMenuItem.Checked) {
+        if (minTrayMenuItem.Checked) {
+          notifyIcon.Visible = true;
+        } else {
+          WindowState = FormWindowState.Minimized;
+          Show();
+        }
+      } else {
+        Show();
+      }
     }
 
     private void HardwareAdded(IHardware hardware) {
@@ -238,6 +250,7 @@
       Config.Set(maxMenuItem.Name, maxMenuItem.Checked);
       Config.Set(limitMenuItem.Name, limitMenuItem.Checked);
 
+      Config.Set(startMinMenuItem.Name, startMinMenuItem.Checked);
       Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked);
       Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
 
@@ -346,13 +359,13 @@
     }
 
     private void ToggleSysTray() {
-      if (Visible) {
-        notifyIcon.Visible = true;
-        Visible = false;        
-      } else {
+      if (notifyIcon.Visible) {
         Visible = true;
         notifyIcon.Visible = false;
-        Activate();
+        Activate(); 
+      } else {
+        notifyIcon.Visible = true;
+        Visible = false;           
       }
     }
 
@@ -382,6 +395,5 @@
 
       sensorSystemTray.Remove(sensor);
     }
-
   }
 }
diff -r f940fe2a7c2b -r 898935080fd6 Program.cs
--- a/Program.cs	Fri Feb 19 18:33:08 2010 +0000
+++ b/Program.cs	Fri Feb 19 19:50:07 2010 +0000
@@ -51,12 +51,21 @@
       #endif
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
-        Application.Run(new GUI.MainForm());
+
+        using (GUI.MainForm form = new GUI.MainForm()) {
+          form.FormClosed += delegate(Object sender, FormClosedEventArgs e) {
+            Application.Exit();
+          };
+          Application.Run();
+        }
+        
       #if !DEBUG
       } catch (Exception e) {
         Utilities.CrashReport.Save(e);
       }
       #endif
     }
+
+    
   }
 }