using System; using System.Windows.Forms; using HeuristicLab.Clients.Hive.SlaveCore.Views; namespace HeuristicLab.Clients.Hive.SlaveCore.SlaveTrayIcon { public partial class MainWindow : Form { public SlaveItem Content { get { return slaveView.Content; } set { slaveView.Content = value; } } 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(); } private void RestoreFromTray() { Show(); WindowState = FormWindowState.Normal; } private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; MinimizeToTray(); } else { if (Content != null) { Content.StopAll(); } } } } }