/// <summary> This method updates a toolbar as instantiated for a specific form and style. It returns a reference to a /// menu object - to be used in order to retrieve this menu object, if it is needed. The returned object /// should be placed in the controlsMap, with the created menu for future use /// </summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> menu reference object</returns> public MenuReference setToolItemInstantiated(GuiMgForm form) { MenuReference menuReference = new MenuReference(form); _instantiatedToolItem[form] = menuReference; return(menuReference); }
public void CriarMenuPorScript(float xStart, float yStart, float xEnd, float yEnd) { Canvas canvasAlvo = CriarCanvas(); MenuReference menu = Instantiate(menuRef); menu.transform.SetParent(canvasAlvo.transform); RectTransform rt = menu.GetComponent <RectTransform>(); RectTransform rtt = canvasAlvo.GetComponent <RectTransform>(); SetCanvasPercentSize(rt, xStart, yStart, xEnd, yEnd); SupportSingleton.Instance.InvokeInRealTime(() => { A_MenuOption[] As = rt.GetComponentsInChildren <A_MenuOption>(); RectTransform pai = As[0].transform.parent.GetComponent <RectTransform>(); Debug.Log(pai.sizeDelta + " : " + pai.childCount + " : " + pai.rect.height); foreach (var A in As) { RectTransform rrtt = A.GetComponent <RectTransform>(); A.GetComponentInChildren <Text>().resizeTextForBestFit = true; rrtt.sizeDelta = new Vector2(rrtt.sizeDelta.x, pai.rect.height / (pai.childCount - 1)); } }, 0.5f); }
public Menu GetMenu() { if (!MenuReference.IsLoaded) { MenuReference.Load(); } return(Menu); }
/// <summary> /// This method updates a menu as instantiated for a specific form and style. It returns a reference to a /// menu object - to be used in order to retrieve this menu object, if it is needed. The returned object /// should be placed in the controlsMap, with the created menu for future use /// </summary> /// <param name = "form">the form for which the menus is instatiated</param> /// <returns> menu reference object</returns> public MenuReference setToolBarIsInstantiated(MgFormBase form) { // toolbar will not save a ref to a form. since we do not handle the toolbar dispose, // then there will not be a way to remove the ref of the form and we might have a dengling ref. // in any case, there is no use for a form on a menuref for the toolbar itself. MenuReference menuReference = new MenuReference(null); _instantiatedToolbar[form] = menuReference; return(menuReference); }
/// <summary> /// This method creates the gui commands in order to delete the matching menu object. /// </summary> /// <param name = "menuStyle"></param> public void deleteMenuEntryObjectItem(MgFormBase form, MenuStyle menuStyle) { //we call this method for menuEntry and MenuStyle(context\pulldown) //when create toolbar without pulldown the Reference is null MenuReference menuReference = getInstantiatedMenu(form, menuStyle); if (menuReference != null) { Commands.addAsync(CommandType.DELETE_MENU_ITEM, menuReference, menuStyle, this); } }
/// <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); }
/// <summary> /// Add menu references to command queue. /// </summary> /// <param name = "mnuRefs">Collection<MenuReference> containing menu refernces to be added to command queue /// </param> /// <param name = "cmdType">Command Type can be PROP_SET_CHECKED, PROP_SET_ENABLE, PROP_SET_VISABLE /// </param> /// <param name = "value">boolean /// </param> private void addAllRefsToCmdQueue(ICollection mnuRefs, CommandType cmdType, Object val) { if (mnuRefs != null) { IEnumerator imnuref = mnuRefs.GetEnumerator(); while (imnuref.MoveNext()) { MenuReference mnuRef = (MenuReference)imnuref.Current; Commands.addAsync(cmdType, mnuRef, this, val); Commands.beginInvoke(); } } }
/// <summary> /// /// </summary> /// <param name="mgForm"></param> /// <returns></returns> public void deleteToolBar(MgFormBase mgForm) { MenuReference toolbar = (MenuReference)_instantiatedToolbar[mgForm]; if (toolbar != null) { // create the matching gui command // form is the parentObject // toolbar is the object Commands.addAsync(CommandType.DELETE_TOOLBAR, mgForm, toolbar); removeInstantiatedToolbar(mgForm); } }
/// <summary> This method returns a menu object reference for a specific form and menu style (pulldown, context). The /// returned reference should be used in order to retrieve the specific instantiated menu object from the /// controls map.</summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> a menu object reference. In case the menu was not yet instantiated for the specfic form and /// style, null is returned. /// </returns> public MenuReference getInstantiatedMenu(GuiMgForm form, MenuStyle menuStyle) { MenuReference menuReference = null; if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { menuReference = (MenuReference)instantiatedPullDown[form]; } else { menuReference = (MenuReference)instantiatedContext[form]; } return(menuReference); }
/// <summary> This method updates a menu as instantiated for a specific form and style. It returns a reference to a /// menu object - to be used in order to retrieve this menu object, if it is needed. The returned object /// should be placed in the controlsMap, with the created menu for future use /// /// </summary> /// <param name="form">the form for which the menus is instantiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> menu reference object</returns> protected MenuReference setMenuIsInstantiated(GuiMgForm form, MenuStyle menuStyle) { var menuReference = new MenuReference(form); if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { instantiatedPullDown[form] = menuReference; } else { instantiatedContext[form] = menuReference; } return(menuReference); }
/// <summary> /// creates enable command for a specific action on the menu /// </summary> /// <param name = "actionMenu">action menu to be enabled\ disabled</param> /// <param name = "form">on which form</param> /// <param name = "menuStyle">which style</param> /// <param name = "enable">enable\ disable</param> public void EnableMenuEntry(MenuEntry actionMenu, MgFormBase form, MenuStyle menuStyle, bool enable) { MenuReference menuReference = actionMenu.getInstantiatedMenu(form, menuStyle); if (menuReference != null) { // When we are in GuiThread, we should enable menuentry synchronously. if (Misc.IsGuiThread()) { Commands.EnableMenuEntry(menuReference, enable); } else { Commands.addAsync(CommandType.PROP_SET_ENABLE, menuReference, null, enable); } } }
/// <summary> This method updates a menu as instantiated for a specific form and style. It returns a reference to a /// menu object - to be used in order to retrieve this menu object, if it is needed. The returned object /// should be placed in the controlsMap, with the created menu for future use /// </summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> menu reference object</returns> protected MenuReference setMenuIsInstantiated(GuiMgForm form, MenuStyle menuStyle) { MenuReference menuReference = new MenuReference(form); if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { _instantiatedPullDown[form] = menuReference; } else if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT) { _instantiatedContext[form] = menuReference; } else if (menuStyle == MenuStyle.MENU_STYLE_TOOLBAR) { _instantiatedToolItem[form] = menuReference; } else { Debug.Assert(false); } return(menuReference); }
/// <summary> This method returns a menu object reference for a specific form and menu style (pulldown, context). The /// returned reference should be used in order to retrieve the specific instantiated menu object from the /// controls map. /// </summary> /// <param name="form">the form for which the menus is instatiated</param> /// <param name="menuStyle">the menu style (pulldown, context)</param> /// <returns> a menu object reference. In case the menu was not yet instantiated for the specfic form and /// style, null is returned.</returns> public MenuReference getInstantiatedMenu(GuiMgForm form, MenuStyle menuStyle) { MenuReference menuReference = null; if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { menuReference = (MenuReference)_instantiatedPullDown[form]; } else if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT) { menuReference = (MenuReference)_instantiatedContext[form]; } else if (menuStyle == MenuStyle.MENU_STYLE_TOOLBAR) { menuReference = (MenuReference)_instantiatedToolItem[form]; } else { Debug.Assert(false); } return(menuReference); }
/// <summary> /// Creates a ToolStripMenuItem for menuEntry. /// </summary> /// <param name="menuReference"></param> /// <param name="windowMenuEntry"></param> /// <param name="mgForm"></param> /// <param name="menuStyle"></param> /// <param name="index"></param> public static void CreateMenuItem(MenuReference menuReference, GuiMenuEntry menuEntry, GuiMgForm mgForm, MenuStyle menuStyle, int index) { GuiCommandQueue.getInstance().createMenuItem(menuEntry, menuReference, menuStyle, true, index, mgForm); }
/// <summary> /// Delete a ToolStripMenuItem. /// </summary> /// <param name="menuReference"></param> public static void DeleteMenuItem(MenuReference menuReference) { #if !PocketPC GuiUtils.DeleteMenuItem(menuReference); #endif }
/// <summary> /// This method creates the gui commands in order to create the matching menu object. It creates the whole /// object – with the sub menus. /// </summary> /// <param name = "menuStyle"> /// </param> /// <param name = "form"> /// </param> public void createMenuEntryObject(Object parentMenuObject, MenuStyle menuStyle, MgFormBase form, bool callFromMenuShowFunction) { #if PocketPC if (getVisible()) #endif { int i; bool hasTool = false; // if the two properties :DisplayContext & DisplayPullDown are false not need to perform the create // loop . // in case the MenuStyle is context, we perform the loop. if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT || form.ShouldShowPullDownMenu || form.ShouldCreateToolbar) { MenuStyle createMenuStyle = menuStyle; bool createSWTmenu = false; // when the pulldown menu isn't display the create loop is done for all its children // so it mean the toolbar need to be created so we call the method setMenuIsInstantiated with the // style MENU_STYLE_TOOLBAR if (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN && !form.ShouldShowPullDownMenu) { createMenuStyle = MenuStyle.MENU_STYLE_TOOLBAR; } else { createSWTmenu = (menuStyle == MenuStyle.MENU_STYLE_CONTEXT || (menuStyle == MenuStyle.MENU_STYLE_PULLDOWN && form.ShouldShowPullDownMenu)); } MenuReference menuReference = null; if (!(String.IsNullOrEmpty(TextMLS) && menuType() == MenuType.WINDOW_MENU_ENTRY)) { menuReference = setMenuIsInstantiated(form, createMenuStyle); } //After #984822, Gui.low expects the local file path. //Since long (even before #984822), if the physical image path was given, the image is //searched in the local file system. I suspect that it should be treated as a server path. //A new QCR should be opened for this and till then, only the URLs should be converted to the local path. if (!String.IsNullOrEmpty(ImageFile) && !ImageFile.StartsWith("@") && Misc.isWebURL(ImageFile, Manager.Environment.ForwardSlashUsage)) { ImageFile = Events.GetLocalFileName(ImageFile, form.getTask()); } // If this is called from menu function then CREATE_MENU_ITEM should use new _index instead of orgIndex. // set the form's pulldown and context menus if (createSWTmenu) { // It may happen that language is changed by SetLang (). So, get translated text before creating menu entry. TextMLS = Events.Translate(_text); if (!(String.IsNullOrEmpty(TextMLS) && menuType() == MenuType.WINDOW_MENU_ENTRY)) { Commands.addAsync(CommandType.CREATE_MENU_ITEM, parentMenuObject, menuStyle, this, form, getIndex()); } } if (menuType() != MenuType.SEPARATOR && menuStyle == MenuStyle.MENU_STYLE_PULLDOWN) { if (form.ShouldCreateToolbar) { hasTool = createMenuEntryTool(form, callFromMenuShowFunction); } } if (this is MenuEntryMenu) { //MenuReference menuItemReference = setInstantiatedMenuItem(form, menuStyle); for (i = 0; i < ((MenuEntryMenu)this).subMenus.Count; i++) { (((MenuEntryMenu)this).subMenus[i]).createMenuEntryObject(menuReference, menuStyle, form, callFromMenuShowFunction); } } if (this is MenuEntryEvent) { // add the menuentry to the list of objects which appear on the menu bar and or the tool bar if (createSWTmenu) { _parentMgMenu.addEntryToInternalEventsOnMenus((MenuEntryEvent)this); } if (hasTool) { _parentMgMenu.addEntryToInternalEventsOnToolBar((MenuEntryEvent)this); } } if (AccessKey != null) { _parentMgMenu.addEntryToMenuEntriesWithAccessKey(this); } } } }
protected internal void createEnableCmd(MgFormBase form, MenuStyle menuStyle, bool enable) { MenuReference menuReference = getInstantiatedMenu(form, menuStyle); Commands.addAsync(CommandType.PROP_SET_ENABLE, menuReference, this, enable); }
/// <summary> Returns all getInstantiatedMenus menus for one form </summary> /// <returns> ArrayList<MenuReference> containing all Instantiated Menus /// </returns> public ICollection getInstantiatedMenus(GuiMgForm form, bool addToolBar, bool addPullDown, bool addContext) { ArrayList list = new ArrayList(); // Can't use List<T> - may include MenuReference or ICollection if (form == null) { ICollection listPullDown = null; ICollection listContext = null; ICollection listToolbar = null; if (addPullDown) { listPullDown = getInstantiatedMenus(MenuStyle.MENU_STYLE_PULLDOWN); if (listPullDown != null) { list.AddRange(listPullDown); } } if (addContext) { listContext = getInstantiatedMenus(MenuStyle.MENU_STYLE_CONTEXT); if (listContext != null) { list.AddRange(listContext); } } if (addToolBar) { listToolbar = getInstantiatedMenus(MenuStyle.MENU_STYLE_TOOLBAR); if (listToolbar != null) { list.AddRange(listToolbar); } } } else { MenuReference listPullDown = null; MenuReference listContext = null; MenuReference listToolbar = null; if (addPullDown) { listPullDown = getInstantiatedMenu(form, MenuStyle.MENU_STYLE_PULLDOWN); if (listPullDown != null) { list.Add(listPullDown); } } if (addContext) { listContext = getInstantiatedMenu(form, MenuStyle.MENU_STYLE_CONTEXT); if (listContext != null) { list.Add(listContext); } } if (addToolBar) { listToolbar = getInstantiatedMenu(form, MenuStyle.MENU_STYLE_TOOLBAR); if (listToolbar != null) { list.Add(listToolbar); } } } return(list); }
/// <summary> /// Create/Delete menu item on visibility = true/false /// </summary> /// <param name = "visible"> /// </param> /// <param name = "setPropOnly">- /// only initialize the property - do not try to create\deleet the matching objects This should be /// true when we initialize the menu entry object data through the /// </param> public void setVisible(bool visible, bool setPropOnly, bool pullDownMenu, TaskBase topMostTask, MgFormBase sendForm) { bool prevState = _menuState.Visible; _menuState.Visible = visible; if (!pullDownMenu) { return; } MenuReference menuReference = null; if (!setPropOnly) { if (topMostTask == null || topMostTask.isMainProg()) { //eventTask can be null, if we are here from TP/TS of MP. In that case, topMostTask should MP. TaskBase eventTask = (TaskBase)Events.GetCurrentTask(); if (eventTask != null) { topMostTask = eventTask; } } MgFormBase formOrg = null; MgFormBase form = null; if (sendForm == null) { formOrg = topMostTask.getTopMostForm(); form = topMostTask.getTopMostForm().getTopMostFrameForm(); // fixed bug#:773382, when there is no SDI\MDI need to get the corg form (for the context menu) form = (form != null ? form : formOrg); } else { formOrg = form = sendForm; } if (!prevState && visible) { resetIndexes(); if (ParentMenuEntry != null) { if (pullDownMenu) { menuReference = ParentMenuEntry.getInstantiatedMenu(form, MenuStyle.MENU_STYLE_PULLDOWN); createMenuEntryObject(menuReference, MenuStyle.MENU_STYLE_PULLDOWN, form, true); } } else { if (pullDownMenu) { createMenuEntryObject(_parentMgMenu, MenuStyle.MENU_STYLE_PULLDOWN, form, true); } } } else if (prevState && !visible) { resetIndexes(); if (pullDownMenu) { deleteMenuEntryObject(form, MenuStyle.MENU_STYLE_PULLDOWN); } } if (pullDownMenu) { Commands.addAsync(CommandType.UPDATE_MENU_VISIBILITY, form); } } }