[5314] | 1 | using System;
|
---|
| 2 | using System.Windows.Forms;
|
---|
[5599] | 3 | using HeuristicLab.Clients.Hive.SlaveCore.Views;
|
---|
[6225] | 4 | using HeuristicLab.Clients.Hive.SlaveCore.Views.Properties;
|
---|
[5314] | 5 |
|
---|
[5599] | 6 | namespace HeuristicLab.Clients.Hive.SlaveCore.SlaveTrayIcon {
|
---|
[5314] | 7 | public partial class MainWindow : Form {
|
---|
| 8 |
|
---|
| 9 | public SlaveItem Content {
|
---|
| 10 | get { return slaveView.Content; }
|
---|
[6225] | 11 | set {
|
---|
| 12 | slaveView.Content = value;
|
---|
| 13 | logView.Content = value;
|
---|
[6263] | 14 | jobsView.Content = value;
|
---|
[6225] | 15 | Content.UserVisibleMessageFired += new EventHandler<Common.EventArgs<string>>(Content_UserVisibleMessageFired);
|
---|
| 16 | }
|
---|
[5314] | 17 | }
|
---|
| 18 |
|
---|
[6225] | 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 |
|
---|
[5314] | 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 |
|
---|
[6257] | 52 | public void RestoreFromTray() {
|
---|
[5314] | 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 | }
|
---|
[6225] | 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 | }
|
---|
[5314] | 71 | }
|
---|
| 72 | }
|
---|