Exemple #1
0
 private void ShowAllLanguageMenuItem_Click(object sender, EventArgs e)
 {
     m_ShowAllLanguage = !ShowAllLanguageMenuItem.Checked;
     eAntForm.preferences.SetProperty("ShowAllLanguages", m_ShowAllLanguage);
     ShowAllLanguageMenuItem.Click -= new EventHandler(ShowAllLanguageMenuItem_Click);
     MenuItems.Clear();
     m_CreateMenuInfo(m_Owner);
 }
Exemple #2
0
        public void MenuItemCollection_Clear_InvokeOnMenuItem_Success()
        {
            var menuItem   = new MenuItem();
            var menu       = new MenuItem("text", new MenuItem[] { menuItem });
            var collection = new Menu.MenuItemCollection(menu);

            collection.Clear();
            Assert.Empty(collection);
            Assert.Null(menuItem.Parent);
            Assert.Equal(-1, menuItem.Index);

            collection.Clear();
            Assert.Empty(collection);
        }
        static void Ready()
        {
            timer_connecting.Stop();

            presence.largeImageKey  = "google_banner";
            presence.largeImageText = "Google Play Music";

            ready = true;

            oldPresence = presence;

            Menu.MenuItemCollection menuIndex = notifyIcon.ContextMenu.MenuItems;

            menuIndex.Clear();
            menuIndex.Add(Buttons["forc"]);
            menuIndex.Add(Buttons["stop"]);
            menuIndex.Add(Buttons["quit"]);

            timer.Tick    += new EventHandler(UpdatePresence);
            timer.Interval = 2500;
            timer.Start();

            timer.Enabled = true;

            CreatePopup("Connected!");
        }
        // Connect button handler
        public static void DiscordConnect(object sender, EventArgs e)
        {
            if (ready)
            {
                return;
            }

            if (DISCORD_CLIENT_ID == "")
            {
                MessageBox.Show("Missing Discord Client ID!", "Discord Play",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                TerminateProgram();
            }

            DiscordRpc.EventHandlers eventHander = new DiscordRpc.EventHandlers();

            eventHander.readyCallback        += Ready;
            eventHander.disconnectedCallback += Disconnected;
            eventHander.errorCallback        += Error;

            Menu.MenuItemCollection menuIndex = notifyIcon.ContextMenu.MenuItems;
            menuIndex.Clear();
            menuIndex.Add(Buttons["init"]);
            menuIndex.Add(Buttons["quit"]);


            timer_connecting.Tick    += new EventHandler(CheckConnected);
            timer_connecting.Interval = 100;
            timer_connecting.Start();

            DiscordRpc.Initialize(DISCORD_CLIENT_ID, ref eventHander, true, null);
        }
        public static void DiscordPause(object sender, EventArgs e)
        {
            if (ready)
            {
                Menu.MenuItemCollection menuIndex = notifyIcon.ContextMenu.MenuItems;
                menuIndex.Clear();
                menuIndex.Add(Buttons["init"]);
                menuIndex.Add(Buttons["quit"]);

                timer.Stop();
            }
        }
        /// <summary>
        /// Re-build the context menus.
        /// </summary>
        private void InitializeContextMenus()
        {
            Menu.MenuItemCollection items = this.serviceGUI.ServiceGridMenu.MenuItems;
            items.Clear();

            foreach (IScript script in this.scriptManager.ServiceScripts)
            {
                MenuItem temp = new MenuItem(script.LongName
                                             , new EventHandler(this.HandleServiceGridMenu)
                                             , script.ScriptShortCut);

                temp.Enabled = script.Active;

                items.Add(temp);
            }
        }
        private void ContextMenu_Popup(object sender, EventArgs e)
        {
            Menu.MenuItemCollection items = this.serviceGUI.ServiceGridMenu.MenuItems;
            items.Clear();

            DataGrid dgrid = this.serviceGUI.ServiceGrid;

            DataView dView = (DataView)dgrid.DataSource;

            ServiceController[] selectedServices = null;

            selectedServices = this.GetSelectedServices();


            foreach (IServiceScript script in this.scriptManager.ServiceScripts)
            {
                if (script.Validator != null)
                {
                    bool hit = false;
                    foreach (ServiceController service in selectedServices)
                    {
                        if (!script.Validator(service))
                        {
                            hit = true;
                        }
                    }
                    if (hit)
                    {
                        continue;
                    }
                }



                MenuItem temp = new MenuItem(script.LongName
                                             , new EventHandler(this.HandleServiceGridMenu)
                                             , script.ScriptShortCut);

                temp.Enabled = script.Active;

                items.Add(temp);
            }
        }
Exemple #8
0
        private void menuSortLoop(Menu.MenuItemCollection mc)
        {
            if (mc == null)
            {
                return;
            }
            for (var i = 0; i < mc.Count; i++)
            {
                menuSortLoop(mc[i].MenuItems);
            }
            var mis = new ArrayList();

            foreach (MenuItem mi in mc)
            {
                mis.Add(mi);
            }
            mis.Sort(new Sorter(_menuorder));
            mc.Clear();
            for (var i = 0; i < mis.Count; i++)
            {
                mc.Add((MenuItem)mis[i]);
            }
        }
Exemple #9
0
        /// <summary>
        /// Populate the Documents dropdown list.
        /// </summary>
        private void PopulateDocuments()
        {
            Menu.MenuItemCollection items =
                documentsMenu.MenuItems;
            foreach (MenuItem item in items)
            {
                item.Click -= new EventHandler(DocumentClick);
            }
            items.Clear();

            foreach (Control ctl in Panel1.Controls)
            {
                if (ctl is WinPart)
                {
                    MenuItem item = new MenuItem();
                    item.Text   = ((WinPart)ctl).ToString();
                    item.Tag    = ctl;
                    item.Click += new EventHandler(DocumentClick);
                    items.Add(item);
                }
            }

            DocumentsToolStripDropDownButton.Update();
        }
Exemple #10
0
        /// <summary>
        /// Re-build the context menus.
        /// </summary>
        private void InitializeContextMenus(DirectoryInfo dir)
        {
            var timer = new Stopwatch();

            ++contextMenuCount;

            try
            {
                Menu.MenuItemCollection items = this.form.DirTreeMenu.MenuItems;
                items.Clear();

                List <MenuItem> menuList = new List <MenuItem>();


                if (this.isFtpSite)
                {
                    foreach (IScript script in this.scriptManager.FtpFolderScripts)
                    {
                        MenuItem temp = new MenuItem(script.LongName
                                                     , new EventHandler(this.FolderScriptMenuItemHandler)
                                                     , script.ScriptShortCut);

                        temp.Enabled = script.Active;
                        menuList.Add(temp);
                    }
                }
                else
                {
                    this.form.DirTreeMenu.MenuItems.Clear();
                    this.form.DirTreeMenu.MenuItems.AddRange(

                        this.scriptManager.FolderScripts.Where(fs => (fs.ValidatorFolder == null || fs.ValidatorFolder(dir)))
                        .Select(fs => new MenuItem(fs.LongName, new EventHandler(this.FolderScriptMenuItemHandler), fs.ScriptShortCut)
                    {
                        Enabled = fs.Active
                    })
                        .OrderBy(m => m.Text)
                        .ToArray()
                        );
                }

                timer.Start();
                this.form.FileGridMenuStrip.Items.Clear();

                this.scriptManager.FileScripts.OrderBy(fs => fs.LongName)
                .ToList()
                .ForEach(fs =>
                         this.form.FileGridMenuStrip.Items.Add(fs.LongName)
                         );


                this.form.DataGridView1.KeyPress += new KeyPressEventHandler(DataGridView1_KeyPress);
                //  this.form.DataGridView1.UserDeletingRow += new DataGridViewRowCancelEventHandler(DataGridView1_UserDeletingRow);



                var scripts = new List <IScript>();
                if (isFtpSite)
                {
                    scripts.AddRange(this.scriptManager.FTPFileScripts.ToArray());
                }
                else
                {
                    scripts.AddRange(this.scriptManager.FileScripts.ToArray());
                }

                var x = 1;
            }
            finally
            {
                timer.Stop();
                totalContextTime += timer.ElapsedMilliseconds;

                if (timer.ElapsedMilliseconds > 1500)
                {
                    Console.Out.WriteLine("Build context menu took:"
                                          + timer.ElapsedMilliseconds.ToString()
                                          + " for "
                                          + dir.FullName);
                }
            }
        }
Exemple #11
0
        /**
         * Fills the menu with actions, depending on the specified context.
         */

        public void FillMenu(IActionContext context)
        {
            if (_persistentMnemonics)
            {
                if (!_mnemonicsAssigned)
                {
                    AssignMnemonics();
                    _mnemonicsAssigned = true;
                }
            }
            else
            {
                ResetUsedMnemonics();
            }
            _lastContext = context;

            MenuActionGroup lastGroup = null;

            MenuItem curSubmenu = null;

            Menu.MenuItemCollection curMenuItems = _menuItems;

            _menuItems.Clear();
            _itemToActionMap.Clear();
            HashSet usedShortcuts = new HashSet();
            int     submenuVisibleActions = 0, submenuEnabledActions = 0;
            bool    haveDefaultAction = false;

            string[] resTypes = context.SelectedResources.GetAllTypes();

            foreach (MenuActionGroup group in _actionGroups)
            {
                if (lastGroup != null && !IsSeparatorSuppressed(group, lastGroup))
                {
                    _menuItems.Add("-");
                }

                if (group.SubmenuName != null)
                {
                    if (lastGroup == null || group.SubmenuName != lastGroup.SubmenuName)
                    {
                        curSubmenu            = _menuItems.Add(group.SubmenuName);
                        curMenuItems          = curSubmenu.MenuItems;
                        submenuVisibleActions = 0;
                        submenuEnabledActions = 0;
                    }
                    else
                    {
                        curMenuItems.Add("-");
                    }
                }
                else
                {
                    if (curSubmenu != null)
                    {
                        if (submenuVisibleActions == 0)
                        {
                            curSubmenu.Visible = false;
                        }
                        else if (submenuEnabledActions == 0)
                        {
                            curSubmenu.Enabled = false;
                        }
                    }
                    curMenuItems = _menuItems;
                    curSubmenu   = null;
                }
                lastGroup = group;

                foreach (MenuAction action in group.Actions)
                {
                    if (action.ResourceType != null)
                    {
                        if (resTypes.Length != 1 || resTypes [0] != action.ResourceType)
                        {
                            if (_disableUnmatchingTypeActions)
                            {
                                MenuItem stubItem = curMenuItems.Add(action.Name);
                                stubItem.Enabled = false;
                                submenuVisibleActions++;
                            }
                            continue;
                        }
                    }

                    MenuItem item = AddActionToMenu(action, curMenuItems, context, usedShortcuts);
                    if (!haveDefaultAction && context.SelectedResources.Count == 1 &&
                        Core.ActionManager.GetDoubleClickAction(context.SelectedResources [0]) == action.Action)
                    {
                        item.DefaultItem  = true;
                        haveDefaultAction = true;
                    }
                    if (item.Visible)
                    {
                        submenuVisibleActions++;
                    }
                    if (item.Enabled)
                    {
                        submenuEnabledActions++;
                    }
                }
            }

            if (curSubmenu != null)
            {
                if (submenuVisibleActions == 0)
                {
                    curSubmenu.Visible = false;
                }
                else if (submenuEnabledActions == 0)
                {
                    curSubmenu.Enabled = false;
                }
            }

            UpdateSeparatorVisibility(_menuItems);
        }