Ejemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name = "menuEntry"></param>
        /// <param name = "menuUid"></param>
        /// <returns></returns>
        private MenuEntry getMenuEntryByUid(MenuEntry menuEntry, int menuUid)
        {
            MenuEntry menuEntryByUid = null;

            if (menuEntry.menuType() == GuiMenuEntry.MenuType.MENU)
            {
                MenuEntryMenu menuEntryMenu  = (MenuEntryMenu)menuEntry;
                IEnumerator   iMenuEntryMenu = menuEntryMenu.iterator();
                while (iMenuEntryMenu.MoveNext())
                {
                    MenuEntry menuEntryNext = (MenuEntry)iMenuEntryMenu.Current;
                    if (menuEntryNext.menuUid() == menuUid)
                    {
                        return(menuEntryNext);
                    }
                    if (menuEntryNext.menuType() == GuiMenuEntry.MenuType.MENU)
                    {
                        menuEntryByUid = getMenuEntryByUid(menuEntryNext, menuUid);
                        if (menuEntryByUid != null)
                        {
                            if (menuEntryByUid.menuUid() == menuUid)
                            {
                                return(menuEntryByUid);
                            }
                        }
                    }
                }
            }
            return(menuEntryByUid);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Gets the menu entry from its Uid.
        /// </summary>
        /// <param name = "menuUid">Uid whose corresponding menu entry is to be found</param>
        /// <returns></returns>
        public MenuEntry menuByUid(int menuUid)
        {
            MenuEntry   menuEntryByUid = null;
            IEnumerator iMgMenu        = menus.GetEnumerator();

            while (iMgMenu.MoveNext())
            {
                MgMenu      mgmenu     = (MgMenu)iMgMenu.Current;
                IEnumerator iMenuEntry = mgmenu.iterator();
                while (iMenuEntry.MoveNext())
                {
                    MenuEntry menuEntry = (MenuEntry)iMenuEntry.Current;
                    if (menuEntry.menuUid() == menuUid)
                    {
                        menuEntryByUid = menuEntry;
                        return(menuEntryByUid);
                    }
                    if (menuEntry.menuType() == GuiMenuEntry.MenuType.MENU)
                    {
                        menuEntryByUid = getMenuEntryByUid(menuEntry, menuUid);
                        if (menuEntryByUid != null)
                        {
                            if (menuEntryByUid.menuUid() == menuUid)
                            {
                                return(menuEntryByUid);
                            }
                        }
                    }
                }
            }
            return(menuEntryByUid);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///   This method updates the indexes of the menu's children
        /// </summary>
        /// <param name = "drillDown">-
        ///   tells us if we need to perform the same for all sub menus, or only for the entries in the
        ///   current level
        /// </param>
        public void setIndexes(bool drillDown)
        {
            int         Idx       = 0;
            IEnumerator iInnerMnt = iterator();

            while (iInnerMnt.MoveNext())
            {
                MenuEntry innerMnt = (MenuEntry)iInnerMnt.Current;
#if  !PocketPC
                innerMnt.setIndex(++Idx);
#else
                if (innerMnt.getVisible())
                {
                    innerMnt.setIndex(++Idx);
                }
                else
                {
                    innerMnt.setIndex(-1);
                }
#endif

                if (drillDown && innerMnt.menuType() == MenuType.MENU)
                {
                    ((MenuEntryMenu)innerMnt).setIndexes(drillDown);
                }
            }
        }
Ejemplo n.º 4
0
        /// <param name = "drillDown">- tells us if we need to perform the same for all sub menus, or only
        ///   for the entries in the current level
        /// </param>
        public void setIndexes(bool drillDown)
        {
            int         Idx        = 0;
            IEnumerator iMenuEntry = iterator();

            while (iMenuEntry.MoveNext())
            {
                MenuEntry menuEntry = (MenuEntry)iMenuEntry.Current;
#if  !PocketPC
                menuEntry.setIndex(++Idx);
#else
                if (menuEntry.getVisible())
                {
                    menuEntry.setIndex(++Idx);
                }
                else
                {
                    menuEntry.setIndex(-1);
                }
#endif

                if (drillDown && menuEntry.menuType() == GuiMenuEntry.MenuType.MENU)
                {
                    ((MenuEntryMenu)menuEntry).setIndexes(drillDown);
                }
            }
        }
Ejemplo n.º 5
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);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///   This method adds the passed menu entry to the list of menu entries with access key
        ///   the key will be : access key & modifier
        /// </summary>
        /// <param name = "menuEntry">a menu Entry object to be added to the list</param>
        public void addEntryToMenuEntriesWithAccessKey(MenuEntry menuEntry)
        {
            List <MenuEntry> entries = null;

            //MENU_TYPE_INTERNAL_EVENT will handel from the keybord mapping
            if (menuEntry.AccessKey != null && menuEntry.menuType() != GuiMenuEntry.MenuType.INTERNAL_EVENT)
            {
                String key = "" + menuEntry.AccessKey.getKeyCode() + menuEntry.AccessKey.getModifier();
                entries = (List <MenuEntry>)_menuEntriesWithAccessKey[key];
                if (entries == null)
                {
                    entries = new List <MenuEntry>();
                }
                entries.Add(menuEntry);
                _menuEntriesWithAccessKey[key] = entries;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///   Refresh the text of the menu entry.
        ///   If this menu entry is a menu itself, call this method recursively.
        /// </summary>
        public void refreshRecursiveMenuesEntryMls(MenuEntry menuEntry)
        {
            // 1st refresh the menuentry text
            menuEntry.refreshText();

            // for menu type entry, do a recursive call for each entry.
            if (menuEntry.menuType() == GuiMenuEntry.MenuType.MENU)
            {
                MenuEntryMenu menuEntryMenu  = (MenuEntryMenu)menuEntry;
                IEnumerator   iMenuEntryMenu = menuEntryMenu.iterator();
                while (iMenuEntryMenu.MoveNext())
                {
                    MenuEntry menuEntryNext = (MenuEntry)iMenuEntryMenu.Current;
                    // recursive call for each menu entry.
                    refreshRecursiveMenuesEntryMls(menuEntryNext);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///   Builds actual array list containing menu entries matching the entry name
        /// </summary>
        /// <param name = "EntryName">Sring Entry name to be searched</param>
        /// <param name = "menuEntry">Root menu entry</param>
        /// <param name = "matchingMnuEntries">Out parameter that will have the matching entries.</param>
        /// <param name="isPulldown"></param>
        /// <returns></returns>
        private void BuildMatchingMenuValues(String entryName, IEnumerator iInnerMnt, bool isPulldown, ArrayList matchingMnuEntries)
        {
            while (iInnerMnt.MoveNext())
            {
                MenuEntry innerMnt = (MenuEntry)iInnerMnt.Current;

                String mntName = innerMnt.getName();
                if (mntName != null && (String.CompareOrdinal(mntName, entryName) == 0))
                {
                    AddMenuValue(matchingMnuEntries, isPulldown, innerMnt);
                }

                if (innerMnt.menuType() == GuiMenuEntry.MenuType.MENU)
                {
                    MenuEntryMenu menuEntMenu = (MenuEntryMenu)innerMnt;
                    IEnumerator   iMenuEntry  = menuEntMenu.iterator();

                    BuildMatchingMenuValues(entryName, iMenuEntry, isPulldown, matchingMnuEntries);
                }
            }
        }