1.1 --- a/GUI/MainForm.cs Wed Sep 22 20:44:34 2010 +0000
1.2 +++ b/GUI/MainForm.cs Thu Sep 23 20:44:59 2010 +0000
1.3 @@ -71,6 +71,7 @@
1.4 private UserOption showMax;
1.5 private UserOption startMinimized;
1.6 private UserOption minimizeToTray;
1.7 + private UserOption minimizeOnClose;
1.8 private UserOption autoStart;
1.9 private UserOption readHddSensors;
1.10 private UserOption showGadget;
1.11 @@ -80,14 +81,14 @@
1.12
1.13 this.settings = new PersistentSettings();
1.14 this.settings.Load(Path.ChangeExtension(
1.15 - System.Windows.Forms.Application.ExecutablePath, ".config"));
1.16 + Application.ExecutablePath, ".config"));
1.17
1.18 this.unitManager = new UnitManager(settings);
1.19
1.20 // set the DockStyle here, to avoid conflicts with the MainMenu
1.21 this.splitContainer.Dock = DockStyle.Fill;
1.22
1.23 - int p = (int)System.Environment.OSVersion.Platform;
1.24 + int p = (int)Environment.OSVersion.Platform;
1.25 if ((p == 4) || (p == 128)) {
1.26 splitContainer.BorderStyle = BorderStyle.None;
1.27 splitContainer.Border3DStyle = Border3DStyle.Adjust;
1.28 @@ -196,6 +197,8 @@
1.29 systemTray.IsMainIconEnabled = minimizeToTray.Value;
1.30 };
1.31
1.32 + minimizeOnClose = new UserOption("minCloseMenuItem", false, minCloseMenuItem, settings);
1.33 +
1.34 autoStart = new UserOption(null, startupManager.Startup, startupMenuItem, settings);
1.35 autoStart.Changed += delegate(object sender, EventArgs e) {
1.36 try {
1.37 @@ -320,7 +323,7 @@
1.38 }
1.39
1.40 private void exitClick(object sender, EventArgs e) {
1.41 - Close();
1.42 + Close();
1.43 }
1.44
1.45 private void timer_Tick(object sender, EventArgs e) {
1.46 @@ -347,7 +350,7 @@
1.47 System.Windows.Forms.Application.ExecutablePath, ".config"));
1.48 }
1.49
1.50 - private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
1.51 + private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
1.52 Visible = false;
1.53 SaveConfiguration();
1.54
1.55 @@ -447,9 +450,25 @@
1.56 protected override void WndProc(ref Message m) {
1.57 const int WM_SYSCOMMAND = 0x112;
1.58 const int SC_MINIMIZE = 0xF020;
1.59 + const int SC_CLOSE = 0xF060;
1.60 +
1.61 if (minimizeToTray.Value &&
1.62 m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) {
1.63 SysTrayHideShow();
1.64 + } else if(minimizeOnClose.Value &&
1.65 + m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE) {
1.66 + /*
1.67 + * Apparently the user wants to minimize rather than close
1.68 + * Now we still need to check if we're going to the tray or not
1.69 + *
1.70 + * Note: the correct way to do this would be to send out SC_MINIMIZE,
1.71 + * but since the code here is so simple,
1.72 + * that would just be a waste of time.
1.73 + */
1.74 + if (minimizeToTray.Value)
1.75 + SysTrayHideShow();
1.76 + else
1.77 + WindowState = FormWindowState.Minimized;
1.78 } else {
1.79 base.WndProc(ref m);
1.80 }