/// <summary> /// Get matching menu entries from menus of all ctls opened. /// </summary> /// <param name = "entryName">name to be matched</param> /// <param name = "currentPulldownMenu">current pulldown menu</param> private ArrayList GetMatchingMenuValues(Int64 contextID, String entryName, MgMenu currentPulldownMenu) { entryName = entryName.Trim(); ArrayList menuEntryList = new ArrayList(); // Go through all ctls to get matching menus int ctlIdx = 0; TaskBase mainProg = (TaskBase)Manager.MGDataTable.GetMainProgByCtlIdx(contextID, ctlIdx); while (mainProg != null) { ApplicationMenus menus = getApplicationMenus(mainProg); if (menus != null) { ArrayList tempMenuEntryList = menus.GetMatchingMenuValues(entryName, currentPulldownMenu); if (tempMenuEntryList != null) { menuEntryList.AddRange(tempMenuEntryList); } } ctlIdx++; mainProg = (TaskBase)Manager.MGDataTable.GetMainProgByCtlIdx(contextID, ctlIdx); } return(menuEntryList); }
/// <summary> /// Sets the menu entry text of a menu entry. /// </summary> /// <param name = "task"></param> /// <param name = "entryName">menuentry name</param> /// <param name = "entryText">new menuentry text</param> public bool SetMenuName(TaskBase task, String entryName, String entryText) { bool isNameSet = false; MgMenu pulldownMenu = GetPulldownMenu(task); // Get matching menus from all ctls ArrayList menuEntryList = GetMatchingMenuValues(task.ContextID, entryName, pulldownMenu); if (menuEntryList != null) { IEnumerator iMatchingEnt = menuEntryList.GetEnumerator(); while (iMatchingEnt.MoveNext()) { var menuValue = (MenuValue)iMatchingEnt.Current; var mnuEnt = menuValue.InnerMenuEntry; bool refresh; if (menuValue.IsPulldown) { refresh = true; } else { refresh = false; } mnuEnt.setText(entryText, refresh); isNameSet = true; } } return(isNameSet); }
/// <summary> Refresh internal actions used in Menus </summary> /// <param name = "guiMgMenu"></param> /// <param name = "guiMgForm"></param> private void refreshMenuActions(GuiMgMenu guiMgMenu, GuiMgForm guiMgForm) { MgMenu mgMenu = (MgMenu)guiMgMenu; MgFormBase mgForm = (MgFormBase)guiMgForm; if (mgMenu != null) { mgMenu.refreshInternalEventMenus(mgForm); } }
/// <summary> /// Get pulldown Menu. /// </summary> /// <param name = "task"></param> private MgMenu GetPulldownMenu(TaskBase task) { MgFormBase formOrg = (MgFormBase)task.getTopMostForm(); MgFormBase form = (formOrg != null) ? (MgFormBase)formOrg.getTopMostFrameForm() : null; form = (form ?? formOrg); MgMenu pulldownMenu = (form != null) ? form.getPulldownMenu() : null; return(pulldownMenu); }
/// <summary> /// enable/disable menu entry identified by entryName. /// </summary> /// <param name = "task"></param> /// <param name = "entryName">menuentry name</param> /// <param name = "enable">enable/disable value</param> public bool MenuEnableByName(TaskBase task, String entryName, bool enable) { bool internalEventMenuEnabled = false; MgMenu pulldownMenu = GetPulldownMenu(task); // Get matching menus from all ctls ArrayList menuEntryList = GetMatchingMenuValues(task.ContextID, entryName, pulldownMenu); if (menuEntryList != null) { IEnumerator iMatchingEnt = menuEntryList.GetEnumerator(); while (iMatchingEnt.MoveNext()) { var menuValue = (MenuValue)iMatchingEnt.Current; var mnuEnt = menuValue.InnerMenuEntry; if (mnuEnt.menuType() == GuiMenuEntry.MenuType.INTERNAL_EVENT) { MenuEntryEvent menuEntryEvent = (MenuEntryEvent)mnuEnt; if ((menuEntryEvent.InternalEvent < InternalInterface.MG_ACT_USER_ACTION_1) || (menuEntryEvent.InternalEvent > InternalInterface.MG_ACT_USER_ACTION_20)) { internalEventMenuEnabled = true; } } bool refresh; if (menuValue.IsPulldown) { refresh = true; } else { refresh = false; } //set the ModalDisabled flag, depending upon the value of enable. if (!enable) { mnuEnt.setModalDisabled(false); } mnuEnt.setEnabled(enable, true, true, entryName, refresh); } if (internalEventMenuEnabled) { Manager.WriteToMessagePanebyMsgId(task, MsgInterface.MENU_STR_ERROR_ENABLE, false); } } return(true); }
/// <summary> /// Set pulldown menu Modal depending upon value of isModal. /// </summary> /// <param name = "contextID"></param> /// <param name = "isModal"></param> public void SetModal(Int64 contextID, bool isModal) { MgFormBase frameForm = Events.GetRuntimeContext(contextID).FrameForm; if (frameForm != null) { MgMenu pulldownMenu = frameForm.getPulldownMenu(); if (pulldownMenu != null) { bool mainContextIsModal = Events.IsBatchRunningInMainContext(); pulldownMenu.SetModal(isModal, mainContextIsModal); } } }
/// <summary> This method returns the control/form's context menu </summary> /// <param name = "guiMgControl"></param> /// <returns></returns> private GuiMgMenu getContextMenu(Object obj) { MgMenu mgMenu = null; if (obj is MgControlBase) { mgMenu = ((MgControlBase)obj).getContextMenu(true); } else if (obj is MgFormBase) { mgMenu = ((MgFormBase)obj).getContextMenu(true); } return(mgMenu); }
/// <summary> /// Refresh the pulldown menu actions. /// </summary> /// <param name = "frameForm"></param> public void RefreshPulldownMenuActions(MgFormBase frameForm) { MenuStyle[] stylesToRefresh = new[] { MenuStyle.MENU_STYLE_PULLDOWN, MenuStyle.MENU_STYLE_TOOLBAR }; foreach (var style in stylesToRefresh) { // refresh the actions MgMenu mgMenu = frameForm.getMgMenu(style); if (mgMenu != null) { mgMenu.refreshMenuAction(frameForm, style); } } }
/// <summary> /// This method initializes an application’s menus object, from the passed menusFileName /// (loads the menus xml file to matching data structures). /// </summary> /// <param name="mainProg"></param> /// <returns></returns> public ApplicationMenus getApplicationMenus(TaskBase mainProg) { if (mainProg == null) { return(null); } // build the menus file URL from the name and the rights hash code String menusKey = mainProg.getMenusFileURL(); ApplicationMenus appMenus = null; if (menusKey != null) { appMenus = (ApplicationMenus)_applicationMenusMap[menusKey]; if (appMenus == null) { try { byte[] menusFileContent = mainProg.getMenusContent(); // build the application menus appMenus = new ApplicationMenus(menusFileContent); // set the indexes of the menu entries relative to their immediate parents. // also set the CtlIdx of the application that contains the menu on the MgMenu, int CtlIdx = mainProg.getCtlIdx(); IEnumerator iMgMenu = appMenus.iterator(); while (iMgMenu.MoveNext()) { MgMenu mgmenu = (MgMenu)iMgMenu.Current; mgmenu.setIndexes(true); mgmenu.CtlIdx = CtlIdx; } _applicationMenusMap[menusKey] = appMenus; } catch (Exception ex) { Events.WriteExceptionToLog(ex); } } } return(appMenus); }
/// <summary> /// refresh the actions of all menus belonging to the current task (according to the current task state) /// </summary> /// <param name = "currentTask"></param> public void refreshMenuActionForTask(TaskBase currentTask) { MgFormBase currentForm = currentTask.getForm(); if (currentForm != null) { MgFormBase menusContainerForm; // the form containing the menus to be refreshed if (currentForm.isSubForm()) { menusContainerForm = currentForm.getSubFormCtrl().getTopMostForm(); if (menusContainerForm.IsMDIChild || menusContainerForm.IsFloatingToolOrModal) { menusContainerForm = menusContainerForm.getTopMostFrameForm(); } } else { menusContainerForm = currentForm.getTopMostFrameForm(); } if (menusContainerForm == null) { menusContainerForm = currentForm.getTopMostFrameFormForMenuRefresh(); } if (menusContainerForm != null) { MenuStyle[] stylesToRefresh = new[] { MenuStyle.MENU_STYLE_PULLDOWN, MenuStyle.MENU_STYLE_CONTEXT, MenuStyle.MENU_STYLE_TOOLBAR }; foreach (var style in stylesToRefresh) { // refresh the actions MgMenu mgMenu = menusContainerForm.getMgMenu(style); if (mgMenu != null) { mgMenu.refreshMenuAction(currentTask.getForm(), style); } } } } }
/// <param name = "mgMenu">EntryName EntryName to be checked</param> /// <param name = "entryName">EntryName to be checked</param> /// <returns> Returns true if specified entry name is found in top level menu</returns> private bool IsTopLevelMenu(MgMenu mgMenu, String entryName) { bool found = false; IEnumerator iMenuEntry = mgMenu.iterator(); while (!found && iMenuEntry.MoveNext()) { MenuEntry menuEntry = (MenuEntry)iMenuEntry.Current; String menuName = menuEntry.getName(); if (menuName != null && String.CompareOrdinal(menuName, entryName) == 0) { found = true; } } return(found); }
/// <summary> /// Search and remove menu entries that are found in delMenu. /// </summary> /// <param name = "delMenu">Menu to be deleted.</param> /// <param name = "menuPos">menu from which menu entries to be deleted</param> /// <param name = "form">Frame window</param> private void SearchAndRemoveMenuEntries(int idx, MgMenu delMenu, object menuPos, MgFormBase form) { IEnumerator iDelMenuEntry = delMenu.iterator(); while (iDelMenuEntry.MoveNext()) { IEnumerator iMenuEntry; MenuEntry delMenuEntry = (MenuEntry)iDelMenuEntry.Current; String delMenuName = delMenuEntry.TextMLS; if (menuPos is MgMenu) { iMenuEntry = ((MgMenu)menuPos).iterator(); } else { iMenuEntry = ((MenuEntryMenu)menuPos).iterator(); } SearchAndRemoveMenuEntry(idx, iMenuEntry, delMenuName, menuPos, form); } }
/// <summary> /// show/hide menu entry identified by entryName. /// </summary> /// <param name = "task"></param> /// <param name = "entryName">menuentry name</param> /// <param name = "show">show/hide value</param> public bool MenuShowByName(TaskBase task, String entryName, bool show) { bool pulldownMenuModified = false; MgMenu pulldownMenu = GetPulldownMenu(task); // Get matching menus from all ctls ArrayList menuEntryList = GetMatchingMenuValues(task.ContextID, entryName, pulldownMenu); if (menuEntryList != null) { IEnumerator iMatchingEnt = menuEntryList.GetEnumerator(); while (iMatchingEnt.MoveNext()) { var menuValue = (MenuValue)iMatchingEnt.Current; var mnuEnt = menuValue.InnerMenuEntry; if (menuValue.IsPulldown) { pulldownMenuModified = true; } mnuEnt.setVisible(show, false, menuValue.IsPulldown, task, null); } } // If the menu is being shown, then refresh 'enable' state of internal event menus if (show && pulldownMenuModified) { int ctlIdx = 0; TaskBase mainProg = (TaskBase)Manager.MGDataTable.GetMainProgByCtlIdx(task.ContextID, ctlIdx); ApplicationMenus menus = getApplicationMenus(mainProg); MgFormBase formOrg = (MgFormBase)task.getTopMostForm(); MgFormBase form = (MgFormBase)formOrg.getTopMostFrameForm(); // fixed bug#:773382, when there is no SDI\MDI need to get the org form (for the context menu) form = (form ?? formOrg); menus.refreshInternalEventMenus(form); } return(true); }
/// <summary> /// This method returns a specific menu object, which matches the passed menu index. It checks if the wanted /// menu already exists. If it does not, it calls the CreateMenu method for this entry. The matching MgMenu /// object is returned. This method will be called from the Property::RefreshDisplay. It will provide the /// Property mechanism with a matching MenuEntry to the specified menu identification. /// </summary> /// <param name="mainProg"></param> /// <param name="menuIndex"></param> /// <param name="menuStyle">type of the menu: MENU_TYPE_PULLDOWN, MENU_TYPE_CONTEXT</param> /// <param name="form"></param> /// <param name="createIfNotExist">This will decide if menu is to be created or not.</param> /// <returns></returns> public MgMenu getMenu(TaskBase mainProg, int menuIndex, MenuStyle menuStyle, MgFormBase form, bool createIfNotExist) { MgMenu retMenu = null; if (mainProg.menusAttached()) { ApplicationMenus appMenus = getApplicationMenus(mainProg); if (appMenus != null) { retMenu = appMenus.getMgMenu(menuIndex); if (createIfNotExist && retMenu != null && !retMenu.menuIsInstantiated(form, menuStyle)) { // this menu does not have a matching java object for this shell – we need to create it // Context menus are created & destroyed on the fly. For context menu, if no visible menu entry // is found at 1st level, then don't create it. Because, if no visible menu entry is found , // no popup is displayed, So menu gets instantiated but it is not destroyed as we don't get CLOSING message. if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT) { if (retMenu.isAnyMenuEntryVisible()) { retMenu.createMenu(form, menuStyle); } else { retMenu = null; } } else { retMenu.createMenu(form, menuStyle); } } } } return(retMenu); }
/// <summary> /// Reset Pulldown menu. /// </summary> /// <param name = "context task"></param> public bool MenuReset(TaskBase mainProg, TaskBase task) { MgFormBase formOrg = task.getTopMostForm(); MgFormBase form = (formOrg != null) ? formOrg.getTopMostFrameForm() : null; form = (form ?? formOrg); if (form != null) { int pulldownMenuIdx = form.getPulldownMenuNumber(); if (pulldownMenuIdx > 0) { String menusFileUrl = mainProg.getMenusFileURL(); //Suspend drawing of frame form till pulldown menu is destroy and rebuilt. Commands.addAsync(CommandType.SUSPEND_PAINT, form); //destroy and rebuild all application menus. destroyAndRebuild(menusFileUrl); Commands.addAsync(CommandType.RESUME_PAINT, form); MgMenu pulldownMenu = form.getPulldownMenu(); //recreate the pulldown menu, only if it is not instantiated.This happens only in case, if MenuRemove() //is called to remove the pulldown menu. if (!pulldownMenu.menuIsInstantiated(form, MenuStyle.MENU_STYLE_PULLDOWN)) { form.setPulldownMenuNumber(pulldownMenuIdx, true); } } } return(true); }
/// <summary> /// check/uncheck menu entry identified by entryName. /// </summary> /// <param name = "task"></param> /// <param name = "entryName">menuentry name </param> /// <param name = "check">check/uncheck value</param> public bool MenuCheckByName(TaskBase task, String entryName, bool check) { MgMenu pulldownMenu = GetPulldownMenu(task); // Get matching menus from all ctls ArrayList menuEntryList = GetMatchingMenuValues(task.ContextID, entryName, pulldownMenu); if (menuEntryList != null) { IEnumerator iMatchingEnt = menuEntryList.GetEnumerator(); while (iMatchingEnt.MoveNext()) { var menuValue = (MenuValue)iMatchingEnt.Current; var mnuEnt = menuValue.InnerMenuEntry; bool refresh; if (menuValue.IsPulldown) { refresh = true; } else { refresh = false; } mnuEnt.setChecked(check, refresh); } } if (pulldownMenu != null && IsTopLevelMenu(pulldownMenu, entryName)) { Manager.WriteToMessagePane(task, "Check/UnCheck of top level menu item is not allowed", false); } return(true); }
/// <summary> /// close the task, if the wide is open, then close is before close the task /// </summary> /// <param name = "form"> </param> /// <param name="mainPrgTask"></param> public static void Abort(MgFormBase form, TaskBase mainPrgTask) { ApplicationMenus menus = MenuManager.getApplicationMenus(mainPrgTask); MgFormBase topMostForm = form.getTopMostForm(); if (topMostForm.wideIsOpen()) { topMostForm.closeWide(); } // Context menu will not automatically dispose when form is dispose. we need to dispose it menually. if (menus != null) { menus.disposeFormContexts(form); } // remove the instantiatedToolbar as this is not removed from Dispose handler. MgMenu mgMenu = form.getPulldownMenu(); if (mgMenu != null) { mgMenu.removeInstantiatedToolbar(form); } if (form.getSubFormCtrl() == null) { // if the closing form is 'opened as a modal' then decrement the modal count on its frame window. if (form.isDialog()) { MgFormBase topMostFrameForm = form.getTopMostFrameForm(); if (topMostFrameForm != null) { topMostFrameForm.UpdateModalFormsCount(form, false); } } #if !PocketPC // If the form was added into WindowMenu then remove it from list before closing it. if (form.IsValidWindowTypeForWidowList) { Property prop = form.GetComputedProperty(PropInterface.PROP_TYPE_SHOW_IN_WINDOW_MENU); if (prop != null && prop.GetComputedValueBoolean()) { MenuManager.WindowList.Remove(form); } } #endif Commands.addAsync(CommandType.CLOSE_FORM, form); // QCR# 307199/302197: When a task closes, its form is closed, where it activates topmost form of // ParentForm. If Print Preview is activated, this is not required. Instead Print Preview form // should be activated. if (!PrintPreviewFocusManager.GetInstance().ShouldPrintPreviewBeFocused) { /* QCR #939802. This bug is since 1.9 after the check-in of version 41 of GuiCommandsQueue.cs */ /* From that version onwards, we started to set the owner of the Floating window. */ /* Now, when we close a form, the .Net Framework activates the form which spawned this form. */ /* But in this special case of the QCR, while closing the 3rd form, framework activated the */ /* 1st form instead of the 2nd. */ /* So, when pressing Esc, the 1st form got closed (and of course, because of this all forms got */ /* closed. */ /* The solution is to explicitly activate the parent form when a form is closed. */ // If interactive offline task calls, non interactive non offline task, after closing the parent task // focus is not switched back to caller task, but it is set on MDI Frame. To avoid this, activate parent // form only if called task's form is opened. MgFormBase formToBeActivated = form.ParentForm; if (form.FormToBoActivatedOnClosingCurrentForm != null) { formToBeActivated = form.FormToBoActivatedOnClosingCurrentForm; } if (formToBeActivated != null && form.getTask() != null && !form.getTask().IsParallel && //not for parallel !MgFormBase.isMDIChild(form.ConcreteWindowType) && //not for mdi children Defect 128265 form.Opened) { Commands.addAsync(CommandType.ACTIVATE_FORM, formToBeActivated.getTopMostForm()); if (form.ConcreteWindowType == WindowType.ChildWindow) { TaskBase task = formToBeActivated.getTask(); MgControlBase mgControl = task.getLastParkedCtrl(); if (mgControl != null) { Commands.addAsync(CommandType.SET_FOCUS, mgControl, mgControl.getDisplayLine(false), true); } } } } } else { // Defect 115062. For frames remove controls also from frame control. if (form.getContainerCtrl() != null) { Commands.addAsync(CommandType.REMOVE_SUBFORM_CONTROLS, form.getContainerCtrl()); } Commands.addAsync(CommandType.REMOVE_SUBFORM_CONTROLS, form.getSubFormCtrl()); } Commands.beginInvoke(); Thread.Sleep(10); }
/// <summary> /// Remove menu identified by menuIdx, in current pulldown menu at menuPath specified. /// </summary> /// <param name = "mainProg"></param> /// <param name = "menuIdx"></param> /// <param name = "menuPath"></param> public bool MenuRemove(TaskBase mainProg, TaskBase task, int menuIdx, String menuPath) { Boolean success = false; // Read all menus present inside Menu repository ApplicationMenus menus = getApplicationMenus(mainProg); int index = menuIdx; // index of the menu inside Menu repository MgMenu delMenu = menus.getMgMenu(index); // menu structure to delete MgFormBase topMostFrameForm = (MgFormBase)task.getForm() == null ? null : (MgFormBase)task.getForm().getTopMostFrameForm(); MgMenu pulldownMenu = GetPulldownMenu(task); if (delMenu == null || pulldownMenu == null) { success = false; } else { // If path, from where the menu to be deleted is Null and 1.menu to be deleted is pulldown menu. The delete pulldown menu // menu to be deleted is not pulldown menu, search the whole menu. if (String.IsNullOrEmpty(menuPath)) { success = true; if (delMenu == pulldownMenu) //remove all entries from pulldown menu { // Set PulldownMenuIdx to 0. this will reset the menu. int saveMenuIdx = topMostFrameForm.getPulldownMenuNumber(); topMostFrameForm.setPulldownMenuNumber(0, true); topMostFrameForm.setPulldownMenuNumber(saveMenuIdx, false); } else { SearchAndRemoveMenuEntries(0, delMenu, pulldownMenu, topMostFrameForm); } } // Function will fail if consecutive "\\" are found in the menu path else if (menuPath.IndexOf("\\\\") >= 0) { success = false; } // Valid Menu Path else { int idx = 0; Object menuPos = null; menuPath = menuPath.TrimEnd(' '); success = FindMenuPath(pulldownMenu, menuPath, ref menuPos, ref idx); if (success) { SearchAndRemoveMenuEntries(idx, delMenu, menuPos, topMostFrameForm); } } } if (success) { if (pulldownMenu != null) { pulldownMenu.refreshInternalEventMenus(topMostFrameForm); } } return(success); }
/// <summary> /// Add menu identified by menuIdx, in current pulldown menu at menuPath specified. /// </summary> /// <param name = "mainProg">main prog</param> /// <param name = "menuIdx">menu to be added</param> /// <param name = "menuPath">menu path</param> public bool MenuAdd(TaskBase mainProg, TaskBase task, int menuIdx, String menuPath) { Boolean success = false; // Read all menus present inside Menu repository ApplicationMenus menus = getApplicationMenus(mainProg); int index = menuIdx; // index of the menu inside Menu repository MgMenu addMenu = menus.getMgMenu(index); // menu structure to add MgMenu pulldownMenu = GetPulldownMenu(task); MgFormBase topMostFrameForm = (MgFormBase)task.getForm() == null ? null : (MgFormBase)task.getForm().getTopMostFrameForm(); if (addMenu == null) { success = false; } // Add Menu to Current Pulldown Menu, only if the menu to add is not Current Pulldown Menu else if (pulldownMenu != null && topMostFrameForm.getPulldownMenuNumber() > 0 && index != topMostFrameForm.getPulldownMenuNumber()) { // if new menu is to be added, make a new menu by clone instead of using the same reference var clonedMenu = (MgMenu)addMenu.Clone(); MgMenu root = topMostFrameForm.getPulldownMenu(); bool includeInMenu = topMostFrameForm.isUsedAsPulldownMenu(root); bool includeInContext = topMostFrameForm.isUsedAsContextMenu(root); // If path, where the menu is to be added, is Null, then add the menu at the end of Current Pulldown Menu. if (String.IsNullOrEmpty(menuPath)) { // If menu is not instantiated, it means old menu is deleted, so assign new menu as pulldown menu. if (pulldownMenu.getInstantiatedMenu(topMostFrameForm, MenuStyle.MENU_STYLE_PULLDOWN) == null) { topMostFrameForm.setPulldownMenuNumber(index, true); success = true; } else if (!String.IsNullOrEmpty(clonedMenu.getName())) { IEnumerator iAddMenu = clonedMenu.iterator(); MenuEntry newMenuEntry; // Iterate through all menu entries inside Menu structure to be added, and add it to the current // Pulldown Menu Structure while (iAddMenu.MoveNext()) { newMenuEntry = (MenuEntry)iAddMenu.Current; root.addSubMenu(newMenuEntry); newMenuEntry.setParentRootMgMenu(root); // set orgindex as -1, so that resetIndexes() will recalculate orgIndex newMenuEntry.setIndex(-1); #if PocketPC // Add menu entry to the Pulldown Menu if menu entry is visible SetAddedMenuVisible(newMenuEntry, includeInMenu, task); #else // Add menu entry object to the Pulldown Menu for newly added menu entries. newMenuEntry.CreateNewlyAddedMenus(root, topMostFrameForm); #endif } success = true; } } // Function will fail if consecutive "\\" are found in the menu path else if (menuPath.IndexOf("\\\\") >= 0) { success = false; } // Valid Menu Path else { if (!String.IsNullOrEmpty(clonedMenu.getName())) { int idx = 0; Object menuPos = null; menuPath = menuPath.TrimEnd(' '); success = FindMenuPath(root, menuPath, ref menuPos, ref idx); if (success) { IEnumerator iAddMenu = clonedMenu.iterator(); MenuEntry newMenuEntry; int i = 0; // if menu to be added to root menu i.e Current Pulldown Menu if (menuPos.GetType() == typeof(MgMenu)) { while (iAddMenu.MoveNext()) { newMenuEntry = (MenuEntry)iAddMenu.Current; root.addMenu(newMenuEntry, idx + i); newMenuEntry.setParentRootMgMenu(root); // set orgindex as -1, so that resetIndexes() will recalculate orgIndex newMenuEntry.setIndex(-1); #if PocketPC // Add menu entry to the Pulldown Menu if menu entry is visible SetAddedMenuVisible(newMenuEntry, includeInMenu, task); #else // Add menu entry object to the Pulldown Menu for newly added menu entries. newMenuEntry.CreateNewlyAddedMenus(root, topMostFrameForm); #endif i++; } } else // if menu to be added to any menu entry { while (iAddMenu.MoveNext()) { newMenuEntry = (MenuEntry)iAddMenu.Current; // set the root parent menu newMenuEntry.setParentRootMgMenu(((MenuEntry)menuPos).getParentMgMenu()); // set immediate parent of the menu entry newMenuEntry.ParentMenuEntry = ((MenuEntry)menuPos).ParentMenuEntry; // set orgindex as -1, so that resetIndexes() will recalculate orgIndex newMenuEntry.setIndex(-1); ((MenuEntryMenu)menuPos).addSubMenu(newMenuEntry, idx + i); #if PocketPC // Add menu entry to the Pulldown Menu if menu entry is visible SetAddedMenuVisible(newMenuEntry, includeInMenu, task); #else // Add menu entry object to the Pulldown Menu for newly added menu entries. newMenuEntry.CreateNewlyAddedMenus(((MenuEntry)menuPos).getInstantiatedMenu(topMostFrameForm, MenuStyle.MENU_STYLE_PULLDOWN), topMostFrameForm); #endif i++; } } } } } } else { //If no pulldown menu is attached, menu to be added should be assigned as pulldown menu. if (topMostFrameForm != null) { if (topMostFrameForm.getPulldownMenuNumber() == 0) { topMostFrameForm.setPulldownMenuNumber(menuIdx, true); } else { topMostFrameForm.getProp(PropInterface.PROP_TYPE_PULLDOWN_MENU).RefreshDisplay(true, Int32.MinValue, false); } success = true; } } if (success) { if (menus != null) { menus.refreshInternalEventMenus(topMostFrameForm); } } return(success); }