Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="evtArgs"></param>
        internal override void handleEvent(EventType type, Object sender, EventArgs evtArgs)
        {
            MapData mapData = ControlsMap.getInstance().getMapData(sender);

            if (mapData == null)
            {
                return;
            }

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(mapData.getControl()));

            try
            {
                switch (type)
                {
                case EventType.RESIZE:
                    GuiUtils.setBackgroundImage((Control)sender);
                    break;

                case EventType.MOUSE_WHEEL:
                case EventType.MOUSE_DOWN:
                case EventType.MOUSE_UP:
                case EventType.MOUSE_DBLCLICK:
                    //case EventType.KeyDown:
                    break;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, evtArgs);
        }
Esempio n. 2
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();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap  controlsMap = ControlsMap.getInstance();
            MgWebBrowser webBroswer  = (MgWebBrowser)sender;

            MapData mapData = controlsMap.getMapData(webBroswer);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl guiMgCtrl      = mapData.getControl();
            var          contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgCtrl));

            try
            {
                switch (type)
                {
                case EventType.GOT_FOCUS:
                    Events.OnFocus(guiMgCtrl, 0, false, false);
                    return;

                case EventType.DISPOSED:
                    break;

#if !PocketPC
                case EventType.STATUS_TEXT_CHANGED:
                    String statusText         = webBroswer.StatusText.Trim();
                    String previousStatusText = ((TagData)webBroswer.Tag).BrowserControlStatusText;
                    if (statusText.Length > 0 && !statusText.Equals(previousStatusText))
                    {
                        ((TagData)webBroswer.Tag).BrowserControlStatusText = statusText;
                        Events.OnBrowserStatusTxtChange(guiMgCtrl, statusText);
                    }
                    break;
#endif

                case EventType.EXTERNAL_EVENT:
                    ExternalEventArgs args = (ExternalEventArgs)e;
                    Events.OnBrowserExternalEvent(guiMgCtrl, args.Param);
                    break;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }
            DefaultHandler.getInstance().handleEvent(type, sender, e);
        }
Esempio n. 4
0
        /// <summary> handle the event of the MgSplitContainer</summary>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            MgSplitContainer mgSplitContainer = (MgSplitContainer)sender;
            DefaultHandler   defaultHandler   = DefaultHandler.getInstance();

            switch (type)
            {
            case EventType.PAINT:
                Graphics G = ((PaintEventArgs)e).Graphics;
                if (GuiUtils.isOutmostMgSplitContainer(mgSplitContainer))
                {
                    Rectangle rect = ((Control)mgSplitContainer).ClientRectangle;
                    Pen       pen  = new Pen(Color.Black, 1);

                    // draw top horizontal lines -
                    pen.Color = SystemColors.ButtonShadow;
                    G.DrawLine(pen, rect.X, rect.Y, rect.Width - 2, rect.Y);
                    pen.Color = Color.Black;
                    G.DrawLine(pen, rect.X + 1, rect.Y + 1, rect.Width - 4, rect.Y + 1);

                    // draw left vertical lines |-
                    pen.Color = SystemColors.ButtonShadow;
                    G.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Height - 3);
                    pen.Color = Color.Black;
                    G.DrawLine(pen, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Height - 4);

                    // draw bottom horizontal lines _
                    pen.Color = SystemColors.ButtonHighlight;
                    G.DrawLine(pen, rect.X + 1, rect.Height - 2, rect.Width - 2, rect.Height - 2);

                    //// draw right vertical lines -|
                    pen.Color = SystemColors.ButtonHighlight;
                    G.DrawLine(pen, rect.Width - 2, rect.Y, rect.Width - 2, rect.Height - 1);

                    pen.Dispose();
                }
                break;

            case EventType.KEY_DOWN:
                defaultHandler.handleEvent(type, sender, e);
                break;

            case EventType.RESIZE:
                mgSplitContainer.onResize();
                break;
            }
        }
Esempio n. 5
0
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            Control     control     = (Control)sender;
            ControlsMap controlsMap = ControlsMap.getInstance();
            MapData     mapData     = controlsMap.getMapData(control);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl ctrl = mapData.getControl();

            switch (type)
            {
#if PocketPC
            case EventType.ENABLED_CHANGED:
                ((TagData)control.Tag).TabControlPanel.Invalidate();
                break;
#else
            case EventType.SELECTING:
                ((TabControlCancelEventArgs)e).Cancel = true;
                ((TagData)control.Tag).SelectingIdx   = ((TabControl)control).SelectedIndex;
                GuiUtils.setSuggestedValueOfChoiceControlOnTagData(control, "" + ((TabControl)control).SelectedIndex);
                return;

            case EventType.MNEMONIC_KEY_PRESSED:
                Events.OnSelection(((MnemonicKeyPressedEventArgs)e).SelectedTabIndex.ToString(), ctrl, 0, false);
                return;
#endif
            case EventType.DISPOSED:
                if (control.Tag != null)
                {
                    ((TagData)control.Tag).TabControlPanel.Dispose();
                }
                return;
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e);
        }
Esempio n. 6
0
        /// <summary> handle the event of the MgSplitContainer</summary>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            Splitter       splitter       = (Splitter)sender;
            DefaultHandler defaultHandler = DefaultHandler.getInstance();

            switch (type)
            {
            case EventType.PAINT:
                onPaint(splitter, (PaintEventArgs)e);
                break;

            case EventType.SPLITTER_MOVING:
                onSplitterMoving(splitter, (SplitterEventArgs)e);
                break;

            case EventType.SPLITTER_MOVED:
                onSplitterMoved(splitter, (SplitterEventArgs)e);
                break;

            case EventType.RESIZE:
                ((MgSplitContainer)splitter.Parent).onResize();
                break;
            }
        }
