Exemple #1
0
        /// <summary>
        ///   This method is activated when a menu was selected. It performs the needed operations in order to
        ///   translate the selected menu into the matching operation
        /// </summary>
        private void onSelection(Object sender)
        {
            //Object object_Renamed = widget.getData();
            GuiMenuEntry menuEntry = null;
            MenuItem     menuItem  = null;

            menuItem  = (MenuItem)sender;
            menuEntry = ((TagData)(menuItem.Tag)).guiMenuEntry;
            // when a menu with check style is selected, it is automatically checked.
            // we want to check it only if it should be checked - according to the state.
            //In Compact framework it is not allowed to set "Checked" for top level menus.
            if (!(menuItem.Parent is MainMenu))
            {
                ((MenuItem)sender).Checked = menuEntry.getChecked();
            }

            try
            {
                GuiMgForm guiMgForm = menuObjToForm(sender);

                Events.OnMenuSelection(menuEntry, guiMgForm, false);
            }
            catch (ApplicationException e)
            {
                Misc.WriteStackTrace(e, Console.Error);
            }
        }
Exemple #2
0
        /// <summary>*******************************************************************************************************
        /// **************************** DO NOT DELETE THIS CODE ****************************
        /// *********************************************************************************************** This
        /// method refreshes the enabling of internal event menu entries. It is activated when the menu is
        /// displayed.
        ///
        /// NOTE: currently not used - we refresh all action menu entries when the action is enabled\disabled. But,
        /// we may decide to use this method instead, due to performance issues. If we decide to use this, we need
        /// to add the SWT.Show to the listeber.
        ///
        /// </summary>
        /// <param name="widget">-
        /// on which show was received
        /// </param>

        /*
         * private void menuShow (Widget widget) { Menu menu = null; MgMenu mgMenu = null; MenuEntryMenu
         * menuEntryMenu = null; MenuEntry menuEntry = null; MgForm form = null;
         *
         * if (widget instanceof Menu) { menu = (Menu)widget; Object data = menu.getData(); int style =
         * menu.getStyle(); MenuStyle menuStyle = (style == SWT.POP_UP ? MenuStyle.MENU_STYLE_CONTEXT :
         * MenuStyle.MENU_STYLE_PULLDOWN);
         *
         * form = (MgForm)menu.getShell().getData(); if (data instanceof MgMenu) { mgMenu = (MgMenu) data;
         * mgMenu.refreshInternalEventMenus(form); } else if (data instanceof MenuEntryMenu) { menuEntryMenu =
         * (MenuEntryMenu)data; menuEntryMenu.refreshActionMenus(form, menuStyle); } } else if (widget instanceof
         * MenuItem) { MenuItem menuItem = (MenuItem)widget; menuEntry = (MenuEntry)menuItem.getData(); } }
         */

        /// <summary> This mdthod takes care of toolitem's prompt - we get the mouse move \ mouse exit event on the toolbar.
        ///
        /// </summary>
        /// <param name="event">-
        /// the event which occured.
        /// </param>
        private void onItemEnterLeave(ToolStripItem menuItem, EventType type)
        {
            GuiMenuEntry  guiMenuEntry = null;
            GuiMgForm     guiMgForm    = null;
            ControlsMap   controlsMap  = ControlsMap.getInstance();
            MapData       mapData      = controlsMap.getMapData(menuItem);
            MenuReference menuRef      = mapData.getMenuReference();

            guiMgForm = menuRef.GetMgForm();

            if (type == EventType.MOUSE_ENTER)
            {
                guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry;

                // handle tooltip
                if (menuItem is ToolStripButton)
                {
                    String tooltipStrMLS = Events.Translate(guiMenuEntry.ToolTip);

                    if (tooltipStrMLS == null)
                    {
                        tooltipStrMLS = "";
                    }

                    menuItem.ToolTipText = tooltipStrMLS;
                }
            }

            Events.OnMenuPrompt(guiMgForm, (GuiMenuEntry)guiMenuEntry);
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        /// <summary> This method is activated when a menu was selected. It performs the needed operations in order to
        /// translate the selected menu into the matching operation
        ///
        /// </summary>
        /// <param name="widget">-
        /// the selected menu entry widget
        /// </param>
        private void onSelection(Object sender)
        {
            //Object object_Renamed = widget.getData();
            GuiMenuEntry  guiMenuEntry = null;
            ToolStripItem menuItem     = null;
            ToolStrip     ts;

            menuItem = (ToolStripItem)sender;
            ts       = menuItem.GetCurrentParent();

            guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry;

            // when a menu with check style is selected, it is automatically checked.
            // we want to check it only if it should be checked - according to the state.
            if (sender is ToolStripButton)
            {
                ((ToolStripButton)sender).Checked = guiMenuEntry.getChecked();
            }
            else
            {
                ((ToolStripMenuItem)sender).Checked = guiMenuEntry.getChecked();
            }

            Form      form                  = menuObjToForm(sender);
            GuiMgForm activeForm            = null;
            bool      activatedFromMDIFrame = false;

            if (form.IsMdiContainer)
            {
                activatedFromMDIFrame = true;

                Form activeMDIChild = GuiUtils.GetActiveMDIChild(form);
                if (activeMDIChild != null)
                {
                    form = activeMDIChild;
                }
            }

            ControlsMap controlsMap = ControlsMap.getInstance();
            Control     c           = ((TagData)(form.Tag)).ClientPanel;

            activeForm = controlsMap.getControlMapData(c).getForm();

            Events.OnMenuSelection(guiMenuEntry, activeForm, activatedFromMDIFrame);
        }
Exemple #5
0
        /// <summary> </summary>
        /// <param name = "guiMgForm"></param>
        /// <param name = "prompt"></param>
        private void onMenuPrompt(GuiMgForm guiMgForm, GuiMenuEntry guiMenuEntry)
        {
            MgFormBase mgForm = null;
            TaskBase   task   = null;

            if (guiMgForm is MgFormBase)
            {
                mgForm = (MgFormBase)guiMgForm;
            }

            if (mgForm != null)
            {
                task = mgForm.getTask();
            }

            if (task != null)
            {
                if (guiMenuEntry == null)
                {
                    if (!task.isAborting())
                    {
                        Manager.CleanMessagePane(task);
                    }
                }
                else
                {
                    if (guiMenuEntry is MenuEntry)
                    {
                        MenuEntry menuEntry = (MenuEntry)guiMenuEntry;

                        String prompt = menuEntry.getPrompt();
                        if (prompt == null)
                        {
                            prompt = "";
                        }

                        Manager.WriteToMessagePane(task, StrUtil.makePrintable(prompt), false);
                    }
                }
            }
        }
Exemple #6
0
        /*
         * (non-Javadoc)
         *  For ContextMenu : MENU_OPENING replaces the SWT's MenuDetect. Since there is no such handler on a control, we needed a way
         *  to block the system's menu and show nothing in case there was no context menu assigned by the user. We also need to decide on
         *  the correct context menu before it opens.
         *  We do that by assigning a new and empty context menu for each control that is created.
         *  When the user right clicks on a control, the empty context (or a real context) shoots a MENU_OPENING.
         *  In this point do a few things :
         *  1. If this is the 1st opening event for that click, we need to decide if that is the correct menu to be opened.
         *     In case its the 2nd time, the 'ContextCanOpen' flag will be true, verifying that we don't need to check the menu.
         *  2. To check the menu we have separate methods for table controls and other controls.
         *     each type will have its own 'handleContextMenu'.
         *     * In table, if the clicked cell is already in edit mode, then the control we'll get here will be already a regular edit box.
         *  3. In case we have discovered that the correct menu to be showed is not the one that had sent us the 'OPENING' event,
         *     we will cancel its opening and insteed we will set the 'ContextCanOpen' to true and call the ContextMenuStrip.Show ourselves.
         *     That way the correct menu will be opened.
         */
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            MapData       mapData;
            GuiMgForm     guiMgForm = null;
            MenuReference menuRef   = null;
            ControlsMap   controlsMap;

            Manager.ContextIDGuard contextIDGuard = null;

            mapData = ControlsMap.getInstance().getMapData(sender);
            if (mapData != null)
            {
                menuRef   = mapData.getMenuReference();
                guiMgForm = menuRef.GetMgForm();
                if (guiMgForm != null)
                {
                    contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgForm));
                }
            }
            try
            {
                switch (type)
                {
                // Only ContexMenuStrip and ToolStripMenuItem can be opened. A MenuStrip is never opened, only its childs which are items.
                // *** see also comment above.
                case EventType.MENU_OPENING:
                    // only if the context itself is opening
                    // the purpose is to determine the correct menu to be opened on the control. (substitude to the SWT.MENU_DETECT).
                    if (sender is ContextMenuStrip && !((TagData)((ContextMenuStrip)sender).Tag).ContextCanOpen)
                    {
                        ContextMenuStrip contextMenu  = (ContextMenuStrip)sender;
                        Control          control      = contextMenu.SourceControl;
                        GuiMgControl     guiMgControl = null;

                        controlsMap = ControlsMap.getInstance();

                        if (control is Form)
                        {
                            // in case of form control, the real control is its panel
                            control = ((TagData)(control.Tag)).ClientPanel;
                        }

                        /*Defect 131535 :
                         * After 3.1 the MDIClient is covered with a Panel with FitToMDI.
                         * In the defect scenario when user presses the right click on online form and keeping the right click pressed drags the cursor to MDI form and then leaves the button
                         * then, somehow we get the SourceControl of the context menu as MDIClient.
                         * But the MDIClient is not saved in ControlsMap anymore.
                         * In order to fix the problem whenever we get the SourceControl of context menu as MDIClient set it to MgPanel obtained from it's parent's (GuiForm) ClientPanel.*/
                        if (control is System.Windows.Forms.MdiClient)
                        {
                            GuiForm guiForm = (GuiForm)control.Parent;
                            control = ((TagData)guiForm.Tag).ClientPanel;
                        }

                        ContainerManager containerManager = ((TagData)(control.Tag)).ContainerManager;
                        if (containerManager is TableManager || containerManager is TreeManager || containerManager is BasicControlsManager)
                        {
                            // Use the mouse pos to determine in which row and column we are at.
                            // We cannot use the contextMenu.Left\Top, since its not always the point from which the cursor was opened.
                            // If the menu was opened via keyboard, we will not get here , since the control will be not table control but the cell control itself.
                            Point MousePos = Control.MousePosition;

                            // get the relative location on the menu within the container.
                            Point pt = control.PointToClient(new Point(MousePos.X, MousePos.Y));
                            mapData = containerManager.HitTest(pt, true, true);
                            if (mapData == null)
                            {
                                if (containerManager is TableManager)
                                {
                                    GuiUtils.setTooltip(control, "");
                                }
                                else
                                {
                                    if (control is Panel && ((TagData)(control.Tag)).ContainerTabControl != null)
                                    {
                                        // in case its the tab panel, the control will be the tab control
                                        control = ((TagData)(control.Tag)).ContainerTabControl;
                                    }

                                    mapData = controlsMap.getMapData(control);
                                }
                            }
                        }
                        else
                        {
                            mapData = controlsMap.getMapData(control);
                        }

                        // Do not go in here if tableManager.handleContextMenu was executed.

                        if (mapData != null)
                        {
                            bool focusChanged = false;
                            guiMgControl = mapData.getControl();
                            bool onMultiMark = false;
                            if (containerManager == null && ((TagData)control.Tag).IsEditor)
                            {
                                Object obj = controlsMap.object2Widget(guiMgControl, mapData.getIdx());
                                if (obj is LogicalControl)
                                {
                                    containerManager = ((LogicalControl)obj).ContainerManager;
                                }
                            }

                            if (containerManager is ItemsManager)
                            {
                                onMultiMark = ((ItemsManager)containerManager).IsItemMarked(mapData.getIdx());
                            }
                            focusChanged = Events.OnBeforeContextMenu(guiMgControl, mapData.getIdx(), onMultiMark);
                            //If the focus was changed, the control must have been saved as the focussing control.
                            //So, remove it from here.
                            if (focusChanged)
                            {
                                GuiUtils.removeFocusingControl(GuiUtils.FindForm(control));
                            }

                            GuiUtils.setTooltip(control, "");
                        }

                        // Cancel the opening of the context, as we will be handling it thr' event.
                        ((CancelEventArgs)e).Cancel = true;

                        // Add Event to Open a Context Menu, So, that it should be opened after the event added by
                        // OnBeforeContextMenu event.
                        int line = mapData != null?mapData.getIdx() : 0;

                        // If right click in on table control and not any control attached to table control
                        if (control is TableControl && guiMgControl == null)
                        {
                            guiMgControl = controlsMap.getMapData(control).getControl();
                        }
                        // Invoke the event to open a context menu.
                        Events.OnOpenContextMenu(guiMgControl, mapData != null ? mapData.getForm() : null,
                                                 contextMenu.Left, contextMenu.Top, line);
                        return;
                    }
                    else
                    {
                        mapData = ControlsMap.getInstance().getMapData(sender);
                        if (mapData == null)
                        {
                            break;
                        }

                        menuRef   = mapData.getMenuReference();
                        guiMgForm = menuRef.GetMgForm();
                        if (sender is MgToolStripMenuItem)
                        {
                            // This change is to improve performance of pulldown menu. When we apply modality, (while opening a batch task).
                            // We just disable menu items on GuiMenuEntry. actual menu is diabled in .ent whe
                            foreach (ToolStripItem item in ((ToolStripMenuItem)sender).DropDownItems)
                            {
                                if (item is MgToolStripMenuItem)
                                {
                                    TagData      tagData1      = (TagData)((MgToolStripMenuItem)item).Tag;
                                    GuiMenuEntry guiMenuEntry1 = tagData1.guiMenuEntry;

                                    if (!(guiMenuEntry1 is MenuEntryEvent || guiMenuEntry1 is MenuEntryMenu))
                                    {
                                        if (guiMenuEntry1.getModalDisabled() && (item.Enabled == guiMenuEntry1.getModalDisabled()))
                                        {
                                            item.Enabled = false;
                                        }
                                        else if (!item.Enabled && (guiMenuEntry1.getEnabled() == true))
                                        {
                                            item.Enabled = guiMenuEntry1.getEnabled();
                                        }
                                    }
                                }
                            }

                            // Create windowMenu items for MgToolStripMenuItem (Only sub-menus can define window menu)
                            TagData tagData = (TagData)((MgToolStripMenuItem)sender).Tag;
                            Events.InitWindowListMenuItems(guiMgForm, tagData.guiMenuEntry, tagData.MenuStyle);
                        }
                    }

                    // we get here in 3 cases :
                    // 1. ContextCanOpen is true. i.e. we have a confirmation to open. we are already in the recursive call.
                    // 2. We are in the original opening, but this is the correct menu.
                    // 3. This is a ToolStripMenuItem (i.e. not the context menu itself.

                    //when opening a menu (pulldown or context), check if paste action
                    //should be enabled/disabled.
                    //Don't check for dummy, no need. also, if u try : getLastFocusedControl will throw exception since dummy don't have mapData.
                    // Dummy is only relevant in context menu (not in drop down).
                    if (!(sender is ContextMenuStrip && ((ContextMenuStrip)sender).Name == "Dummy"))
                    {
                        //Call to checkPasteEnable() was introduced for QCR# 241365 in Java RC.
                        //This code is added for following situation:
                        //If there are 3 fields a, b, c. Field C has modifiable = No.
                        //If contex menu of fields a and b show paste as enabled, then the modifiable=no field will also show paste enabled...
                        //and it shouldn't.
                        //When we are on 3rd field, tab to another window and get back (to loose and regain focus)
                        //now, the paste is disabled on c as it should...but tab to the other fields, now the paste is disabled for them as well.
                        //to make paste enabled for Modifiable fields, this call is required here.
                        GuiMgControl guiMgControl = getLastFocusedControl(sender);
                        GuiUtils.checkPasteEnable(guiMgControl, true);
                    }

                    return;


                // Select event can happen ONLY on MenuItem, not on Menu. (see addHandler).
                case EventType.MENU_ITEM_SELECTED:
                    onSelection(sender);

                    break;

                case EventType.MOUSE_ENTER:
                    onItemEnterLeave((ToolStripItem)sender, type);
                    break;

                case EventType.MOUSE_LEAVE:
                    onItemEnterLeave((ToolStripItem)sender, type);
                    break;

                case EventType.CLOSED:
                    if (sender is ContextMenuStrip)
                    {
                        ToolStrip menu = (ToolStrip)sender;
                        if (((ContextMenuStrip)sender).Name == "Dummy")
                        {
                            break;
                        }

                        //Current context menu will be disposed , So, create the dummy context menu for control.
                        Control control = ((TagData)menu.Tag).MouseDownOnControl;
                        GuiUtils.setContextMenu(control, null);

                        //Dispose context Menu.
                        GuiMgMenu mgMenu = ((TagData)menu.Tag).GuiMgMenu;
                        Events.OnContextMenuClose(menuRef.GetMgForm(), mgMenu);
                    }
                    break;

                case EventType.DISPOSED:
                    controlsMap = ControlsMap.getInstance();
                    GuiMenuEntry guiMenuEntry = null;

                    if (sender is ContextMenuStrip && ((ContextMenuStrip)sender).Name == "Dummy")
                    {
                        break;
                    }

                    mapData = controlsMap.getMapData(sender);

                    if (mapData == null)
                    {
                        break;
                    }

                    menuRef   = mapData.getMenuReference();
                    guiMgForm = menuRef.GetMgForm();

                    if (guiMgForm != null)
                    {
                        if (sender is ToolStripItem)
                        {
                            ToolStripItem menuItem  = (ToolStripItem)sender;
                            MenuStyle     menuStyle = ((TagData)menuItem.Tag).MenuStyle;

                            guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry;

                            guiMenuEntry.removeMenuIsInstantiated(guiMgForm, menuStyle);

                            //if (menuEntry is MenuEntryMenu)
                            //   menuEntry.removeInstantiatedMenuItems(mgForm, menuStyle);
                            if ((guiMenuEntry.ImageFile != null) && menuItem.Image != null)
                            {
                                menuItem.Image.Dispose();
                            }
                            menuItem.Tag = null;
                        }
                        else if (sender is ToolStrip)
                        {
                            ToolStrip menu      = (ToolStrip)sender;
                            MenuStyle menuStyle = ((TagData)menu.Tag).MenuStyle;

                            if (((TagData)menu.Tag).GuiMgMenu != null)
                            {
                                GuiMgMenu mgMenu = ((TagData)menu.Tag).GuiMgMenu;
                                mgMenu.removeInstantiatedMenu(guiMgForm, menuStyle);
                            }
                            //else if (((TagData)menu.Tag).menuEntry != null)
                            //{
                            //   MenuEntry mgMenu = ((TagData)menu.Tag).menuEntry;
                            //   menuEntry.removeInstantiatedMenuItems(mgForm, menuStyle);
                            //}

                            menu.Tag = null;
                        }
                    }

                    if (menuRef != null)
                    {
                        Object fromMap = controlsMap.object2Widget(menuRef);
                        if (fromMap != null)
                        {
                            controlsMap.remove(menuRef);
                        }
                    }

                    break;

                case EventType.KEY_DOWN:
                {
                    if (((KeyEventArgs)e).KeyCode == Keys.F1)
                    {
                        ToolStrip menu = (ToolStrip)sender;

                        foreach (ToolStripItem menuItem in menu.Items)
                        {
                            if (menuItem.CanSelect && menuItem.Selected)
                            {
                                guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry;

                                if (guiMenuEntry.Help > 0)
                                {
                                    if (menu.IsDropDown)
                                    {
                                        // Defect Id 115414: If help is opened then menu needs to be closed. After closing the menu focus should not be on the menu.
                                        // Same like when menu is clicked.ToolStripDropDownCloseReason.ItemClicked option closes the menu and
                                        // focus does not remains on the menu.
                                        ((ToolStripDropDownMenu)menu).Close(ToolStripDropDownCloseReason.ItemClicked);
                                    }
                                    Events.OnHelpInVokedOnMenu(guiMenuEntry, ((TagData)menuItem.Tag).MapData.getMenuReference().GetMgForm());
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (MnemonicHelper.HandleMnemonicForHebrew((ToolStrip)sender, (char)((KeyEventArgs)e).KeyCode))
                        {
                            ((KeyEventArgs)e).Handled = true;
                        }
                    }
                }
                break;

                default:
                    System.Console.Out.WriteLine(type.ToString());
                    break;
                }
            }
            finally
            {
                if (contextIDGuard != null)
                {
                    contextIDGuard.Dispose();
                }
            }
        }
Exemple #7
0
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            MapData     mapData;
            GuiMgForm   guiMgForm = null;
            ControlsMap controlsMap;

            switch (type)
            {
            case EventType.MENU_OPENING:
                // only if the context itself is opening
                // the purpose is to determine the correct menu to be opened on the control. (substitude to the SWT.MENU_DETECT).
                if (sender is ContextMenu && !((TagData)((ContextMenu)sender).Tag).ContextCanOpen)
                {
                    ContextMenu contextMenu = (ContextMenu)sender;
                    Control     control     = contextMenu.SourceControl;
                    controlsMap = ControlsMap.getInstance();
                    if (control is Form)
                    {
                        // in case of form control, the real control is its panel
                        control = ((TagData)(control.Tag)).ClientPanel;
                    }
                    else if (control is Panel && ((TagData)(control.Tag)).ContainerTabControl != null)
                    {
                        // in case its the tab panel, the control will be the tab control
                        control = ((TagData)(control.Tag)).ContainerTabControl;
                    }

                    ContainerManager containerManager = ((TagData)(control.Tag)).ContainerManager;
                    if (containerManager is TableManager || containerManager is BasicControlsManager)
                    {
                        // Use the mouse pos to determine in which row and column we are at.
                        // We cannot use the contextMenu.Left\Top, since its not always the point from which the cursor was opened.
                        // If the menu was opened via keyboard, we will not get here , since the control will be not table control but the cell control itself.
                        Point MousePos = Control.MousePosition;
                        // get the relative location on the menu within the container.
                        Point pt = control.PointToClient(new Point(MousePos.X, MousePos.Y));
                        mapData = containerManager.HitTest(pt, true, true);
                        if (mapData == null)
                        {
                            if (containerManager is TableManager)
                            {
                                // The menu is on a column or the table header.
                                ((TableManager)containerManager).handleContextMenu(control, pt);
                            }
                            else
                            {
                                mapData = controlsMap.getMapData(control);
                            }
                        }
                    }
                    else
                    {
                        mapData = controlsMap.getMapData(control);
                    }

                    // Do not go in here if tableManager.handleContextMenu was executed.
                    if (mapData != null)
                    {
                        bool         focusChanged = false;
                        GuiMgControl guiMgControl = mapData.getControl();
                        bool         onMultiMark  = false;
                        if (containerManager is ItemsManager)
                        {
                            onMultiMark = ((ItemsManager)containerManager).IsItemMarked(mapData.getIdx());
                        }
                        focusChanged = Events.OnBeforeContextMenu(guiMgControl, mapData.getIdx(), onMultiMark);
                        //If the focus was changed, the control must have been saved as the focussing control.
                        //So, remove it from here.
                        if (focusChanged)
                        {
                            GuiUtilsBase.removeFocusingControl(GuiUtilsBase.FindForm(control));
                        }

                        // set the correct context menu on the control
                        handleContext(control, guiMgControl, mapData.getForm());
                    }
                    // if the context has changed, it means we need to cancel the opening of the context we are in,
                    // and we should open another context that is already on the control.
                    // set its ContextCanOpen to true . open it, and then set it to false.
                    // if menu was not changed (even if the 'ContextCanOpen' is false) then we will continue with the opening.
                    // There is no need for recursive call in that case.
                    if (control.ContextMenu != null && control.ContextMenu != contextMenu)
                    {
                        ((TagData)(((ContextMenu)control.ContextMenu).Tag)).ContextCanOpen = true;
                        // show the new context in the same coordinates as the opening one.
                        Point MousePos = Control.MousePosition;
                        Point pt       = control.PointToClient(new Point(MousePos.X, MousePos.Y));
                        control.ContextMenu.Show(control, pt);
                        ((TagData)(((ContextMenu)control.ContextMenu).Tag)).ContextCanOpen = false;
                        return;
                    }
                }
                return;

            case EventType.MENU_ITEM_SELECTED:
                onSelection(sender);
                break;

            case EventType.DISPOSED:
                controlsMap = ControlsMap.getInstance();
                MenuReference menuRef      = null;
                GuiMenuEntry  guiMenuEntry = null;

                if (sender is ContextMenu && ((ContextMenu)sender).Name == "Dummy")
                {
                    break;
                }


                mapData = controlsMap.getMapData(sender);
                if (mapData == null)
                {
                    break;
                }

                menuRef   = mapData.getMenuReference();
                guiMgForm = menuRef.GetMgForm();
                if (guiMgForm == null)
                {
                    break;
                }
                if (sender is MenuItem)
                {
                    MenuItem  menuItem  = (MenuItem)sender;
                    MenuStyle menuStyle = ((TagData)menuItem.Tag).MenuStyle;
                    guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry;
                    guiMenuEntry.removeMenuIsInstantiated(guiMgForm, menuStyle);
                    //if (menuEntry is MenuEntryMenu)
                    //   menuEntry.removeInstantiatedMenuItems(mgForm, menuStyle);
                }
                if (menuRef != null)
                {
                    Object fromMap = controlsMap.object2Widget(menuRef);
                    if (fromMap != null)
                    {
                        controlsMap.remove(menuRef);
                    }
                }
                break;

            default:
                Console.Out.WriteLine(type.ToString());
                break;
            }
        }
Exemple #8
0
 private void onMenuSelection(GuiMenuEntry menuEntry, GuiMgForm activeForm, bool activatedFromMDIFrame)
 {
     Manager.MenuManager.onMenuSelection(menuEntry, activeForm, activatedFromMDIFrame);
 }
Exemple #9
0
 /// <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);
 }