/// <summary> /// This method creates the GUI command for the creation of the menu’s tool, as a child of the MgMenu’s /// toolbar object. Toolbar will be placed as the parentObject. /// /// Note: This method is internal in order to allow the MgMenu object to create the tool for the group /// separator. /// </summary> /// <param name = "form">form on which we create the tool on</param> /// <returns> true if a tool was defined</returns> public bool createMenuEntryTool(MgFormBase form, bool calcToolbarIndexParam) { bool hasTool = false; if (toolIsDefined() || menuType() == MenuType.SEPARATOR) { setMenuIsInstantiated(form, MenuStyle.MENU_STYLE_TOOLBAR); // create the gui command for the tool Object toolbar = _parentMgMenu.createAndGetToolbar(form); // add the tool to the matching group and get the desired index bool createSepAtTheEnd = _parentMgMenu.checkStartSepForGroup(form, ImageGroup, menuType()); int toolbarIndexForFuntion = 0; int toolbarIndex = 0; if (calcToolbarIndexParam) { //calc the index of the new tool toolbarIndexForFuntion = calcToolbarIndex(form, ImageGroup, this); for (int i = 0; i < ImageGroup; i++) { toolbarIndexForFuntion += form.getToolbarGroupCount(i); } } //add the new tool to the group toolbarIndex = _parentMgMenu.addToolToGroup(form, ImageGroup, menuType()); //if calcToolbarIndexParam is TRUE then the tool will be add to the calc index // otheriwse we will add the tool to the end if the group // toolbarIndex is the last index in the visible group, so if toolbarIndexForFuntion > toolbarIndex we // should not set toolbarIndex with toolbarIndexForFuntion. We use the index as an index in the cmd to add the item in the gui // and if the index is too big we will get exception. if (calcToolbarIndexParam && toolbarIndexForFuntion < toolbarIndex) { toolbarIndex = toolbarIndexForFuntion; } Commands.addAsync(CommandType.CREATE_TOOLBAR_ITEM, toolbar, form, this, toolbarIndex); if (createSepAtTheEnd) { _parentMgMenu.checkEndtSepForGroup(form, ImageGroup, menuType()); } hasTool = true; } return(hasTool); }