예제 #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);
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
파일: MenuEntry.cs 프로젝트: rinavin/RCJS
        /**
         * get the tool index for method menuShow - recursively.
         * we pass all the menu entry in this menu entry calculate the index of the tool.
         * @param form : the form that we work on it
         * @param mgValue TODO
         * @param toolGroup: the tool group that this icon need to be added.
         * @forMenuEntry: calculate the tool index for this menu entry
         * @mgValue: mgValue.bool , will return true if stop the loop
         * @return
         */

        private int getGroupCount(MgFormBase form, int toolGroup, MenuEntry forMenuEntry, ref bool found)
        {
            int count = 0;

            if (this == forMenuEntry)
            {
                found = true;
                return(count);
            }

            if (this is MenuEntryMenu)
            {
                MenuEntryMenu menuEntryMenu = ((MenuEntryMenu)this);
                for (int i = 0;
                     i < menuEntryMenu.subMenus.Count;
                     i++)
                {
                    MenuEntry subMenuEntry = (menuEntryMenu.subMenus[i]);
                    count += subMenuEntry.getGroupCount(form, toolGroup, forMenuEntry, ref found);
                    if (found)
                    {
                        break;
                    }
                }
            }
            else
            {
                //if this menu is on same tool group of the sendMenuEntry and it is before the icon of this menu entry
                if (inSameToolGroup(toolGroup))
                {
                    if ((ParentMenuEntry != forMenuEntry.ParentMenuEntry) ||
                        (getIndex() < forMenuEntry.getIndex()))
                    {
                        count++;
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                }
            }
            return(count);
        }
예제 #4
0
        /// <summary>
        ///   This function does deep copy of all elements in menuEntries ArrayList.
        /// </summary>
        /// <returns> a new object of Arraylist which contains refrences of new menuEntries objects</returns>
        private List <MenuEntry> getDeepCopyOfMenuEntries(List <MenuEntry> menuEntries)
        {
            List <MenuEntry> clonedMenuEntries = new List <MenuEntry>(menuEntries.Count);
            int i = 0;

            foreach (MenuEntry menuentry in menuEntries)
            {
                clonedMenuEntries.Add((MenuEntry)menuentry.Clone());

                if (menuentry is MenuEntryMenu)
                {
                    MenuEntryMenu menu       = (MenuEntryMenu)menuentry;
                    MenuEntryMenu clonedMenu = (MenuEntryMenu)(clonedMenuEntries[i]);
                    clonedMenu.subMenus = getDeepCopyOfMenuEntries(menu.subMenus);
                }
                i++;
            }

            return(clonedMenuEntries);
        }
예제 #5
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);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// set menu entries Modal, depedning upon the value of isModal & mainContextIsModal.
        /// </summary>
        /// <param name = "menuEntries"></param>
        /// <param name = "isModal"></param>
        /// <param name = "mainContextIsModal"></param>
        private void setModal(List <MenuEntry> menuEntries, bool isModal, bool mainContextIsModal, bool toplevel)
        {
            foreach (MenuEntry menuEntry in menuEntries)
            {
                bool applyModal = false;
                if (menuEntry is MenuEntryMenu)
                {
                    MenuEntryMenu menu = (MenuEntryMenu)menuEntry;
                    setModal(menu.subMenus, isModal, mainContextIsModal, false);
                }
                else
                {
                    applyModal = menuEntry.ShouldSetModal(isModal, mainContextIsModal);
                }

                if (applyModal)
                {
                    if (isModal)
                    {
                        // If menuEntry is enabled , then only set ModalDisabled flag & disable the menu.
                        if (menuEntry.getEnabled())
                        {
                            menuEntry.setModalDisabled(true);
                            menuEntry.setEnabled(false, true, true, null, toplevel ? true :false);
                        }
                    }
                    else
                    {
                        // If menuEntry is ModalDisabled, then only enable menuEntry & reset ModalDisabled flag.
                        if (menuEntry.getModalDisabled())
                        {
                            menuEntry.setEnabled(true, true, true, null, toplevel ? true : false);
                            menuEntry.setModalDisabled(false);
                        }
                    }
                }
            }
        }