Esempio n. 7
0
 /// <summary> </summary>
 internal override void handleEvent(EventType type, Object sender, EventArgs e)
 {
     DefaultHandler.getInstance().handleEvent(type, sender, e);
 }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap controlsMap = ControlsMap.getInstance();
            MgComboBox  comboBox    = (MgComboBox)sender;
            MapData     mapData     = controlsMap.getMapData(comboBox);

            if (mapData == null)
            {
                return;
            }

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(mapData.getControl()));

            try
            {
                switch (type)
                {
                case EventType.RESIZE:
                    GuiMgControl mgControl = mapData.getControl();
                    if (mgControl.IsTableHeaderChild)
                    {
                        comboBox.Invalidate();
                    }
                    break;

                case EventType.MOUSE_DOWN:
                    ((TagData)comboBox.Tag).HandleOnDropDownClosed = false;

                    GuiUtils.saveFocusingControl(GuiUtils.FindForm(comboBox), mapData);
                    DefaultHandler.getInstance().handleEvent(type, sender, e);

                    // QCR #713073 Process drop down only for left mouse click. right click opens the context menu.
                    if (((MouseEventArgs)e).Button == MouseButtons.Left)
                    {
#if !PocketPC
                        // In mouse down event, we initiate drag and since we are returning from here,
                        // we need to handle it here itself as it won't call defaulthandler.handleEvent.
                        GuiUtils.AssessDrag((Control)sender, (MouseEventArgs)e, mapData);
#endif

                        // QCR #927727, this will prevent openning combo for non parkable conrols
                        Events.OnComboDroppingDown(mapData.getControl(), mapData.getIdx());
                    }
                    return;

                case EventType.DROP_DOWN:
                    // when the drop down is open reset the member
                    ((TagData)comboBox.Tag).ClickOnComboDropDownList = false;
                    break;

                case EventType.DROP_DOWN_CLOSED:
                    OnDropDownClosed(comboBox, e);
                    break;

                case EventType.KEY_DOWN:
                    if (OnkeyDown(sender, e))
                    {
                        return;
                    }
                    break;

                case EventType.SELECTED_INDEX_CHANGED:
                    ((TagData)comboBox.Tag).HandleOnDropDownClosed = false;
                    TagData tg = ((TagData)comboBox.Tag);
                    tg.IgnoreTwiceClickWhenToValueIs = GuiUtils.getValue(comboBox);
                    //fixed bug #:782615, when type char, we get click_index_change in spite of the index isn't changed.
                    //                    ignore when the value isn't real changed
                    //While creating combo control, if you try to select the option from combo using key,
                    //ListControlOriginalValue is not initialized yet. So, return.
                    if (tg.ListControlOriginalValue == null || tg.ListControlOriginalValue.Equals(tg.IgnoreTwiceClickWhenToValueIs))
                    {
                        return;
                    }

                    //we must this fixed for bug #:768284, we get twice before the GuiCommandQueue.setselection(comboBox) was called.
                    //                                     so the value on tg.ComboBoxOriginalValue isn't updated yet.
                    if (tg.IgnoreTwiceClick)
                    {
                        if (tg.IgnoreTwiceClickWhenToValueIs == tg.IgnoreTwiceClickWhenFromValueIs)
                        {
                            tg.IgnoreTwiceClickWhenFromValueIs = tg.IgnoreTwiceClickWhenToValueIs;
                            tg.IgnoreTwiceClick = false;
                            return;
                        }
                        else
                        {
                            tg.IgnoreTwiceClickWhenFromValueIs = tg.IgnoreTwiceClickWhenToValueIs;
                        }
                    }
                    break;

                case EventType.PRESS:
                    // save current control as last focused control
                    if (!comboBox.Focused)
                    {
                        GuiUtils.saveFocusingControl(GuiUtils.FindForm(comboBox), mapData);
                    }
                    break;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e);
        }
Esempio n. 9
0
        /// <summary>
        ///   handle message of  child of .NET control
        ///   create event according to message and handle it in usual manner
        /// </summary>
        /// <param name = "m"> message </param>
        /// <param name = "mapData"> map data of .NET control</param>
        /// <param name = "control">control which receive message - the child of .NET control</param>
        /// <param name="state"></param>
        private static void handleMessage(Message m, MapData mapData, Control control, PreProcessControlState state)
        {
            EventArgs e = null;

            HandlerBase.EventType eventType = HandlerBase.EventType.NONE;

            switch (m.Msg)
            {
            case NativeWindowCommon.WM_LBUTTONDOWN:
                e         = createLeftMouseEventArgs(1, (int)m.LParam);
                eventType = HandlerBase.EventType.MOUSE_DOWN;
                break;

            case NativeWindowCommon.WM_LBUTTONUP:
                e         = createLeftMouseEventArgs(1, (int)m.LParam);
                eventType = HandlerBase.EventType.MOUSE_UP;
                break;

            case NativeWindowCommon.WM_LBUTTONDBLCLK:
                e         = createLeftMouseEventArgs(2, (int)m.LParam);
                eventType = HandlerBase.EventType.MOUSE_DBLCLICK;
                break;

            case NativeWindowCommon.WM_MOUSEMOVE:
                e         = createLeftMouseEventArgs(1, (int)m.LParam);
                eventType = HandlerBase.EventType.MOUSE_MOVE;
                break;

            case NativeWindowCommon.WM_KEYDOWN:
                eventType = HandlerBase.EventType.KEY_DOWN;
                Keys keyCode = GetKeyCode(m);
                e = new KeyEventArgs(keyCode);
                DotNetHandler.getInstance().handleEvent("KeyDown", control, e, mapData);


                // we use preProcessResult only for navigation keys
                // if control returns preProcessResult = false for a navigation key then we do not
                // interfere because the control already handled the navigation internally.
                if (state == PreProcessControlState.MessageNeeded)
                {
                    foreach (var item in _navigationKeys)
                    {
                        if (keyCode == item)
                        {
                            return;
                        }
                    }
                }
                if (keyCode == Keys.Tab && !keyShouldBeHandledByMagic) //QCR #728708
                //special handling for a tab key, in future may be extended for othe keys as weel.
                {
                    return;
                }

                break;

            default:
                Debug.Assert(false);
                break;
            }

            DefaultHandler.getInstance().handleEvent(eventType, control, e, mapData);
        }
