Exemple #1
0
        /// <summary>
        /// Delete MenuEntries created for WindowList
        /// </summary>
        /// <param name="menuEntryMenu">MenuEntry containing window list menu item</param>
        /// <param name="windowMenuIdx">index from where to start deleting menuentries </param>
        private void DeleteWindowMenuEntries(MenuEntry menuEntryMenu, int windowMenuIdx, bool IsMenuEntryWindowMenu)
        {
            Debug.Assert(Misc.IsGuiThread());

            if (windowMenuIdx > 0)
            {
                int              offset             = windowMenuIdx;
                bool             bRemoveFromSubMenu = false; // check whether we need this / not.
                List <MenuEntry> menuEntryList;

                if (IsMenuEntryWindowMenu)
                {
                    menuEntryList = menuEntryMenu.getParentMgMenu().MenuEntries;
                }
                else
                {
                    menuEntryList = ((MenuEntryMenu)menuEntryMenu).subMenus;
                }

                while (offset < menuEntryList.Count)
                {
                    MenuEntry menuEntry = menuEntryList[offset++];
                    if ((menuEntry is MenuEntryWindowMenu) ||
                        (menuEntry.menuType() == GuiMenuEntry.MenuType.SEPARATOR))
                    {
                        // Delete existing ToolStripMenuItem if exists.
                        // Window menu entries are deleted before they are created on the fly(before menu gets opened).
                        // And hence while removing them remove it from PullDown as well as Context menu.
                        ICollection mnuReference = menuEntry.getInstantiatedMenus(MenuStyle.MENU_STYLE_PULLDOWN);
                        DeleteMenuItems(mnuReference);

                        mnuReference = menuEntry.getInstantiatedMenus(MenuStyle.MENU_STYLE_CONTEXT);
                        DeleteMenuItems(mnuReference);

                        bRemoveFromSubMenu = true;
                    }
                    else
                    {
                        break;
                    }
                }

                // Remove deleted menu entries from a sub-menu.
                if (bRemoveFromSubMenu)
                {
                    menuEntryList.RemoveRange(windowMenuIdx, offset - windowMenuIdx);
                    if (IsMenuEntryWindowMenu)
                    {
                        menuEntryMenu.getParentMgMenu().setIndexes(false);
                    }
                    else
                    {
                        ((MenuEntryMenu)menuEntryMenu).setIndexes(false);
                    }
                }
            }
        }