コード例 #1
0
ファイル: TrayIcon.cs プロジェクト: weedkiller/Sun.Plasma
        /// <summary>
        /// Initializes the trayicon and the contextmenu
        /// </summary>
        public static void InitializeTrayIcon()
        {
            // Initialize objects and tray icon
            NotifyIcon              = new System.Windows.Forms.NotifyIcon();
            NotifyIcon.Text         = "Sun Plasma";
            NotifyIcon.Icon         = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
            NotifyIcon.DoubleClick += new EventHandler(NotifyIcon_Click);
            NotifyIcon.Visible      = true;

            // Set up the context menu for the notify icon
            NotifyContextMenu = new System.Windows.Forms.ContextMenu();

            // Launch Star Citizen
            var launchStarCitizenItem = NotifyContextMenu.MenuItems.Add("Launch Star Citizen");
            var command = new ViewModel.Commands.LaunchStarCitizenCommand();

            launchStarCitizenItem.Enabled = command.CanExecute(null);
            launchStarCitizenItem.Click  += (sender, args) => command.Execute(null);

            // Launch Mumble
            var launchMumble  = NotifyContextMenu.MenuItems.Add("Launch Mumble");
            var commandMumble = new ViewModel.Commands.LaunchMumbleCommand();

            launchMumble.Enabled = commandMumble.CanExecute(null);
            launchMumble.Click  += (sender, args) => commandMumble.Execute(null);

            // Exit
            NotifyContextMenu.MenuItems.Add("-");
            NotifyContextMenu.MenuItems.Add("Exit", NotifyContextMenuExit_Click);

            NotifyIcon.ContextMenu = NotifyContextMenu;
        }
コード例 #2
0
ファイル: TrayIcon.cs プロジェクト: RononDex/Sun.Plasma
        /// <summary>
        /// Initializes the trayicon and the contextmenu
        /// </summary>
        public static void InitializeTrayIcon()
        {
            // Initialize objects and tray icon
            NotifyIcon = new System.Windows.Forms.NotifyIcon();
            NotifyIcon.Text = "Sun Plasma";
            NotifyIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
            NotifyIcon.DoubleClick += new EventHandler(NotifyIcon_Click);
            NotifyIcon.Visible = true;

            // Set up the context menu for the notify icon
            NotifyContextMenu = new System.Windows.Forms.ContextMenu();

            // Launch Star Citizen
            var launchStarCitizenItem = NotifyContextMenu.MenuItems.Add("Launch Star Citizen");
            var command = new ViewModel.Commands.LaunchStarCitizenCommand();
            launchStarCitizenItem.Enabled = command.CanExecute(null);
            launchStarCitizenItem.Click += (sender, args) => command.Execute(null);

            // Launch Mumble
            var launchMumble = NotifyContextMenu.MenuItems.Add("Launch Mumble");
            var commandMumble = new ViewModel.Commands.LaunchMumbleCommand();
            launchMumble.Enabled = commandMumble.CanExecute(null);
            launchMumble.Click += (sender, args) => commandMumble.Execute(null);

            // Exit
            NotifyContextMenu.MenuItems.Add("-");
            NotifyContextMenu.MenuItems.Add("Exit", NotifyContextMenuExit_Click);

            NotifyIcon.ContextMenu = NotifyContextMenu;
        }