diff --git a/GUI/MainForm.Designer.cs b/GUI/MainForm.Designer.cs index f3d2e9a..582f966 100644 --- a/GUI/MainForm.Designer.cs +++ b/GUI/MainForm.Designer.cs @@ -94,6 +94,7 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { // optionsToolStripMenuItem // this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.startMinMenuItem, this.minTrayMenuItem, this.toolStripMenuItem3, this.hddMenuItem}); @@ -418,6 +420,13 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { 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 --git a/GUI/MainForm.cs b/GUI/MainForm.cs index a8f38e0..7849c54 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -134,6 +134,7 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { 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 @@ namespace OpenHardwareMonitor.GUI { } 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 @@ namespace OpenHardwareMonitor.GUI { sensorSystemTray.Remove(sensor); } - } } diff --git a/Program.cs b/Program.cs index 1734f70..5fad500 100644 --- a/Program.cs +++ b/Program.cs @@ -51,12 +51,21 @@ namespace OpenHardwareMonitor { #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 } + + } }