Exemplo n.º 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);
            }
        }
Exemplo n.º 2
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);
        }