/* * Create a notification context with an icon and menu. */ internal NotificationContext() { // Create a VistaMenu control to stylize context menus VistaMenu vistaMenu = new VistaMenu(); // Create menu items for the notification icon context menu MenuItem menuItemShow = new MenuItem("Show " + Application.ProductName, menuItemShow_Click); MenuItem menuItemSettings = new MenuItem("Settings…", menuItemSettings_Click); MenuItem menuItemAbout = new MenuItem("About…", menuItemAbout_Click); MenuItem menuItemExit = new MenuItem("Exit", menuItemExit_Click); // Add icons to the notification icon context menu items vistaMenu.SetImage(menuItemSettings, Properties.Resources.MenuItemSettings.ToBitmap()); vistaMenu.SetImage(menuItemAbout, Properties.Resources.MenuItemAbout.ToBitmap()); // Set the show menu entry as default (bold) menuItemShow.DefaultItem = true; // Add the menu items to the notify icon context menu ContextMenu contextMenuNotifyIcon = new ContextMenu(new MenuItem[] { menuItemShow, menuItemSettings, new MenuItem("-"), menuItemAbout, new MenuItem("-"), menuItemExit }); // This needs to be called or the context menu will not have icons ((System.ComponentModel.ISupportInitialize)(vistaMenu)).EndInit(); // Create a new instance of the notify icon notifyIcon = new NotifyIcon() { ContextMenu = contextMenuNotifyIcon, Icon = new Icon(Program.Settings.Data.WhiteNotificationIcon ? Properties.Resources.NotificationWhite : Properties.Resources.NotificationColor, SystemInformation.SmallIconSize), Text = Application.ProductName, Visible = true, }; // Assign a click and double click event handler for the notification icon notifyIcon.Click += notifyIcon_Click; notifyIcon.DoubleClick += notifyIcon_DoubleClick; // Show the wrapper form on startup? if(Program.Settings.Data.ShowOnStartup) { DisplayWrapperForm(); } // Remind the user that the application is running on the background? if(Program.Settings.Data.BackgroundRunningBalloon && !Program.Settings.Data.ShowOnStartup) { notifyIcon.BalloonTipClicked += delegate { Program.Settings.Data.BackgroundRunningBalloon = false; }; notifyIcon.ShowBalloonTip(3000, "SlackUI is running on the background", "SlackUI started hidden and will continue to run so that you can receive real time updates while " + "signed in.\n\nTo stop showing this reminder, click here.", ToolTipIcon.Info); } }
private static void SetImages(ContextMenu menu) { var vm = new VistaMenu(); ((System.ComponentModel.ISupportInitialize)(vm)).BeginInit(); foreach (MenuItem item in menu.MenuItems) { if (item.Tag is Task) { switch ((item.Tag as Task).Priority) { case TaskPriority.One: vm.SetImage(item, LazyCow.Properties.Resources.prio1); break; case TaskPriority.Two: vm.SetImage(item, LazyCow.Properties.Resources.prio2); break; case TaskPriority.Three: vm.SetImage(item, LazyCow.Properties.Resources.prio3); break; default: vm.SetImage(item, LazyCow.Properties.Resources.prio0); break; } } else if (item.Tag is TaskList) { foreach (MenuItem task in item.MenuItems) { if (!(task.Tag is Task)) continue; var t = task.Tag as Task; switch (t.Priority) { case TaskPriority.One: vm.SetImage(task, LazyCow.Properties.Resources.prio1); break; case TaskPriority.Two: vm.SetImage(task, LazyCow.Properties.Resources.prio2); break; case TaskPriority.Three: vm.SetImage(task, LazyCow.Properties.Resources.prio3); break; default: vm.SetImage(task, LazyCow.Properties.Resources.prio0); break; } } } } ((System.ComponentModel.ISupportInitialize)(vm)).EndInit(); }