Exemple #1
0
        /// <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);
            }
        }