Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.TrayIcon/3.3/MainWindow.cs @ 6725

Last change on this file since 6725 was 6698, checked in by ascheibe, 13 years ago

#1233

  • implemented review comments
  • more cleanups
File size: 2.1 KB
Line 
1using System;
2using System.Windows.Forms;
3using HeuristicLab.Clients.Hive.SlaveCore.Views;
4using HeuristicLab.Clients.Hive.SlaveCore.Views.Properties;
5
6namespace HeuristicLab.Clients.Hive.SlaveCore.SlaveTrayIcon {
7  public partial class MainWindow : Form {
8
9    public SlaveItem Content {
10      get { return slaveView.Content; }
11      set {
12        slaveView.Content = value;
13        logView.Content = value;
14        jobsView.Content = value;
15        Content.UserVisibleMessageFired += new EventHandler<Common.EventArgs<string>>(Content_UserVisibleMessageFired);
16      }
17    }
18
19    void Content_UserVisibleMessageFired(object sender, Common.EventArgs<string> e) {
20      if (Settings.Default.ShowBalloonTips) {
21        notifyIcon.ShowBalloonTip(2000, "HeuristicLab Hive", e.Value, ToolTipIcon.Info);
22      }
23    }
24
25    public MainWindow() {
26      InitializeComponent();
27    }
28
29    private void notifyIcon_DoubleClick(object sender, EventArgs e) {
30      if (WindowState == FormWindowState.Normal) {
31        MinimizeToTray();
32      } else {
33        RestoreFromTray();
34      }
35    }
36
37    private void closeToolStripMenuItem_Click(object sender, EventArgs e) {
38      Application.Exit();
39    }
40
41    private void showToolStripMenuItem_Click(object sender, EventArgs e) {
42      if (WindowState != FormWindowState.Normal) {
43        RestoreFromTray();
44      }
45    }
46
47    public void MinimizeToTray() {
48      WindowState = FormWindowState.Minimized;
49      Hide();
50    }
51
52    public void RestoreFromTray() {
53      Show();
54      WindowState = FormWindowState.Normal;
55    }
56
57    private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) {
58      if (e.CloseReason == CloseReason.UserClosing) {
59        e.Cancel = true;
60        MinimizeToTray();
61      }
62    }
63
64    private void notifyIcon_BalloonTipClicked(object sender, EventArgs e) {
65      RestoreFromTray();
66    }
67
68    private void homepageToolStripMenuItem_Click(object sender, EventArgs e) {
69      System.Diagnostics.Process.Start("http://dev.heuristiclab.com");
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.