/// <summary> /// Create a menuentry for WindowList items. /// </summary> /// <param name="mgFormBase">Form associated with windowmenu entry</param> /// <param name="menuType">WindowMenu/Separator</param> /// <param name="guiMgForm"></param> /// <param name="menuStyle">pulldown/context</param> /// <param name="bChecked">menuentry should be checked or not</param> /// <returns></returns> public MenuEntry CreateMenuEntryItem(MgFormBase mgFormBase, MenuType menuType, GuiMgForm guiMgForm, MenuStyle menuStyle, bool bChecked) { MenuEntry menuEntry = null; if (menuType == MenuType.WINDOW_MENU_ENTRY) { menuEntry = new MenuEntryWindowMenu(getParentMgMenu()); ((MenuEntryWindowMenu)menuEntry).SetForm(mgFormBase); //String menuText = mgFormBase.getProp(PropInterface.PROP_TYPE_FORM_NAME).getValue(); //windowMenuEntry.setText(menuText, false); //windowMenuEntry.TextMLS = Events.Translate(menuText); menuEntry.setEnabled(true, false, false); menuEntry.setChecked(bChecked, false); } else if (menuType == MenuType.SEPARATOR) { menuEntry = new MenuEntry(menuType, getParentMgMenu()); } menuEntry.setVisible(true, true, false, null); menuEntry.setMenuIsInstantiated(guiMgForm, menuStyle); return(menuEntry); }
/// <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; } }