Esempio n. 10
0
        /// <summary> </summary>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap  controlsMap  = ControlsMap.getInstance();
            Control      control      = (Control)sender;
            RadioButton  radioButton  = (RadioButton)sender;
            MgRadioPanel mgRadioPanel = (MgRadioPanel)radioButton.Parent;
            MapData      mapData      = controlsMap.getMapData(mgRadioPanel);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl guiMgControl        = mapData.getControl();
            Type         senderType          = sender.GetType();
            bool         leftClickWasPressed = false;

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgControl));

            try
            {
                switch (type)
                {
                case EventType.MOUSE_DOWN:
                    //fixed bug #435168 , saveing the widget that we made MouseDown on the comosite control
                    ((TagData)mgRadioPanel.Tag).MouseDownOnControl = radioButton;
                    GuiUtils.checkAndCloseTreeEditorOnClick(control);
                    MouseEventArgs mouseEvtArgs = (MouseEventArgs)e;
                    GuiUtils.SaveLastClickInfo(mapData, (Control)sender, new Point(mouseEvtArgs.X, mouseEvtArgs.Y));
#if !PocketPC //tmp
                    GuiUtils.setTooltip(control, "");
#endif
                    String Value = GuiUtils.GetRadioButtonIndex(radioButton);
                    GuiUtils.setSuggestedValueOfChoiceControlOnTagData(mgRadioPanel, Value);
                    Events.OnSelection(Value, guiMgControl, mapData.getIdx(), true);
                    //the right click isn't move the focus to the control, only on left click.
                    leftClickWasPressed = (((MouseEventArgs)e).Button == MouseButtons.Left);

                    if (leftClickWasPressed)
                    {
                        Events.OnMouseDown(null, guiMgControl, null, leftClickWasPressed, mapData.getIdx(), false, true);
#if !PocketPC
                        GuiUtils.AssessDrag(control, (MouseEventArgs)e, mapData);
#endif
                    }
                    else
                    {
                        control.Focus();
                    }
                    return;

                case EventType.KEY_DOWN:
                    ((TagData)mgRadioPanel.Tag).MouseDownOnControl = null;
                    break;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e, mapData);
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap controlsMap = ControlsMap.getInstance();
            Control     control     = (Control)sender;
            MapData     mapData     = controlsMap.getMapData(control);

            if (mapData == null)
            {
                return;
            }

            Type    senderType = sender.GetType();
            ListBox listBox    = (ListBox)sender;

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(mapData.getControl()));

            try
            {
                switch (type)
                {
                case EventType.MOUSE_DOWN:
                    MouseEventArgs mouseEvtArgs = (MouseEventArgs)e;
                    GuiUtils.SaveLastClickInfo(mapData, (Control)sender, new Point(mouseEvtArgs.X, mouseEvtArgs.Y));
                    bool leftClickWasPressed = (((MouseEventArgs)e).Button == MouseButtons.Left);
                    GuiUtils.SetOnClickOnTagData(control, leftClickWasPressed);

#if !PocketPC
                    if (leftClickWasPressed)
                    {
                        GuiUtils.AssessDrag(control, (MouseEventArgs)e, mapData);
                    }
#endif

                    return;

                case EventType.MOUSE_UP:
                case EventType.GOT_FOCUS:
                case EventType.LOST_FOCUS:
                    GuiUtils.SetOnClickOnTagData(control, false);

#if !PocketPC
                    if (type == EventType.MOUSE_UP)
                    {
                        GuiUtils.ResetDragInfo(control);
                    }
#endif
                    return;

                case EventType.KEY_DOWN:
                    if (OnkeyDown(type, sender, e))
                    {
                        return;
                    }
                    break;

                case EventType.CLICK:
                    // we do not want the process selection to accure here. only in SelectedIndexChanged.
                    return;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e);
        }
