public ApplicationRoot() { TrayIcon = new NotifyIcon(); TrayMenu = new ContextMenuStrip(); TrayIcon.ContextMenuStrip = TrayMenu; TrayIcon.Text = "Battlezone Launcher"; TrayLauncher = new ToolStripMenuItem("Lancher", null, new EventHandler(TrayLauncher_Click)); TrayTasks = new ToolStripMenuItem("Tasks", null, new EventHandler(TrayTasks_Click)); TrayAbout = new ToolStripMenuItem("About", null, new EventHandler(TrayAbout_Click)); TrayExit = new ToolStripMenuItem("Exit", null, new EventHandler(TrayExit_Click)); TrayMenu.Items.AddRange(new ToolStripItem[] { TrayLauncher, TrayTasks, TrayAbout, new ToolStripSeparator(), TrayExit }); LauncherItems = new LauncherItemCollection(@".\data\launcher.json"); Patches = new PatchList(@".\data\patches.json"); MainForm = new LauncherForm(this); TaskForm = new TaskForm(); AboutBox = new AboutBox(); TaskList = new List<LauncherTask>(); TrayIcon.Icon = Properties.Resources.launcher1; TrayIcon.Visible = true; TrayIcon.MouseUp += TrayIcon_MouseUp; MainForm.Show(); }
private void TrayTasks_Click(object sender, EventArgs e) { if (TaskForm == null || TaskForm.IsDisposed || TaskForm.Disposing) TaskForm = new TaskForm(); TaskForm.Show(); if (TaskForm.WindowState == FormWindowState.Minimized) { if (TaskForm.Handle != IntPtr.Zero) { SendMessage(TaskForm.Handle, WM_SYSCOMMAND, SC_RESTORE, IntPtr.Zero); } } TaskForm.Focus(); }