/// <summary> /// Create a WindowMenuEntry under a MenuEntryMenu and also create a ToolSripMenuItem using Manager. /// </summary> /// <param name="mgFormBase"></param> /// <param name="menuType">WindowMenu / Separator</param> /// <param name="windowMenuIdx">Index where new menuentry should be added</param> /// <param name="guiMgForm"></param> /// <param name="menuStyle">Pulldown / Context</param> /// <param name="setChecked" public override void CreateMenuEntry(MgFormBase mgFormBase, MenuType menuType, int windowMenuIdx, GuiMgForm guiMgForm, MenuStyle menuStyle, bool setChecked) { MenuReference menuReference = getInstantiatedMenu(guiMgForm, menuStyle); MenuEntry menuEntry = base.CreateMenuEntryItem(mgFormBase, menuType, guiMgForm, menuStyle, setChecked); addSubMenu(menuEntry, windowMenuIdx + 1); setIndexes(false); // Create a corresponding ToopStripMenuItem for windowMenuEntry. Manager.CreateMenuItem(menuReference, menuEntry, guiMgForm, menuStyle, menuEntry.getIndex() - 1); }
/** * 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); }