/// <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> /// 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); }