1 | using System;
|
---|
2 | using System.Windows.Forms;
|
---|
3 | using HeuristicLab.Clients.Hive.SlaveCore.Views;
|
---|
4 | using HeuristicLab.Clients.Hive.SlaveCore.Views.Properties;
|
---|
5 |
|
---|
6 | namespace 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 | }
|
---|