예제 #7
0
        /// <summary>
        ///   Updates the current object (MgMenu or MenuEntry) by the parsed element values
        /// </summary>
        public override void startElement(String elementName, NameValueCollection attributes)
        {
            String str       = "";
            int    menuType  = 0;
            bool   doNothing = false;
            bool   boolVal;

            switch (elementName)
            {
            case "Menu":
                _currentMgMenu = new MgMenu();
                pushCurrentObject(_currentMgMenu);
                _mgMenus.Add(_currentMgMenu);
                break;

            case "MenuEntry":
                // we do not allocate the menu entry object yet - depends on the menu type
                _currentObjectType = CurrentObjectType.MENU_TYPE_MENU_ENTRY;
                break;

            case "Name":
                if (isMgMenu())
                {
                    _currentMgMenu.setName(attributes["val"]);
                }
                else
                {
                    _currentMenuEntry.setName(attributes["val"]);
                }
                break;

            case "MenuType":
            {
                MenuEntry newEntry = null;
                if (!isMgMenu())
                {
                    // resolve the menu entry type
                    menuType = getInt(attributes);
                    switch (menuType)
                    {
                    case MNT_TYPE_MENU:
                        newEntry = new MenuEntryMenu(_currentMgMenu);
                        break;

                    case MNT_TYPE_PROG:
                        newEntry = new MenuEntryProgram(_currentMgMenu);
                        break;

                    case MNT_TYPE_ACTION:
                        // we still do not know the type if the event (internal, system or user)
                        newEntry = new MenuEntryEvent(_currentMgMenu);
                        break;

                    case MNT_TYPE_OS:
                        newEntry = new MenuEntryOSCommand(_currentMgMenu);
                        break;

                    case MNT_TYPE_LINE:
                        // nothing to do in case of a separator
                        newEntry = new MenuEntry(GuiMenuEntry.MenuType.SEPARATOR, _currentMgMenu);
                        newEntry.setVisible(true, true, false, null);
                        break;

                    case MNT_TYPE_WINDOW_LIST:
                        newEntry = new MenuEntryWindowMenu(_currentMgMenu);
                        newEntry.setVisible(true, true, false, null);
                        break;

                    default:
                        doNothing = true;
                        break;
                    }

                    if (!doNothing)
                    {
                        // we need to attach the new menu entry to its parent menu
                        if (_objectsStack.Peek() is MgMenu)
                        {
                            _currentMgMenu.addSubMenu(newEntry);
                        }
                        else
                        {
                            ((MenuEntryMenu)_currentMenuEntry).addSubMenu(newEntry);
                        }
                        pushCurrentObject(newEntry);
                    }
                }
                break;
            }

            case "MenuUid":
                if (isMgMenu())
                {
                    _currentMgMenu.setUid(getInt(attributes));
                }
                else
                {
                    _currentMenuEntry.setUid(getInt(attributes));
                }
                break;

            case "Checked":
                boolVal = getBooleanValue(attributes);
                _currentMenuEntry.setChecked(boolVal, true);
                break;

            case "VISIBLE":
                boolVal = getBooleanValue(attributes);
                _currentMenuEntry.setVisible(boolVal, true, false, null);
                break;

            case "Enabled":
                boolVal = getBooleanValue(attributes);
                _currentMenuEntry.setEnabled(boolVal, false, false);
                break;

            case "IsParallel":
                boolVal = getBooleanValue(attributes);
                ((MenuEntryProgram)_currentMenuEntry).IsParallel = boolVal;
                break;

            case "ImageFor":
                str = attributes["val"];
                switch (str)
                {
                case "B":
                    _currentMenuEntry.Imagefor = GuiMenuEntry.ImageFor.MENU_IMAGE_BOTH;
                    break;

                case "M":
                    _currentMenuEntry.Imagefor = GuiMenuEntry.ImageFor.MENU_IMAGE_MENU;
                    break;

                default:
                    _currentMenuEntry.Imagefor = GuiMenuEntry.ImageFor.MENU_IMAGE_TOOLBAR;
                    break;
                }
                break;

            case "Icon":
                String imageFile = Events.TranslateLogicalName(attributes["val"]);
                _currentMenuEntry.ImageFile = imageFile;
                break;

            case "ToolNumber":
                _currentMenuEntry.ImageNumber = getInt(attributes);
                break;

            case "ToolGroup":
                _currentMenuEntry.ImageGroup = getInt(attributes);
                break;

            case "Tooltip_U":
                _currentMenuEntry.toolTip(attributes["val"]);
                break;

            case "Description_U":
                if (isMgMenu())
                {
                    _currentMgMenu.setText(attributes["val"]);
                }
                else
                {
                    _currentMenuEntry.setText(attributes["val"], true);
                }
                break;

            case "Help":
            {
                int help = getInt(attributes, "obj");
                if (_currentMenuEntry is MenuEntryEvent)
                {
                    ((MenuEntryEvent)_currentMenuEntry).Help = help;
                }
                else if (_currentMenuEntry is MenuEntryOSCommand)
                {
                    ((MenuEntryOSCommand)_currentMenuEntry).Help = help;
                }
                else if (_currentMenuEntry is MenuEntryProgram)
                {
                    ((MenuEntryProgram)_currentMenuEntry).Help = help;
                }
                break;
            }

            case "Prompt":
            {
                String prompt = attributes["val"];
                if (_currentMenuEntry is MenuEntryEvent)
                {
                    ((MenuEntryEvent)_currentMenuEntry).Prompt = prompt;
                }
                else if (_currentMenuEntry is MenuEntryOSCommand)
                {
                    ((MenuEntryOSCommand)_currentMenuEntry).Prompt = prompt;
                }
                else if (_currentMenuEntry is MenuEntryProgram)
                {
                    ((MenuEntryProgram)_currentMenuEntry).Prompt = prompt;
                }
                break;
            }

            case "DestinationContext":
            {
                String destContext = attributes["val"];
                if (_currentMenuEntry is MenuEntryEvent)
                {
                    ((MenuEntryEvent)_currentMenuEntry).DestinationContext = destContext;
                }
                break;
            }

            case "SourceContext":
            {
                String val = attributes["val"];
                ((MenuEntryProgram)_currentMenuEntry).SourceContext = (MenuEntryProgram.SrcContext)XmlParser.getInt(val);
                break;
            }

            case "FieldID":
            {
                String val = attributes["val"];
                ((MenuEntryProgram)_currentMenuEntry).ReturnCtxIdVee = (char)XmlParser.getInt(val);
                break;
            }

            case "Program":
                ((MenuEntryProgram)_currentMenuEntry).Idx        = getInt(attributes, "obj");
                ((MenuEntryProgram)_currentMenuEntry).Comp       = getInt(attributes, "comp");
                ((MenuEntryProgram)_currentMenuEntry).ProgramIsn = getInt(attributes, "ObjIsn");
                ((MenuEntryProgram)_currentMenuEntry).CtlIndex   = getInt(attributes, "CtlIndex");
                (_currentMenuEntry).setEnabled((_currentMenuEntry).getEnabled(), true, false);
                break;

            case "PublicName":
                ((MenuEntryProgram)_currentMenuEntry).PublicName = attributes["val"];
                break;

            case "COPY_GLOBAL_PARAMS":
            {
                bool copyGlobalParameters = false;

                if (attributes["val"].Equals("Y"))
                {
                    copyGlobalParameters = true;
                }

                ((MenuEntryProgram)_currentMenuEntry).CopyGlobalParameters = copyGlobalParameters;
                break;
            }

            case "Arguments":
                if (_currentMenuEntry is MenuEntryProgram)
                {
                    ((MenuEntryProgram)_currentMenuEntry).MainProgVars = new List <String>();
                }
                else if (_currentMenuEntry is MenuEntryEvent)
                {
                    ((MenuEntryEvent)_currentMenuEntry).MainProgVars = new List <String>();
                }
                break;

            case "Argument":
                _inArgumentTag = true;
                break;

            case "Variable":
                if (_inArgumentTag)
                {
                    if (_currentMenuEntry is MenuEntryProgram)
                    {
                        ((MenuEntryProgram)_currentMenuEntry).MainProgVars.Add(attributes["val"]);
                    }
                    else if (_currentMenuEntry is MenuEntryEvent)
                    {
                        ((MenuEntryEvent)_currentMenuEntry).MainProgVars.Add(attributes["val"]);
                    }
                }
                break;

            case "Skip":
                if (_inArgumentTag && attributes["val"].Equals("Y"))
                {
                    if (_currentMenuEntry is MenuEntryProgram)
                    {
                        ((MenuEntryProgram)_currentMenuEntry).MainProgVars.Add("Skip");
                    }
                    else if (_currentMenuEntry is MenuEntryEvent)
                    {
                        ((MenuEntryEvent)_currentMenuEntry).MainProgVars.Add("Skip");
                    }
                }
                break;

            case "Ext":
                ((MenuEntryOSCommand)_currentMenuEntry).OsCommand = attributes["val"];
                break;

            case "Wait":
                ((MenuEntryOSCommand)_currentMenuEntry).Wait = getBooleanValue(attributes);
                break;

            case "Show":
            {
                String val = attributes["val"];
                ((MenuEntryOSCommand)_currentMenuEntry).Show = (CallOsShow)XmlParser.getInt(val);
                break;
            }

            case "EventType":
            {
                String val = attributes["val"];
                if (val.Equals("U"))
                {
                    _currentMenuEntry.setType(GuiMenuEntry.MenuType.USER_EVENT);
                }
                else if (val.Equals("I"))
                {
                    _currentMenuEntry.setType(GuiMenuEntry.MenuType.INTERNAL_EVENT);
                }
                else if (val.Equals("S"))
                {
                    _currentMenuEntry.setType(GuiMenuEntry.MenuType.SYSTEM_EVENT);
                }
                break;
            }

            case "Event":
                _inEventTag = true;
                break;

            case "Parent":
                if (_inEventTag)
                {
                    ((MenuEntryEvent)_currentMenuEntry).UserEvtTaskId = attributes["val"];
                }
                break;

            case "PublicObject":
                if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.USER_EVENT)
                {
                    ((MenuEntryEvent)_currentMenuEntry).UserEvtIdx       = getInt(attributes, "obj");
                    ((MenuEntryEvent)_currentMenuEntry).UserEvtCompIndex = getInt(attributes, "comp");
                }
                break;

            case "Modifier":
                if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.SYSTEM_EVENT ||
                    _inAccessKeyTag)
                {
                    _modifier = (Modifiers)attributes["val"][0];
                }
                break;

            case "Key":
                if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.SYSTEM_EVENT ||
                    _inAccessKeyTag)
                {
                    _keyCode = getInt(attributes);
                }
                break;

            case "InternalEventID":
                if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.INTERNAL_EVENT)
                {
                    ((MenuEntryEvent)_currentMenuEntry).InternalEvent = getInt(attributes);
                    _currentMenuEntry.setEnabled((_currentMenuEntry).getEnabled(), true, false);
                }
                break;

            case "AccessKey":
                _inAccessKeyTag = true;
                break;

            case "PrgDescription":
                ((MenuEntryProgram)_currentMenuEntry).Description = attributes["val"];
                break;

            case "PrgFlow":
                ((MenuEntryProgram)_currentMenuEntry).Flow = attributes["val"][0];
                break;
            }
        }