Added an option to minimize on close.
1.1 --- a/GUI/MainForm.Designer.cs Wed Sep 22 20:44:34 2010 +0000
1.2 +++ b/GUI/MainForm.Designer.cs Thu Sep 23 20:44:59 2010 +0000
1.3 @@ -92,6 +92,7 @@
1.4 this.optionsMenuItem = new System.Windows.Forms.MenuItem();
1.5 this.startMinMenuItem = new System.Windows.Forms.MenuItem();
1.6 this.minTrayMenuItem = new System.Windows.Forms.MenuItem();
1.7 + this.minCloseMenuItem = new System.Windows.Forms.MenuItem();
1.8 this.startupMenuItem = new System.Windows.Forms.MenuItem();
1.9 this.separatorMenuItem = new System.Windows.Forms.MenuItem();
1.10 this.temperatureUnitsMenuItem = new System.Windows.Forms.MenuItem();
1.11 @@ -302,6 +303,7 @@
1.12 this.optionsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
1.13 this.startMinMenuItem,
1.14 this.minTrayMenuItem,
1.15 + this.minCloseMenuItem,
1.16 this.startupMenuItem,
1.17 this.separatorMenuItem,
1.18 this.temperatureUnitsMenuItem,
1.19 @@ -319,19 +321,24 @@
1.20 this.minTrayMenuItem.Index = 1;
1.21 this.minTrayMenuItem.Text = "Minimize To Tray";
1.22 //
1.23 + // minCloseMenuItem
1.24 + //
1.25 + this.minCloseMenuItem.Index = 2;
1.26 + this.minCloseMenuItem.Text = "Minimize On Close";
1.27 + //
1.28 // startupMenuItem
1.29 //
1.30 - this.startupMenuItem.Index = 2;
1.31 + this.startupMenuItem.Index = 3;
1.32 this.startupMenuItem.Text = "Run On Windows Startup";
1.33 //
1.34 // separatorMenuItem
1.35 //
1.36 - this.separatorMenuItem.Index = 3;
1.37 + this.separatorMenuItem.Index = 4;
1.38 this.separatorMenuItem.Text = "-";
1.39 //
1.40 // temperatureUnitsMenuItem
1.41 //
1.42 - this.temperatureUnitsMenuItem.Index = 4;
1.43 + this.temperatureUnitsMenuItem.Index = 5;
1.44 this.temperatureUnitsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
1.45 this.celciusMenuItem,
1.46 this.fahrenheitMenuItem});
1.47 @@ -351,12 +358,12 @@
1.48 //
1.49 // MenuItem4
1.50 //
1.51 - this.MenuItem4.Index = 5;
1.52 + this.MenuItem4.Index = 6;
1.53 this.MenuItem4.Text = "-";
1.54 //
1.55 // hddMenuItem
1.56 //
1.57 - this.hddMenuItem.Index = 6;
1.58 + this.hddMenuItem.Index = 7;
1.59 this.hddMenuItem.Text = "Read HDD sensors";
1.60 //
1.61 // helpMenuItem
1.62 @@ -513,6 +520,7 @@
1.63 private System.Windows.Forms.MenuItem resetMinMaxMenuItem;
1.64 private System.Windows.Forms.MenuItem MenuItem3;
1.65 private System.Windows.Forms.MenuItem gadgetMenuItem;
1.66 + private System.Windows.Forms.MenuItem minCloseMenuItem;
1.67 }
1.68 }
1.69
2.1 --- a/GUI/MainForm.cs Wed Sep 22 20:44:34 2010 +0000
2.2 +++ b/GUI/MainForm.cs Thu Sep 23 20:44:59 2010 +0000
2.3 @@ -71,6 +71,7 @@
2.4 private UserOption showMax;
2.5 private UserOption startMinimized;
2.6 private UserOption minimizeToTray;
2.7 + private UserOption minimizeOnClose;
2.8 private UserOption autoStart;
2.9 private UserOption readHddSensors;
2.10 private UserOption showGadget;
2.11 @@ -80,14 +81,14 @@
2.12
2.13 this.settings = new PersistentSettings();
2.14 this.settings.Load(Path.ChangeExtension(
2.15 - System.Windows.Forms.Application.ExecutablePath, ".config"));
2.16 + Application.ExecutablePath, ".config"));
2.17
2.18 this.unitManager = new UnitManager(settings);
2.19
2.20 // set the DockStyle here, to avoid conflicts with the MainMenu
2.21 this.splitContainer.Dock = DockStyle.Fill;
2.22
2.23 - int p = (int)System.Environment.OSVersion.Platform;
2.24 + int p = (int)Environment.OSVersion.Platform;
2.25 if ((p == 4) || (p == 128)) {
2.26 splitContainer.BorderStyle = BorderStyle.None;
2.27 splitContainer.Border3DStyle = Border3DStyle.Adjust;
2.28 @@ -196,6 +197,8 @@
2.29 systemTray.IsMainIconEnabled = minimizeToTray.Value;
2.30 };
2.31
2.32 + minimizeOnClose = new UserOption("minCloseMenuItem", false, minCloseMenuItem, settings);
2.33 +
2.34 autoStart = new UserOption(null, startupManager.Startup, startupMenuItem, settings);
2.35 autoStart.Changed += delegate(object sender, EventArgs e) {
2.36 try {
2.37 @@ -320,7 +323,7 @@
2.38 }
2.39
2.40 private void exitClick(object sender, EventArgs e) {
2.41 - Close();
2.42 + Close();
2.43 }
2.44
2.45 private void timer_Tick(object sender, EventArgs e) {
2.46 @@ -347,7 +350,7 @@
2.47 System.Windows.Forms.Application.ExecutablePath, ".config"));
2.48 }
2.49
2.50 - private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
2.51 + private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
2.52 Visible = false;
2.53 SaveConfiguration();
2.54
2.55 @@ -447,9 +450,25 @@
2.56 protected override void WndProc(ref Message m) {
2.57 const int WM_SYSCOMMAND = 0x112;
2.58 const int SC_MINIMIZE = 0xF020;
2.59 + const int SC_CLOSE = 0xF060;
2.60 +
2.61 if (minimizeToTray.Value &&
2.62 m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) {
2.63 SysTrayHideShow();
2.64 + } else if(minimizeOnClose.Value &&
2.65 + m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE) {
2.66 + /*
2.67 + * Apparently the user wants to minimize rather than close
2.68 + * Now we still need to check if we're going to the tray or not
2.69 + *
2.70 + * Note: the correct way to do this would be to send out SC_MINIMIZE,
2.71 + * but since the code here is so simple,
2.72 + * that would just be a waste of time.
2.73 + */
2.74 + if (minimizeToTray.Value)
2.75 + SysTrayHideShow();
2.76 + else
2.77 + WindowState = FormWindowState.Minimized;
2.78 } else {
2.79 base.WndProc(ref m);
2.80 }