private WinForms::ContextMenuStrip InitMenu() { WinForms::ContextMenuStrip contextMenu = new WinForms::ContextMenuStrip(); void MenuShow_Click(object Sender, EventArgs e) { notifierWindow.RestoreWindowState(); } void MenuClose_Click(object Sender, EventArgs e) { // Dispose and close the window which exits the app notifierWindow.Close(); contextMenu.Dispose(); trayIcon.Dispose(); Environment.Exit(0); } void MenuConsole_Click(object Sender, EventArgs e) { Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WFN.exe")); } void MenuShowActivity_Click(object Sender, EventArgs e) { App.GetActivityWindow().Show(); } contextMenu.Items.Add(Messages.NotifierTrayIcon_ShowNotifier, null, MenuShow_Click); contextMenu.Items.Add(Messages.NotifierTrayIcon_OpenConsole, null, MenuConsole_Click); contextMenu.Items.Add(Messages.NotifierTrayIcon_ShowActivityWindow, null, MenuShowActivity_Click); contextMenu.Items.Add(Messages.NotifierTrayIcon_DiscardAndClose, null, MenuClose_Click); return(contextMenu); }
private ContextMenu InitMenu() { void MenuShow_Click(object Sender, RoutedEventArgs e) { notifierWindow.RestoreWindowState(); } void MenuClose_Click(object Sender, EventArgs e) { notifierWindow.Close(); Close(); } void MenuConsole_Click(object Sender, EventArgs e) { notifierWindow.ShowConsole(); } void MenuHide_Click(object Sender, EventArgs e) { Hide(); } void addMenuItem(ContextMenu cm, string caption, RoutedEventHandler eh) { MenuItem mi = new MenuItem { Header = caption }; mi.Click += eh; cm.Items.Add(mi); } ContextMenu contextMenu = new ContextMenu(); addMenuItem(contextMenu, Messages.ActivityWindow_ShowNotifier, MenuShow_Click); addMenuItem(contextMenu, Messages.ActivityWindow_OpenConsole, MenuConsole_Click); addMenuItem(contextMenu, Messages.ActivityWindow_DiscardAndClose, MenuClose_Click); addMenuItem(contextMenu, Messages.ActivityWindow_HideThisWindow, MenuHide_Click); return(contextMenu); }
void MenuClose_Click(object Sender, EventArgs e) { // Dispose and close the window which exits the app notifierWindow.Close(); Environment.Exit(0); }
private ContextMenu InitMenu() { ContextMenu contextMenu = new ContextMenu() { Items = { CreateMenuItem(Messages.ActivityWindow_ShowNotifier, (s, e) => notifierWindow.RestoreWindowState()), CreateMenuItem(Messages.ActivityWindow_OpenConsole, (s, e) => notifierWindow.ShowConsole()), CreateMenuItem(Messages.ActivityWindow_HideThisWindow, (s, e) => Hide()), CreateMenuItem(SetOrientationGetMessage(), (s, e) => ((MenuItem)s).Header = SetOrientationGetMessage(true)), new Separator(), CreateMenuItem(Messages.ActivityWindow_DiscardAndClose, (s, e) => { notifierWindow.Close(); Close(); }) } }; return(contextMenu); }