New option to start the application minimized.
authormoel.mich
Fri, 19 Feb 2010 19:50:07 +0000
changeset 55898935080fd6
parent 54 f940fe2a7c2b
child 56 5cb7eb5bf628
New option to start the application minimized.
GUI/MainForm.Designer.cs
GUI/MainForm.cs
Program.cs
     1.1 --- a/GUI/MainForm.Designer.cs	Fri Feb 19 18:33:08 2010 +0000
     1.2 +++ b/GUI/MainForm.Designer.cs	Fri Feb 19 19:50:07 2010 +0000
     1.3 @@ -94,6 +94,7 @@
     1.4        this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
     1.5        this.plotMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     1.6        this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     1.7 +      this.startMinMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     1.8        this.minTrayMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     1.9        this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
    1.10        this.hddMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    1.11 @@ -101,12 +102,12 @@
    1.12        this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    1.13        this.timer = new System.Windows.Forms.Timer(this.components);
    1.14        this.splitContainer = new System.Windows.Forms.SplitContainer();
    1.15 +      this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel();
    1.16        this.notifyContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    1.17        this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    1.18        this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
    1.19        this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
    1.20        this.sensorContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    1.21 -      this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel();
    1.22        this.columnsContextMenuStrip.SuspendLayout();
    1.23        this.menuStrip.SuspendLayout();
    1.24        this.splitContainer.Panel1.SuspendLayout();
    1.25 @@ -411,6 +412,7 @@
    1.26        // optionsToolStripMenuItem
    1.27        // 
    1.28        this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
    1.29 +            this.startMinMenuItem,
    1.30              this.minTrayMenuItem,
    1.31              this.toolStripMenuItem3,
    1.32              this.hddMenuItem});
    1.33 @@ -418,6 +420,13 @@
    1.34        this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
    1.35        this.optionsToolStripMenuItem.Text = "Options";
    1.36        // 
    1.37 +      // startMinimizedMenuItem
    1.38 +      // 
    1.39 +      this.startMinMenuItem.CheckOnClick = true;
    1.40 +      this.startMinMenuItem.Name = "startMinimizedMenuItem";
    1.41 +      this.startMinMenuItem.Size = new System.Drawing.Size(166, 22);
    1.42 +      this.startMinMenuItem.Text = "Start Minimized";
    1.43 +      // 
    1.44        // minTrayMenuItem
    1.45        // 
    1.46        this.minTrayMenuItem.Checked = true;
    1.47 @@ -480,6 +489,16 @@
    1.48        this.splitContainer.SplitterWidth = 3;
    1.49        this.splitContainer.TabIndex = 3;
    1.50        // 
    1.51 +      // plotPanel
    1.52 +      // 
    1.53 +      this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    1.54 +      this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill;
    1.55 +      this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F);
    1.56 +      this.plotPanel.Location = new System.Drawing.Point(0, 0);
    1.57 +      this.plotPanel.Name = "plotPanel";
    1.58 +      this.plotPanel.Size = new System.Drawing.Size(478, 198);
    1.59 +      this.plotPanel.TabIndex = 0;
    1.60 +      // 
    1.61        // notifyContextMenuStrip
    1.62        // 
    1.63        this.notifyContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    1.64 @@ -514,16 +533,6 @@
    1.65        this.sensorContextMenuStrip.Name = "sensorContextMenuStrip";
    1.66        this.sensorContextMenuStrip.Size = new System.Drawing.Size(61, 4);
    1.67        // 
    1.68 -      // plotPanel
    1.69 -      // 
    1.70 -      this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
    1.71 -      this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill;
    1.72 -      this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F);
    1.73 -      this.plotPanel.Location = new System.Drawing.Point(0, 0);
    1.74 -      this.plotPanel.Name = "plotPanel";
    1.75 -      this.plotPanel.Size = new System.Drawing.Size(478, 198);
    1.76 -      this.plotPanel.TabIndex = 0;
    1.77 -      // 
    1.78        // MainForm
    1.79        // 
    1.80        this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
    1.81 @@ -597,6 +606,7 @@
    1.82      private System.Windows.Forms.ToolStripMenuItem minTrayMenuItem;
    1.83      private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
    1.84      private System.Windows.Forms.ContextMenuStrip sensorContextMenuStrip;
    1.85 +    private System.Windows.Forms.ToolStripMenuItem startMinMenuItem;
    1.86    }
    1.87  }
    1.88  
     2.1 --- a/GUI/MainForm.cs	Fri Feb 19 18:33:08 2010 +0000
     2.2 +++ b/GUI/MainForm.cs	Fri Feb 19 19:50:07 2010 +0000
     2.3 @@ -134,6 +134,7 @@
     2.4        maxMenuItem.Checked = Config.Get(maxMenuItem.Name, true);
     2.5        limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false);
     2.6  
     2.7 +      startMinMenuItem.Checked = Config.Get(startMinMenuItem.Name, false); 
     2.8        minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true);
     2.9        hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true);
    2.10  
    2.11 @@ -143,7 +144,18 @@
    2.12        tempMenuItem.Checked = Config.Get(tempMenuItem.Name, true);
    2.13        fansMenuItem.Checked = Config.Get(fansMenuItem.Name, true);
    2.14       
    2.15 -      timer.Enabled = true;   
    2.16 +      timer.Enabled = true;
    2.17 +
    2.18 +      if (startMinMenuItem.Checked) {
    2.19 +        if (minTrayMenuItem.Checked) {
    2.20 +          notifyIcon.Visible = true;
    2.21 +        } else {
    2.22 +          WindowState = FormWindowState.Minimized;
    2.23 +          Show();
    2.24 +        }
    2.25 +      } else {
    2.26 +        Show();
    2.27 +      }
    2.28      }
    2.29  
    2.30      private void HardwareAdded(IHardware hardware) {
    2.31 @@ -238,6 +250,7 @@
    2.32        Config.Set(maxMenuItem.Name, maxMenuItem.Checked);
    2.33        Config.Set(limitMenuItem.Name, limitMenuItem.Checked);
    2.34  
    2.35 +      Config.Set(startMinMenuItem.Name, startMinMenuItem.Checked);
    2.36        Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked);
    2.37        Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
    2.38  
    2.39 @@ -346,13 +359,13 @@
    2.40      }
    2.41  
    2.42      private void ToggleSysTray() {
    2.43 -      if (Visible) {
    2.44 -        notifyIcon.Visible = true;
    2.45 -        Visible = false;        
    2.46 -      } else {
    2.47 +      if (notifyIcon.Visible) {
    2.48          Visible = true;
    2.49          notifyIcon.Visible = false;
    2.50 -        Activate();
    2.51 +        Activate(); 
    2.52 +      } else {
    2.53 +        notifyIcon.Visible = true;
    2.54 +        Visible = false;           
    2.55        }
    2.56      }
    2.57  
    2.58 @@ -382,6 +395,5 @@
    2.59  
    2.60        sensorSystemTray.Remove(sensor);
    2.61      }
    2.62 -
    2.63    }
    2.64  }
     3.1 --- a/Program.cs	Fri Feb 19 18:33:08 2010 +0000
     3.2 +++ b/Program.cs	Fri Feb 19 19:50:07 2010 +0000
     3.3 @@ -51,12 +51,21 @@
     3.4        #endif
     3.5          Application.EnableVisualStyles();
     3.6          Application.SetCompatibleTextRenderingDefault(false);
     3.7 -        Application.Run(new GUI.MainForm());
     3.8 +
     3.9 +        using (GUI.MainForm form = new GUI.MainForm()) {
    3.10 +          form.FormClosed += delegate(Object sender, FormClosedEventArgs e) {
    3.11 +            Application.Exit();
    3.12 +          };
    3.13 +          Application.Run();
    3.14 +        }
    3.15 +        
    3.16        #if !DEBUG
    3.17        } catch (Exception e) {
    3.18          Utilities.CrashReport.Save(e);
    3.19        }
    3.20        #endif
    3.21      }
    3.22 +
    3.23 +    
    3.24    }
    3.25  }