Esempio n. 12
0
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap controlsMap = ControlsMap.getInstance();
            UtilImeJpn  utilImeJpn  = Manager.UtilImeJpn;

            TextBox textCtrl = (TextBox)sender;
            int     start;
            int     end;

            MapData mapData = controlsMap.getMapData(textCtrl);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl guiMgCtrl = mapData.getControl();
            GuiMgForm    guiMgForm = mapData.getForm();

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgCtrl));

            if (Events.ShouldLog(Logger.LogLevels.Gui))
            {
                Events.WriteGuiToLog("TextBoxHandler(\"" + mapData.getControl().getName(mapData.getIdx()) + "\"): " + type);
            }

            try
            {
                switch (type)
                {
                case EventType.GOT_FOCUS:
                    // check the paste enable. check the clip content.
                    if (mapData != null)
                    {
                        GuiUtils.checkPasteEnable(mapData.getControl(), true);
                        GuiUtils.SetFocusColor(textCtrl);
                    }
                    break;

                case EventType.LOST_FOCUS:
                    // Always disable paste when exiting a text ctrl. (since we might be focusing on a diff type of
                    // ctrl).
                    if (mapData != null)
                    {
                        GuiUtils.disablePaste(mapData.getControl());
                        GuiUtils.ResetFocusColor(textCtrl);
                    }
                    break;

                case EventType.KEY_UP:
                    GuiUtils.enableDisableEvents(sender, mapData.getControl());
                    return;

                case EventType.KEY_DOWN:
                    KeyEventArgs keyEventArgs = (KeyEventArgs)e;

                    if (ShouldBeHandledByTextBox(textCtrl, keyEventArgs))
                    {
                        GuiUtils.checkAutoWide(mapData.getControl(), textCtrl, GuiUtils.getValue(textCtrl));
                        keyEventArgs.Handled = false;
                        return;
                    }
                    break;

                case EventType.IME_EVENT:
                    // (Korean) IME messages (WM_IME_COMPOSITION, etc.) are handled as pseudo-input
                    // where action=MG_ACT_CHAR, text=" ".
                    // To distinguish with real " ", ImeParam im is attached to RuntimeEvent.
                    ImeEventArgs iea = (ImeEventArgs)e;
                    start = textCtrl.SelectionStart;
                    end   = textCtrl.SelectionStart + textCtrl.SelectionLength;
                    Events.OnKeyDown(guiMgForm, guiMgCtrl, Modifiers.MODIFIER_NONE, 0, start, end, " ", iea.im, true, "-1", false, iea.Handled);
                    iea.Handled = true;
                    break;

                case EventType.KEY_PRESS:
                    KeyPressEventArgs keyPressEventArgs = (KeyPressEventArgs)e;
                    // skipp control key
                    if (Char.IsControl(keyPressEventArgs.KeyChar))
                    {
                        return;
                    }

                    start = textCtrl.SelectionStart;
                    end   = textCtrl.SelectionStart + textCtrl.SelectionLength;
                    String pressedChar = "" + keyPressEventArgs.KeyChar;

                    // flag the isActChar to indicate this is MG_ACT_CHAR
                    Events.OnKeyDown(guiMgForm, guiMgCtrl, Modifiers.MODIFIER_NONE, 0, start, end, pressedChar, true, "-1", keyPressEventArgs.Handled);
                    keyPressEventArgs.Handled = true;
                    break;

                case EventType.MOUSE_UP:
                    GuiUtils.enableDisableEvents(sender, mapData.getControl());
                    break;

                case EventType.CUT:
                    Events.CutEvent(mapData.getControl());
                    return;

                case EventType.COPY:
                    Events.CopyEvent(mapData.getControl());
                    return;

                case EventType.PASTE:
                    Events.PasteEvent(mapData.getControl());
                    return;

                case EventType.CLEAR:
                    Events.ClearEvent(mapData.getControl());
                    return;

                case EventType.UNDO:
                    Events.UndoEvent(mapData.getControl());
                    return;



                case EventType.STATUS_TEXT_CHANGED:
                    // JPN: ZIMERead function
                    if (utilImeJpn != null && sender is MgTextBox && !utilImeJpn.IsEditingCompStr((Control)sender))
                    {
                        utilImeJpn.StrImeRead = ((MgTextBox)sender).GetCompositionString();
                    }
                    return;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e);
        }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            Control   clientPanel;
            MapData   mapData;
            GuiMgForm guiMgForm;

            // When modal window is opened and if we close the form Modal form using external event (i.e. Stop RTE from studio / Exit System event)
            // We are getting closed event 2 times for a modal window :
            //          1) First time from GuiCommandsQueue.closeForm() due to form.close() and
            //          2) We are not able to figure out from where we are getting the second closed event.
            // When we come here to process closed event second time the object is already disposed, hence we should not process any events.
            if (GuiUtils.isDisposed((Control)sender))
            {
                return;
            }

            clientPanel = ((TagData)((Control)sender).Tag).ClientPanel;
            if (clientPanel == null)
            {
                clientPanel = (Control)sender;
            }
            mapData   = ControlsMap.getInstance().getMapData(clientPanel);
            guiMgForm = mapData.getForm();
            GuiForm form = (GuiForm)sender;


            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgForm));

            try
            {
                switch (type)
                {
                case EventType.LOAD:
#if !PocketPC
                    // #919192: Icon displayed for an maximised MDI Child is not the one set in
                    // form's Icon property before loading the form.
                    // This is a framework bug. The workaround is to set the icon for Maximised MDI Child again in load handler.
                    if (form.IsMdiChild && form.WindowState == FormWindowState.Maximized)
                    {
                        Icon originalIcon = form.Icon;
                        form.Icon = null;
                        form.Icon = originalIcon;
                    }
                    ContextForms.AddForm(form);
#endif
                    form.Activate();
                    break;

                case EventType.CAN_REPOSITION:

                    if (form.IsMdiChild && OldZorderManager.getInstance().UseOldZorderAlgorithm)
                    {
                        if (!ContextForms.IsLastForm(form))
                        {
                            GuiForm nextForm = ContextForms.GetNextForm(form);
                            if (nextForm.Handle != ((RepositionEventArgs)e).HwndInsertAfter)
                            {
                                ((RepositionEventArgs)e).CanReposition = false;
                            }
                        }
                    }
                    break;

                case EventType.ACTIVATED:
                    //ClientManager.Instance.RefreshMenu(mgForm.getTask().getMgdID());
                    OnFormActivate(form);
                    //Defect 124155 - if form is ancestor to blocking batch form - return activation to the batch
                    if (form.IsMdiChild && ContextForms.IsBlockedByMdiForm(form))
                    {
                        GuiForm formToActivate = ContextForms.GetBlockingFormToActivate(form);
                        if (formToActivate != null && !formToActivate.IsClosing)
                        {
                            formToActivate.Activate();
                        }
                    }

                    break;

                case EventType.WMACTIVATE:
                    OnWmActivate(form, e);

                    break;

#if !PocketPC
                case EventType.SHOWN:
                    if (form.WindowState == FormWindowState.Normal &&
                        ((TagData)form.Tag).WindowType != WindowType.FitToMdi &&
                        ((TagData)form.Tag).WindowType != WindowType.Sdi &&
                        ((TagData)form.Tag).WindowType != WindowType.MdiFrame)
                    {
                        Rectangle?savedbounds = GuiUtils.getSavedBounds(form);
                        if (savedbounds != null)
                        {
                            Rectangle rect = (Rectangle)savedbounds;

                            if (rect.Size != form.ClientSize)
                            {
                                GuiUtils.setBounds(form, rect);
                            }
                        }
                    }

                    GuiUtils.saveFormBounds(form);
                    form.Resize += FormHandler.getInstance().ResizeHandler;

                    // form is shown, so set the flag as false
                    PrintPreviewFocusManager.GetInstance().IsInModalFormOpening = false;
                    ((TagData)form.Tag).IsShown = true;
                    break;
#endif
                case EventType.MDI_CHILD_ACTIVATED:

                    Events.OnFormActivate(guiMgForm);


                    break;

                case EventType.RESIZE:
                    if (((TagData)form.Tag).IgnoreWindowResizeAndMove)
                    {
                        return;
                    }
                    onResize(form, guiMgForm);
                    break;

                case EventType.RESIZE_BEGIN:
                    OnResizeBegin(form);
                    break;

                case EventType.RESIZE_END:
                    OnResizeEnd(form);
                    break;

                case EventType.LAYOUT:
#if !PocketPC
                    if (GuiUtils.IsFormMinimized(form))
                    {
                        ((TagData)form.Tag).Minimized = true;
                    }
                    else if (!((TagData)form.Tag).IsShown)
                    {
                        ((TagData)form.Tag).Minimized = false;
                    }
#endif
                    if (((TagData)form.Tag).WindowType == WindowType.Sdi)
                    {
                        SDIFormLayout(form);
                    }
                    return;

                case EventType.SIZING:
                    OnSizing(form, (SizingEventArgs)e);
                    break;

#if !PocketPC //tmp
                case EventType.COPY_DATA:
                    Events.OnCopyData(guiMgForm, ((CopyDataEventArgs)e).Copydata);
                    return;

                case EventType.MOVE:
                    if (((TagData)form.Tag).WindowType == WindowType.ChildWindow)
                    {
                        Control parent = form.Parent;


                        Debug.Assert(parent is Panel);
                        Form parentform = GuiUtils.FindForm(parent);
                        if (GuiUtils.IsFormMinimized(parentform))
                        {
                            return;
                        }

                        EditorSupportingPlacementLayout placementLayout = ((TagData)parent.Tag).PlacementLayout;
                        if (placementLayout != null)
                        {
                            //TODO: If the child window is moved due to scrolling of the parent window,
                            //computeAndUpdateLogicalSize() should not be called.
                            placementLayout.computeAndUpdateLogicalSize(parent);
                        }
                    }

                    if (((TagData)form.Tag).IgnoreWindowResizeAndMove)
                    {
                        return;
                    }
                    onMove(form, guiMgForm);
                    break;
#endif
                case EventType.CLOSING:
                    //handle the event only if it was not canceled.
                    if (((CancelEventArgs)e).Cancel == false)
                    {
                        bool clrHandledEvent = false;
#if !PocketPC
                        //When MDI Frame is closing, We should not put ACT_EXIT on each it's child windows.
                        //This causes invokation of confirmation dialog, which should be avoided.
                        WindowType windowType = ((TagData)form.Tag).WindowType;
                        if (((FormClosingEventArgs)e).CloseReason == System.Windows.Forms.CloseReason.MdiFormClosing &&
                            (windowType == WindowType.MdiChild || windowType == WindowType.FitToMdi))
                        {
                            return;
                        }
#endif
                        clrHandledEvent = Events.OnFormClose(guiMgForm);


#if !PocketPC //tmp
                        // If CloseReason is UserClosing, then only set Cancel.
                        if (((FormClosingEventArgs)e).CloseReason == System.Windows.Forms.CloseReason.UserClosing)
#endif
                        //If clrHandledEvent is true then 'Cancel' should be false else true.
                        ((CancelEventArgs)e).Cancel = !clrHandledEvent;
                    }
                    return;

                case EventType.CLOSED:
#if PocketPC
                    GUIMain.getInstance().MainForm.closeSoftKeyboard();
#endif
                    break;

                case EventType.NCMOUSE_DOWN:
                    if (!IsClickOnCloseButton((NCMouseEventArgs)e))
                    {
#if !PocketPC
                        // QCR #414516. Click on title bar mustn't move cursor to the parent task.
                        Form previousActiveForm = Form.ActiveForm ?? lastActiveTopLevelForm;

                        //defect 120508 : if the form was already active - we should not process the mouse down
                        if (GuiUtils.FindTopLevelForm(form) != previousActiveForm)
#endif
                        Events.OnMouseDown(guiMgForm, null, null, true, 0, true, true);
                    }
                    break;

                case EventType.NCACTIVATE:
                    Events.OnNCActivate(guiMgForm);
                    break;

                case EventType.DISPOSED:
                    Events.OnDispose(guiMgForm);
                    ContextForms.RemoveForm(form);

                    clientPanel.Tag = null;
                    form.Tag        = null;

                    return;

                case EventType.DEACTIVATED:
                    Events.OnCloseHelp(guiMgForm);
                    break;

#if PocketPC
                case EventType.KEY_DOWN:
                    // Key event preview - KeyDown with 'tab' key is usually used by the system to move the focus
                    // between controls. We want to do it ourselves, so we intercept it here and pass it to the control
                    // in focus.
                    if (((KeyEventArgs)e).KeyCode == Keys.Tab)
                    {
                        // get the tagdata and look for the control that has the focus
                        TagData tagData = (TagData)((Control)sender).Tag;

                        // If the control is one of those for which we need to raise the event, aise it and mark the
                        // event as handled.
                        if (tagData.LastFocusedControl is MgTextBox)
                        {
                            ((MgTextBox)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e);
                            ((KeyEventArgs)e).Handled = true;
                        }
                        else if (tagData.LastFocusedControl is MgCheckBox)
                        {
                            ((MgCheckBox)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e);
                            ((KeyEventArgs)e).Handled = true;
                        }
                        else if (tagData.LastFocusedControl is MgComboBox)
                        {
                            ((MgComboBox)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e);
                            ((KeyEventArgs)e).Handled = true;
                        }
                        else if (tagData.LastFocusedControl is MgButtonBase)
                        {
                            ((MgButtonBase)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e);
                            ((KeyEventArgs)e).Handled = true;
                        }
                        else if (tagData.LastFocusedControl is MgTabControl)
                        {
                            ((MgTabControl)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e);
                            ((KeyEventArgs)e).Handled = true;
                        }
                    }
                    return;
#endif
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }
            DefaultHandler.getInstance().handleEvent(type, sender, e, mapData);
        }
