/** * 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); }
/** * get the tool index for method menuShow. * we pass all the menu entry in the MgMenu and calculate the index of the tool. * @param form : the form that we work on it * @param toolGroup: the tool group that this icon need to be added. * @forMenuEntry: calculate the tool index for this menu entry * @return */ private int calcToolbarIndex(MgFormBase form, int toolGroup, MenuEntry forMenuEntry) { int count = 0; MgMenu mgMenu = form.getMgMenu(MenuStyle.MENU_STYLE_PULLDOWN); bool found = false; IEnumerator iMenuEntry = mgMenu.iterator(); while (iMenuEntry.MoveNext()) { MenuEntry menuEntry = (MenuEntry)iMenuEntry.Current; //get the count from this menu recursively count += menuEntry.getGroupCount(form, toolGroup, forMenuEntry, ref found); if (found) { break; } } return(count); }