/// <summary> /// This constructor creates a matching event object for the passed menuEntryEvent /// </summary> /// <param name = "menuEntryEvent">event menu entry for which we create this event</param> /// <param name = "currentTask">current task from which the menu entry was activated</param> /// <param name = "control"></param> internal RunTimeEvent(MenuEntryEvent menuEntryEvent, Task currentTask, MgControl control, int ctlIdx) : base(menuEntryEvent, ctlIdx) { _task = currentTask; _taskTag = currentTask.getTaskTag(); Control = control; }
/// <summary> /// When menuEntry is selected on Menu, this method gets called. It calls appropriate functions depending /// upon type of menu selected. /// </summary> /// <param name="menuEntry">selected menu entry</param> /// <param name="activeForm">current active form, when menu is selected.</param> /// <param name="activatedFromMDIFrame">Is menu selected from MDI Frame. </param> public void onMenuSelection(GuiMenuEntry menuEntry, GuiMgForm activeForm, bool activatedFromMDIFrame) { try { MgFormBase topMostForm = null; TaskBase task = null; if (!((MgFormBase)activeForm).IsHelpWindow) { task = ((MgFormBase)activeForm).getTask(); //from the menu task get the form of the menu(topmost) and save member of the last menu Id selected. topMostForm = (MgFormBase)task.getTopMostForm(); } else { //In case of help window, get the parent form of help form and get task from that. activeForm = topMostForm = ((MgFormBase)activeForm).ParentForm; task = topMostForm.getTask(); } topMostForm.LastClickedMenuUid = menuEntry.menuUid(); if (menuEntry is MenuEntryProgram) { Events.OnMenuProgramSelection(task.ContextID, (MenuEntryProgram)menuEntry, activeForm, activatedFromMDIFrame); } else if (menuEntry is MenuEntryOSCommand) { Events.OnMenuOSCommandSelection(task.ContextID, (MenuEntryOSCommand)menuEntry, activeForm); } else if (menuEntry is MenuEntryEvent) { // in order to get the correct ctlidx we take it from the parent MgMenu of the menuentry and then // change it if the event is a user event from another component int ctlIdx = ((MenuEntryEvent)menuEntry).getParentMgMenu().CtlIdx; MenuEntryEvent menuEntryEvent = (MenuEntryEvent)menuEntry; if (menuEntryEvent.UserEvtCompIndex > 0) { ctlIdx = menuEntryEvent.UserEvtCompIndex; } Events.OnMenuEventSelection(task.ContextID, (MenuEntryEvent)menuEntry, activeForm, ctlIdx); } else if (menuEntry is MenuEntryWindowMenu) { MgFormBase mgFormbase = ((MenuEntryWindowMenu)menuEntry).MgForm; // Activate the form associated with the entry Commands.addAsync(CommandType.ACTIVATE_FORM, mgFormbase); // Put ACT_HIT on form. Events.OnMenuWindowSelection((MenuEntryWindowMenu)menuEntry); } } catch (ApplicationException ex) { Events.WriteExceptionToLog(ex); } }
/// <summary> /// enable/disable menu entry identified by entryName. /// </summary> /// <param name = "task"></param> /// <param name = "entryName">menuentry name</param> /// <param name = "enable">enable/disable value</param> public bool MenuEnableByName(TaskBase task, String entryName, bool enable) { bool internalEventMenuEnabled = false; MgMenu pulldownMenu = GetPulldownMenu(task); // Get matching menus from all ctls ArrayList menuEntryList = GetMatchingMenuValues(task.ContextID, entryName, pulldownMenu); if (menuEntryList != null) { IEnumerator iMatchingEnt = menuEntryList.GetEnumerator(); while (iMatchingEnt.MoveNext()) { var menuValue = (MenuValue)iMatchingEnt.Current; var mnuEnt = menuValue.InnerMenuEntry; if (mnuEnt.menuType() == GuiMenuEntry.MenuType.INTERNAL_EVENT) { MenuEntryEvent menuEntryEvent = (MenuEntryEvent)mnuEnt; if ((menuEntryEvent.InternalEvent < InternalInterface.MG_ACT_USER_ACTION_1) || (menuEntryEvent.InternalEvent > InternalInterface.MG_ACT_USER_ACTION_20)) { internalEventMenuEnabled = true; } } bool refresh; if (menuValue.IsPulldown) { refresh = true; } else { refresh = false; } //set the ModalDisabled flag, depending upon the value of enable. if (!enable) { mnuEnt.setModalDisabled(false); } mnuEnt.setEnabled(enable, true, true, entryName, refresh); } if (internalEventMenuEnabled) { Manager.WriteToMessagePanebyMsgId(task, MsgInterface.MENU_STR_ERROR_ENABLE, false); } } return(true); }
/// <summary> /// This method is activated when an Event menu was selected. It performs the needed operations in order to /// translate the selected event menu into the matching operation /// </summary> /// <param name = "menuEntryEvent">the selected menu \ bar menuEntryEvent object</param> /// <param name = "activeForm">last active Form</param> /// <param name = "ctlIdx">the index of the ctl which the menu is attached to in toolkit</param> internal static void onEventMenuSelection(MenuEntryEvent menuEntryEvent, MgForm activeForm, int ctlIdx) { MgControl lastFocusedControl = getLastFocusedControl(activeForm); Task task = getLastFocusedTask(activeForm); RunTimeEvent aRtEvt = new RunTimeEvent(menuEntryEvent, task, lastFocusedControl, ctlIdx); aRtEvt.setPublicName(); aRtEvt.setMainPrgCreator(null); // build the argument list from the mainProgVars List <String> mainProgVars = menuEntryEvent.MainProgVars; if (mainProgVars != null && mainProgVars.Count > 0) { ArgumentsList argList = new ArgumentsList(); argList.fillListByMainProgVars(mainProgVars, task.getCtlIdx()); aRtEvt.setArgList(argList); aRtEvt.setTask(null); } ClientManager.Instance.EventsManager.addToTail(aRtEvt); }
/// <summary> /// Handles menu selection /// </summary> /// <param name="contextID">active/target context (irelevant for RC)</param> /// <param name = "menuEntry"></param> /// <param name = "activeForm"></param> /// <param name = "activatedFromMDIFrame"></param> private void OnMenuEventSelection(Int64 contextID, MenuEntryEvent menuEntryEvent, GuiMgForm activeForm, int ctlIdx) { MenuManager.onEventMenuSelection(menuEntryEvent, (MgForm)activeForm, ctlIdx); }