Esempio n. 14
0
        /// <summary></summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="evtArgs"></param>
        internal override void handleEvent(EventType type, Object sender, EventArgs evtArgs)
        {
            ControlsMap controlsMap = ControlsMap.getInstance();
            Control     ctrl        = (Control)sender;
            MapData     mapData     = controlsMap.getMapData(ctrl);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl mgControl = mapData.getControl();
            MgLinkLabel  linkLabel = ctrl as MgLinkLabel;

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(mgControl));

            try
            {
                if (linkLabel != null)
                {
                    switch (type)
                    {
                    case EventType.LINK_CLICKED:
                        LinkLabelLinkClickedEventArgs args = (LinkLabelLinkClickedEventArgs)evtArgs;
#if !PocketPC
                        if (args.Button == MouseButtons.Left)
#endif
                        // Mobile: we get here only with a left button click
                        OnLinkClicked(linkLabel, controlsMap, mapData, mgControl, true);
                        return;

                    case EventType.GOT_FOCUS:
                    case EventType.MOUSE_UP:
                        break;

                    case EventType.MOUSE_DOWN:
                        if (!linkLabel.Focused)
                        {
                            GuiUtils.saveFocusingControl(GuiUtils.FindForm(linkLabel), mapData);
                        }

                        break;

                    case EventType.MOUSE_ENTER:
                        linkLabel.OnHovering = true;
                        break;

                    case EventType.MOUSE_LEAVE:
                        linkLabel.OnHovering = false;
                        break;

                    case EventType.KEY_DOWN:
                        KeyEventArgs keyEventArgs = (KeyEventArgs)evtArgs;

                        if (KbdConvertor.isModifier(keyEventArgs.KeyCode))
                        {
                            return;
                        }

                        if (keyEventArgs.Modifiers == Keys.None && keyEventArgs.KeyCode == Keys.Space)
                        {
                            OnLinkClicked(linkLabel, controlsMap, mapData, mgControl, false);
                            return;
                        }
                        break;

                    case EventType.PRESS:
                        if (!linkLabel.Focused)
                        {
                            GuiUtils.saveFocusingControl(GuiUtils.FindForm(linkLabel), mapData);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }


            DefaultHandler.getInstance().handleEvent(type, sender, evtArgs);
        }
Esempio n. 15
0
        /// <summary> </summary>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap controlsMap = ControlsMap.getInstance();
            Control     ctrl        = (Control)sender;
            MapData     mapData     = controlsMap.getMapData(ctrl);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl guiMgControl  = mapData.getControl();
            bool         isButton      = (ctrl is MgButtonBase);
            bool         isImageButton = (ctrl is MgImageButton);
            bool         isCheckBox    = (ctrl is MgCheckBox);

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgControl));

            try
            {
                switch (type)
                {
                case EventType.MOUSE_LEAVE:
                    if (isImageButton && ((MgImageButton)ctrl).Supports6Images())
                    {
                        ((TagData)(ctrl).Tag).OnHovering = false;
                        GuiUtils.RefreshButtonImage(ctrl);
                    }
                    break;

                case EventType.MOUSE_ENTER:
                    if (isImageButton && ((MgImageButton)ctrl).Supports6Images())
                    {
                        ((TagData)(ctrl).Tag).OnHovering = true;
                        GuiUtils.RefreshButtonImage(ctrl);
                    }
                    break;

                case EventType.CLICK:
                    if (isButton)
                    {
                        bool isClick = false;

                        // if it is not click (onMouseDown) and lastparked ctrl is not equal to button, then
                        // it has come through accelerators and accelerators should be considered as click
                        if (((TagData)ctrl.Tag).OnMouseDown)
                        {
                            isClick = true;
                        }

                        String controlName = guiMgControl == null ? "" : guiMgControl.Name;
                        Events.SaveLastClickedCtrlName(guiMgControl, controlName);

                        Events.OnSelection(GuiUtils.getValue(ctrl), guiMgControl, mapData.getIdx(), isClick);
                        GuiUtils.SetOnClickOnTagData(ctrl, false);
                        GuiUtils.RefreshButtonImage(ctrl);
                    }
                    return;

                case EventType.MOUSE_DOWN:
                    bool mouseDown = (isButton ? ((MouseEventArgs)e).Button == MouseButtons.Left : true);
                    GuiUtils.SetOnClickOnTagData(ctrl, mouseDown);
                    if (isImageButton)
                    {
                        GuiUtils.RefreshButtonImage(ctrl);
                    }
                    if (isButton || isCheckBox)
                    {
                        MouseEventArgs mouseEvtArgs = (MouseEventArgs)e;
                        GuiUtils.SaveLastClickInfo(mapData, (Control)sender, new Point(mouseEvtArgs.X, mouseEvtArgs.Y));
#if !PocketPC
                        // In mouse down event, we initiate drag and since we are returning from here,
                        // we need to handle it here itself as it won't call defaulthandler.handleEvent.
                        if (((MouseEventArgs)e).Button == MouseButtons.Left)
                        {
                            GuiUtils.AssessDrag(ctrl, (MouseEventArgs)e, mapData);
                        }
#endif
                        return;
                    }
                    break;

                case EventType.KEY_PRESS:
                    /*For CheckBox and Button, Space bar key should be ignored as it is handled thr' selection event.*/
                    if (Char.IsWhiteSpace(((KeyPressEventArgs)e).KeyChar))
                    {
                        return;
                    }
                    break;

                case EventType.LOST_FOCUS:
                    if (isButton)
                    {
                        GuiUtils.SetOnClickOnTagData(ctrl, false);
                        GuiUtils.RefreshButtonImage(ctrl);

                        //fixed bug #:252654, .NET display the control and hot Track in spite of it's not,
                        //            when focus is lost update the UIIState by set UISF_HIDEFOCUS
                        //            the same fixed was done in online for check box in
                        UpdateUIstate(ctrl, true);
                    }
                    return;

                case EventType.GOT_FOCUS:
                    GuiUtils.SetOnClickOnTagData(ctrl, false);
                    if (isButton)
                    {
                        GuiUtils.RefreshButtonImage(ctrl);

                        //fixed bug #:252654, .NET display the control and hot Track in spite of it's not,
                        //            when focus is got update the UIIState by clear the UISF_HIDEFOCUS
                        //            the same fixed was done in online for check box in
                        UpdateUIstate(ctrl, false);
                    }
                    if (isButton || isCheckBox)
                    {
                        return;
                    }
                    else
                    {
                        break;
                    }

                case EventType.MOUSE_UP:
                    GuiUtils.SetOnClickOnTagData(ctrl, false);
                    if (isImageButton)
                    {
                        GuiUtils.RefreshButtonImage(ctrl);
                    }

#if !PocketPC
                    // Reset drag information, since we are returning from here.
                    GuiUtils.ResetDragInfo(ctrl);
#endif
                    return;

                case EventType.RESIZE:
                    if (isImageButton)
                    {
                        GuiUtils.RefreshButtonImage(ctrl);
                    }
                    break;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e);
        }
