Exemple #1
0
        /// <summary>this is an entry point for all objects handlers</summary>
        /// <param name="objectHashCode"> hash code of the object</param>
        /// <param name="eventName"> event name</param>
        /// <param name="parameters">event parameters</param>
        /// <returns></returns>
        public static void handleDotNetEvent(int objectHashCode, String eventName, Object[] parameters)
        {
            Object       invokedObject     = DNManager.getInstance().DNObjectEventsCollection.getObject(objectHashCode);
            GuiMgControl mgControl         = null;
            bool         raiseRuntimeEvent = true;

            Manager.ContextIDGuard contextIDGuard = null;

            // If Object is a control and it is 'our' control (not created dynamically, decided by .Tag)
            if (invokedObject is Control && ((Control)invokedObject).Tag != null)
            {
                ControlsMap controlsMap = ControlsMap.getInstance();
                MapData     mapData     = controlsMap.getControlMapData((Control)invokedObject);
                if (mapData == null)
                {
                    return;
                }

                mgControl = mapData.getControl();

                contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(mgControl));
                //first execute default magic handling of event
                EventType type = DNControlEvents.getStandardEvent(eventName);
                if (type != EventType.NONE && parameters.Length == 2)
                {
                    DefaultHandler.getInstance().handleEvent(type, invokedObject, (EventArgs)parameters[1]);
                }

                if (eventName == "KeyDown") //QCR #736734 KeyDown is handled from Filter.cs on WM_KEYDOWN - do not duplicate the event
                {
                    raiseRuntimeEvent = false;
                }
                else if (eventName == "Disposed")
                {
                    // a Disposed event for a control can't be handled as a runtime-event after the task/form are closed
                    raiseRuntimeEvent = false;
                }
                else
                {
                    // raise .NET runtime event only if hooked from the application (i.e. have a handler in the task)
                    List <String> applicationHookedDNeventsNames = ((TagData)((Control)invokedObject).Tag).ApplicationHookedDNeventsNames;
                    if (applicationHookedDNeventsNames == null || !applicationHookedDNeventsNames.Contains(eventName))
                    {
                        raiseRuntimeEvent = false;
                    }
                }
            }

            // raise .NET event
            if (raiseRuntimeEvent)
            {
                Events.OnDotNetEvent(invokedObject, mgControl, eventName, parameters);
            }

            if (contextIDGuard != null)
            {
                contextIDGuard.Dispose();
            }
        }
Exemple #2
0
        /// <summary>
        /// This function handles DN control value changed event.
        /// </summary>
        /// <param name="objectHashCode">object hash code.</param>
        public static void HandleDNControlValueChanged(int objectHashCode)
        {
            Object invokedObject = DNManager.getInstance().DNObjectEventsCollection.getObject(objectHashCode);

            // Get the gui control from the control's map.
            if (invokedObject is Control && ((Control)invokedObject).Tag != null)
            {
                ControlsMap controlsMap = ControlsMap.getInstance();
                MapData     mapData     = controlsMap.getControlMapData((Control)invokedObject);
                if (mapData != null)
                {
                    //Raise the event.
                    Events.OnDNControlValueChanged(mapData.getControl(), mapData.getIdx());
                }
            }
        }
Exemple #3
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 #4
0
        /// <summary>
        ///   process message
        ///   find out if the message is from child of the .NET control and process it
        /// </summary>
        /// <param name = "m"></param>
        /// <returns></returns>
        private static bool handleChildrenOfDotNetControls(Message m)
        {
            PreProcessControlState state       = PreProcessControlState.MessageNotNeeded;
            ControlsMap            controlsMap = ControlsMap.getInstance();
            MapData mapData;

            switch (m.Msg)
            {
            //this are common messages that we want to handle for children of .NET controls
            case NativeWindowCommon.WM_MOUSEMOVE:
            case NativeWindowCommon.WM_LBUTTONDOWN:
            case NativeWindowCommon.WM_LBUTTONUP:
            case NativeWindowCommon.WM_LBUTTONDBLCLK:
            case NativeWindowCommon.WM_KEYDOWN:
                Control c, control = c = Control.FromChildHandle(m.HWnd);
                if (c != null)
                {
                    mapData = controlsMap.getControlMapData(c);
                    if (mapData != null) //this is a magic control
                    {
                        //this is a .NET control on magic
                        if (isDotNetControl(mapData) && m.Msg == NativeWindowCommon.WM_KEYDOWN)
                        {
                            state = ProcessAndHandleDotNetControlMessage(m, mapData, control, control); //then handle it in magic
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else //look for magic parent of the control
                    {
                        while (c.Parent != null)
                        {
                            c       = c.Parent;
                            mapData = controlsMap.getControlMapData(c);
                            if (mapData != null)
                            {
                                if (isDotNetControl(mapData))
                                {
                                    //FOUND! This is a child of .NET control
                                    state = ProcessAndHandleDotNetControlMessage(m, mapData, c, control);
                                }
                                break;
                            }
                        }
                    }
                }
                break;

            case NativeWindowCommon.WM_KEYUP:
            {
                // Handled here because while moving between windows of windowlist using keyboard (ie. Ctrl+Tab+Tab+,...),
                // the list should not be sorted until we release key associated with Next/Previous window Action.
                Control ctrl = Control.FromHandle(m.HWnd);
                if (ctrl != null)
                {
                    Form form = GuiUtils.FindForm(ctrl);
                    if (form != null && ControlsMap.isMagicWidget(form))
                    {
                        // Each form has a panel and panel contains all controls.
                        mapData = controlsMap.getControlMapData(((TagData)form.Tag).ClientPanel);
                        if (mapData != null)
                        {
                            Events.HandleKeyUpMessage(mapData.getForm(), (int)m.WParam);
                        }
                    }
                }
            }
            break;
            }
            return(state == PreProcessControlState.MessageProcessed);
        }