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 TrayLauncher_Click(object sender, EventArgs e) { if (MainForm == null || MainForm.IsDisposed || MainForm.Disposing) MainForm = new LauncherForm(this); MainForm.Show(); if (MainForm.WindowState == FormWindowState.Minimized) { if (MainForm.Handle != IntPtr.Zero) { SendMessage(MainForm.Handle, WM_SYSCOMMAND, SC_RESTORE, IntPtr.Zero); } } MainForm.Focus(); }