Esempio n. 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="mapData"></param>
        internal void handleEvent(EventType type, Control sender, EventArgs e, MapData mapData)
        {
            MapData          orgMapData       = mapData;
            ContainerManager containerManager = GuiUtils.getContainerManager(sender);

            switch (type)
            {
#if !PocketPC
            case EventType.DRAG_OVER:
            case EventType.DRAG_DROP:
                // Need to get current Control, Hence needed
                Point pt     = new Point(((DragEventArgs)e).X, ((DragEventArgs)e).Y);
                Point screen = sender.PointToClient(pt);
                mapData = containerManager.HitTest(screen, true, false);
                break;
#endif
            case EventType.MOUSE_MOVE:
                // the mouse move will handle the tooltip
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, false);
                break;

            case EventType.NCMOUSE_DOWN:
                MapData containerMapData = ControlsMap.getInstance().getMapData(sender);
                Events.OnMouseDown(containerMapData.getForm(), containerMapData.getControl(), null, true, 0, true, true);
                break;

            case EventType.MOUSE_DOWN:
                // check if a point on some table child
                // fixed bug #986057 (same in online)
                // * when pressing Rclick(button != 1) on Table or on the divider the Table's Context Menu will be
                // display( if press on other row no focus will move to the new row)
                // * when pressing Rclick exactly edit the context menu of the edit will be display and the focus
                // will move to the control
                bool LeftClickWasPressed = ((MouseEventArgs)e).Button == MouseButtons.Left;
                bool findExact           = (sender is TableControl && LeftClickWasPressed ? false : true);
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), findExact, true);
                if (mapData != null)
                {
                    // Defect# 130085: When we click on a control (say checkbox) placed on table header, mouseDown is not needed to be processed.
                    // Actually, this is received from WM_PARENTNOTIFY from TableControl. This will avoid multiple ACT_CTRL_HIT on table header child
                    // control and Table control. Another option was to set WS_EX_NOPARENTNOTIFY style to table header child.
                    GuiMgControl mgControl = mapData.getControl();
                    if (mgControl.IsTableHeaderChild)
                    {
                        return;
                    }
                    // mark that we need to focus on the control
                    GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData);
                }
                else if (sender is TableControl)
                {
                    GuiUtils.restoreFocus(GuiUtils.FindForm(sender));
                }
                break;

            case EventType.MOUSE_UP:
                // for mouse up we need control the has been clicked and not nearest control
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true);
                break;

            case EventType.MOUSE_DBLCLICK:
                if (!(sender is TableControl)) //TODO
                {
                    mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true);
                }
                break;

            case EventType.PRESS:
                findExact = !(sender is TableControl);
                // Mobile clients for which this event type is applicable must
                // pass actual press co-ords
                Point point = new Point(0, 0);
                mapData = containerManager.HitTest(point, findExact, true);
                if (mapData != null)
                {
                    GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData);
                }
                break;

            case EventType.PAINT:
                if (containerManager is BasicControlsManager)
                {
                    ((BasicControlsManager)containerManager).Paint(((PaintEventArgs)e).Graphics);
                }
                break;

