示例#1
0
        private static void UpdateMenu()
        {
            List <ICommand> ChangedCommandList = PluginManager.GetChangedCommands();

            foreach (ICommand Command in ChangedCommandList)
            {
                // Update changed menus with their new state.
                bool MenuIsVisible = PluginManager.GetMenuIsVisible(Command);
                if (MenuIsVisible)
                {
                    TaskbarIcon.SetMenuIsVisible(Command, true);
                    TaskbarIcon.SetMenuText(Command, PluginManager.GetMenuHeader(Command));
                    TaskbarIcon.SetMenuIsEnabled(Command, PluginManager.GetMenuIsEnabled(Command));

                    Bitmap?MenuIcon = PluginManager.GetMenuIcon(Command);
                    if (MenuIcon != null)
                    {
                        TaskbarIcon.SetMenuCheck(Command, false);
                        TaskbarIcon.SetMenuIcon(Command, MenuIcon);
                    }
                    else
                    {
                        TaskbarIcon.SetMenuCheck(Command, PluginManager.GetMenuIsChecked(Command));
                    }
                }
                else
                {
                    TaskbarIcon.SetMenuIsVisible(Command, false);
                }
            }
        }
示例#2
0
        private void OnMenuOpening(object?sender, EventArgs e)
        {
            Logger.AddLog("OnMenuOpening");

            Contract.RequireNotNull(Assembly.GetEntryAssembly(), out Assembly EntryAssembly);
            string ExeName = EntryAssembly.Location;

            // Update the load at startup menu with the current state (the user can change it directly in the Task Scheduler at any time).
            if (IsElevated)
            {
                TaskbarIcon.SetMenuCheck(LoadAtStartupCommand, Scheduler.IsTaskActive(ExeName));
            }
            else
            {
                if (Scheduler.IsTaskActive(ExeName))
                {
                    TaskbarIcon.SetMenuText(LoadAtStartupCommand, RemoveFromStartupHeader);
                }
                else
                {
                    TaskbarIcon.SetMenuText(LoadAtStartupCommand, LoadAtStartupHeader);
                }
            }

            // Update the menu with latest news from plugins.
            UpdateMenu();

            PluginManager.OnMenuOpening();
        }