using System; using System.Windows.Forms; using HeuristicLab.Clients.Hive.SlaveCore.Views; using HeuristicLab.Clients.Hive.SlaveCore.Views.Properties; namespace HeuristicLab.Clients.Hive.SlaveCore.SlaveTrayIcon { public partial class MainWindow : Form { public SlaveItem Content { get { return slaveView.Content; } set { slaveView.Content = value; logView.Content = value; jobsView.Content = value; Content.UserVisibleMessageFired += new EventHandler>(Content_UserVisibleMessageFired); } } void Content_UserVisibleMessageFired(object sender, Common.EventArgs e) { if (Settings.Default.ShowBalloonTips) { notifyIcon.ShowBalloonTip(2000, "HeuristicLab Hive", e.Value, ToolTipIcon.Info); } } public MainWindow() { InitializeComponent(); } private void notifyIcon_DoubleClick(object sender, EventArgs e) { if (WindowState == FormWindowState.Normal) { MinimizeToTray(); } else { RestoreFromTray(); } } private void closeToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } private void showToolStripMenuItem_Click(object sender, EventArgs e) { if (WindowState != FormWindowState.Normal) { RestoreFromTray(); } } public void MinimizeToTray() { WindowState = FormWindowState.Minimized; Hide(); } public void RestoreFromTray() { Show(); WindowState = FormWindowState.Normal; } private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; MinimizeToTray(); } } private void notifyIcon_BalloonTipClicked(object sender, EventArgs e) { RestoreFromTray(); } private void homepageToolStripMenuItem_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("http://dev.heuristiclab.com"); } } }