#if PocketPC
            case EventType.RESIZE:
                EditorSupportingPlacementLayout placementLayout1 = ((TagData)sender.Tag).PlacementLayout;
                if (placementLayout1 != null)
                {
                    LayoutEventArgs le = new LayoutEventArgs();
                    placementLayout1.layout(sender, le);
                }
                break;
#endif
            case EventType.LAYOUT:
                EditorSupportingPlacementLayout placementLayout = ((TagData)sender.Tag).PlacementLayout;
                if (placementLayout != null)
                {
                    placementLayout.layout(sender, (LayoutEventArgs)e);
                }
                break;

            case EventType.DISPOSED:
                containerManager.Dispose();
                break;
            }

            if (mapData == null)
            {
                mapData = orgMapData;
            }
            DefaultHandler.getInstance().handleEvent(type, sender, e, mapData);
        }
Esempio n. 17
0
        /* (non-Javadoc)
         * @see org.eclipse.swt.widgets.Handler#handleEvent(org.eclipse.swt.widgets.Event)
         */
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap controlsMap  = ControlsMap.getInstance();
            RichTextBox richTextCtrl = (RichTextBox)sender;
            MapData     mapData      = controlsMap.getMapData(richTextCtrl);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl ctrl      = mapData.getControl();
            GuiMgForm    guiMgForm = mapData.getForm();

            UtilImeJpn utilImeJpn = Manager.UtilImeJpn; // JPN: IME support

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(ctrl));

            try
            {
                switch (type)
                {
                case EventType.GOT_FOCUS:
                    // check the paste enable. check the clip content.
                    if (mapData != null)
                    {
                        GuiUtils.checkPasteEnable(mapData.getControl(), true);
                    }

                    // For RichEdit Ctrl, Set AcceptButton(i.e. DefaultButton) to null in order to allow enter key on RichEdit control.
                    if (sender is MgRichTextBox)
                    {
                        Form form = GuiUtils.FindForm(richTextCtrl);
                        form.AcceptButton = null;

                        if (((MgRichTextBox)sender).ReadOnly)
                        {
                            GuiUtils.restoreFocus(form);
                        }
                    }
                    break;

                case EventType.LOST_FOCUS:
                    // Always disable paste when exiting a text ctrl. (since we might be focusing on a diff type of
                    // ctrl).
                    if (mapData != null)
                    {
                        GuiUtils.disablePaste(mapData.getControl());
                    }
                    break;

                case EventType.KEY_UP:
                    // Korean
                    if (sender is MgRichTextBox && ((MgRichTextBox)sender).KoreanInterimSel >= 0)
                    {
                        return;
                    }

                    if (utilImeJpn != null)
                    {
                        if (utilImeJpn.IsEditingCompStr(richTextCtrl)) // JPN: IME support
                        {
                            return;
                        }

                        if (richTextCtrl is MgRichTextBox)           // JPN: ZIMERead function
                        {
                            utilImeJpn.StrImeRead = ((MgRichTextBox)richTextCtrl).GetCompositionString();
                        }
                    }

                    GuiUtils.enableDisableEvents(sender, mapData.getControl());
                    return;

                case EventType.KEY_DOWN:
                    // Korean
                    if (sender is MgRichTextBox && ((MgRichTextBox)sender).KoreanInterimSel >= 0)
                    {
                        return;
                    }

                    if (utilImeJpn != null && utilImeJpn.IsEditingCompStr(richTextCtrl)) // JPN: IME support
                    {
                        return;
                    }

                    KeyEventArgs keyEventArgs = (KeyEventArgs)e;
                    // marking the text (next/prev char or beg/end text) we let the
                    // system to take care of it.
                    // why ? There is no way in windows to set the caret at the beginning of
                    // a selected text. it works only on multi mark for some reason.
                    // also posting a shift+key does not work well since we have no way of knowing
                    // if the shift is already pressed or not.
                    // *** ALL other keys will continue to handleEvent.
                    if ((keyEventArgs.Shift && (keyEventArgs.KeyCode == Keys.Left || keyEventArgs.KeyCode == Keys.Right || keyEventArgs.KeyCode == Keys.Up || keyEventArgs.KeyCode == Keys.Down || keyEventArgs.KeyCode == Keys.Home || keyEventArgs.KeyCode == Keys.End)) ||
                        (keyEventArgs.Control && (keyEventArgs.KeyCode == Keys.Left || keyEventArgs.KeyCode == Keys.Right)))
                    {
                        keyEventArgs.Handled = false;
                        return;
                    }
                    break;

                case EventType.KEY_PRESS:

                    KeyPressEventArgs keyPressEventArgs = (KeyPressEventArgs)e;

                    bool IgnoreKeyPress = ((TagData)richTextCtrl.Tag).IgnoreKeyPress;
                    // should we ignore the key pressed ?
                    if (IgnoreKeyPress)
                    {
                        ((TagData)richTextCtrl.Tag).IgnoreKeyPress = false;

                        return;
                    }

                    // skipp control key
                    if (Char.IsControl(keyPressEventArgs.KeyChar))
                    {
                        return;
                    }

                    int start = richTextCtrl.SelectionStart;
                    int end   = richTextCtrl.SelectionStart + richTextCtrl.SelectionLength;

                    String pressedChar = "" + keyPressEventArgs.KeyChar;

                    // flag the isActChar to indicate this is MG_ACT_CHAR
                    Events.OnKeyDown(guiMgForm, ctrl, Modifiers.MODIFIER_NONE, 0, start, end, pressedChar, true, "-1", keyPressEventArgs.Handled);

                    // keyPressEventArgs.Handled wii stay 'false' in order to let the system put the correct char.
                    // What will happen is 2 things : 1. processKeyDown will add 'MG_ACT_CHAR'. 2. The system will write the char.
                    // In the past, the 'ACT_CHAR' was using sendKeys in order to write the char, but it makes problems in multilanguage systems.
                    // So, in TextMaskEditor for rich , ACT_CHAR will do nothing, just pass there in order to rais the 'control modify'.
                    //keyPressEventArgs.Handled = true;
                    break;

                case EventType.MOUSE_UP:
                    GuiUtils.enableDisableEvents(sender, mapData.getControl());
                    break;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e);
        }