Exemplo n.º 1
0
        /// <summary>
        ///   This method adds the passed menu entry to the list of entries which appear on the Tool Bar, if it does
        ///   not exist in the array already
        /// </summary>
        /// <param name = "menuEntry">a menu Entry object to be added to the list</param>
        public void addEntryToInternalEventsOnToolBar(MenuEntryEvent menuEntry)
        {
            List <MenuEntryEvent> entries = null;

            if (menuEntry.InternalEvent > 0)
            {
                entries = (List <MenuEntryEvent>)_internalEventsOnToolBar[menuEntry.InternalEvent];
                if (entries == null)
                {
                    entries = new List <MenuEntryEvent>();
                }
                entries.Add(menuEntry);
                _internalEventsOnToolBar[menuEntry.InternalEvent] = entries;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///   This method enables\ disables all internal event menu items which match the passed
        ///   action number, on the passed form, to the passed enable state.
        /// </summary>
        /// <param name = "form">on which we refresh this action state</param>
        /// <param name = "action">action whose enable state changed</param>
        /// <param name = "enable">new state of the action</param>
        public void enableInternalEvent(MgFormBase form, int action, bool enable, MgFormBase mdiChildForm)
        {
            List <MenuEntryEvent> entries   = getInternalEventsEntriesOnMenu(action);
            MgFormBase            frameForm = (form != null
                                    ? form.getTopMostFrameFormForMenuRefresh() :
                                               form);

            if (entries != null)
            {
                for (int i = 0; i < entries.Count; i++)
                {
                    MenuEntryEvent actionMenu = entries[i];

                    if ((actionMenu.InternalEvent < InternalInterface.MG_ACT_USER_ACTION_1) ||
                        (actionMenu.InternalEvent > InternalInterface.MG_ACT_USER_ACTION_20))
                    {
                        if (frameForm != null)
                        {
                            EnableMenuEntry(actionMenu, frameForm, MenuStyle.MENU_STYLE_PULLDOWN, enable);
                        }
                        MgFormBase contextMenuForm = mdiChildForm != null ? mdiChildForm : form;
                        EnableMenuEntry(actionMenu, contextMenuForm, MenuStyle.MENU_STYLE_CONTEXT, enable);
                    }
                }
            }

            entries = getInternalEventsEntriesOnToolBar(action);
            if (entries != null)
            {
                for (int i = 0; i < entries.Count; i++)
                {
                    MenuEntryEvent actionMenu = entries[i];
                    if ((actionMenu.InternalEvent < InternalInterface.MG_ACT_USER_ACTION_1) ||
                        (actionMenu.InternalEvent > InternalInterface.MG_ACT_USER_ACTION_20))
                    {
                        if (frameForm != null)
                        {
                            EnableMenuEntry(actionMenu, frameForm, MenuStyle.MENU_STYLE_TOOLBAR, enable);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name = "enabled">
        /// </param>
        /// <param name = "checkValidation:">to check the validation of the set value
        ///   @return : error number if the method was faild.
        /// </param>
        /// <param name = "refresh">refresh will decide if gui refresh is to be performed or not.
        /// </param>
        public void setEnabled(bool enabled, bool checkValidation, bool checkEnableSystemAction, String checkForName,
                               bool IsChildOfCheckForName, bool refresh)
        {
            if (checkValidation)
            {
                //bug #:293070 If MnuEnable () is called on menu, we should disable it's menu entries as well. (in online it is bug #:927017)
                if (menuType() == MenuType.MENU)
                {
                    bool NewIsChildOfCheckForName = IsChildOfCheckForName || (checkForName == null) ||
                                                    (_name != null && _name.CompareTo(checkForName) == 0);

                    for (int i = 0;
                         i < ((MenuEntryMenu)this).subMenus.Count;
                         i++)
                    {
                        MenuEntry subMenuEntry = (((MenuEntryMenu)this).subMenus[i]);
                        subMenuEntry.setEnabled(enabled, checkValidation, checkEnableSystemAction, checkForName,
                                                NewIsChildOfCheckForName, refresh);
                    }
                }

                if (checkEnableSystemAction && this is MenuEntryEvent)
                {
                    MenuEntryEvent menuEntryEvent  = (MenuEntryEvent)this;
                    bool           notAllowDisable = ((menuEntryEvent.menuType() == MenuType.INTERNAL_EVENT) &&
                                                      ((menuEntryEvent.InternalEvent < InternalInterface.MG_ACT_USER_ACTION_1) ||
                                                       (menuEntryEvent.InternalEvent > InternalInterface.MG_ACT_USER_ACTION_20)));

                    if (notAllowDisable)
                    {
                        return;
                    }
                }

                if (menuType() == MenuType.PROGRAM)
                {
                    MenuEntryProgram mp = (MenuEntryProgram)this;
                    if (mp.Idx <= 0)
                    {
                        enabled = false;
                    }
                }
                else if (menuType() == MenuType.INTERNAL_EVENT)
                {
                    MenuEntryEvent me = (MenuEntryEvent)this;
                    if (me.InternalEvent == 0)
                    {
                        enabled = false;
                    }
                }
                else if (menuType() == MenuType.USER_EVENT)
                {
                    MenuEntryEvent me = (MenuEntryEvent)this;
                    if (me.UserEvtIdx == 0)
                    {
                        enabled = false;
                    }
                }
            }

            bool activateEanble = (menuType() == MenuType.MENU) ||
                                  (checkForName == null) || (_name != null && _name.CompareTo(checkForName) == 0);

            // fixed bugs#:293070 & 754704, (as we doing for online in gui_mnut.cpp \EnableMenu()
            // when try to enale\disable menu entry item we need to set the comman type without to update the member Enable
            if (IsChildOfCheckForName)
            {
                if (refresh)
                {
                    ICollection mnuRefs = getInstantiatedMenus(null, true, true, true);

                    if (enabled)
                    {
                        //try to enable menu that is not enabled
                        if (!_menuState.Enabled)
                        {
                            enabled = false;
                        }
                    }

                    addAllRefsToCmdQueue(mnuRefs, CommandType.PROP_SET_ENABLE, enabled);
                }
            }
            else if (activateEanble)
            {
                if (!getModalDisabled())
                {
                    _menuState.Enabled = enabled;
                }

                if (refresh)
                {
                    ICollection mnuRefs = getInstantiatedMenus(true);
                    addAllRefsToCmdQueue(mnuRefs, CommandType.PROP_SET_ENABLE, enabled);
                }
            }
        }
Exemplo n.º 4
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;
            }
        }