Esempio n. 1
0
        private void UpdateMenu(bool beforeMenuOpening)
        {
            List <ICommand> ChangedCommandList = PluginManager.GetChangedCommands(beforeMenuOpening);

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

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

            TaskbarIcon SenderIcon = sender as TaskbarIcon;
            string      ExeName    = Assembly.GetExecutingAssembly().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)
            {
                SenderIcon.SetMenuIsChecked(LoadAtStartupCommand, Scheduler.IsTaskActive(ExeName));
            }
            else
            {
                if (Scheduler.IsTaskActive(ExeName))
                {
                    SenderIcon.SetMenuHeader(LoadAtStartupCommand, RemoveFromStartupHeader);
                }
                else
                {
                    SenderIcon.SetMenuHeader(LoadAtStartupCommand, LoadAtStartupHeader);
                }
            }

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

            PluginManager.OnMenuOpening();
        }