/// <summary>
        /// gets last value of the control that was previously in focus
        /// is working only for text controls
        /// used to restore control's edited value after current record is replaced by different chunk
        /// </summary>
        /// <returns></returns>
        private LastFocusedVal GetLastEditedFocusedVal()
        {
            Form           form           = GuiUtilsBase.FindForm(_tableControl);
            LastFocusedVal lastFocusedVal = null;
            MapData        mapData        = ((TagData)form.Tag).LastFocusedMapData;

            if (mapData != null && mapData.getControl() != null)
            {
                Object obj = controlsMap.object2Widget(mapData.getControl(), mapData.getIdx());
                var    lg  = obj as LogicalControl;
                if (lg != null && lg.ContainerManager == this)
                {
                    GuiMgControl mgControl = mapData.getControl();
                    if (mgControl.isTextControl())
                    {
                        lastFocusedVal = new LastFocusedVal(mgControl, mapData.getIdx(), lg.Text);
                    }
                }
            }
            return(lastFocusedVal);
        }
Beispiel #2
0
 /// <summary> </summary>
 internal override void handleEvent(EventType type, Object sender, EventArgs e)
 {
     if (type == EventType.DISPOSED)
     {
         ControlsMap   controlsMap   = ControlsMap.getInstance();
         ToolStripItem toolStripItem = (ToolStripItem)sender;
         MapData       mapData       = controlsMap.getMapData(sender);
         if (mapData != null)
         {
             GuiMgControl guiMgControl = mapData.getControl();
             toolStripItem.Tag = null;
             controlsMap.remove(guiMgControl, mapData.getIdx());
         }
     }
 }
Beispiel #3
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());
                }
            }
        }
Beispiel #4
0
        /// <summary>
        ///   get editor control of child
        /// </summary>
        /// <returns></returns>
        public override Control getEditorControl()
        {
            TreeEditor treeEditor = _treeManager.getTmpEditor();
            Control    control    = treeEditor.Control;

            if (control != null)
            {
                MapData mapData = ControlsMap.getInstance().getMapData(control);
                if (mapData != null && _mgRow == mapData.getIdx())
                {
                    // this child has temporary editor
                    return(control);
                }
            }
            return(null);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private bool OnkeyDown(Object sender, EventArgs e)
        {
            ControlsMap  controlsMap  = ControlsMap.getInstance();
            MgComboBox   comboBox     = (MgComboBox)sender;
            MapData      mapData      = controlsMap.getMapData(comboBox);
            bool         ignoreEvent  = false;
            bool         isDropped    = false;
            KeyEventArgs keyEventArgs = (KeyEventArgs)e;

            // Definition of the behavior (the same in on line)
            // ---------------------------------------------
            // When NOT Dropped :
            //                   page down or up : move to the next\prev record
            //                   up,down,left,right : move to the next\prev field
            //                   Home, End : select the first\end options in the popup (don't need to do nothing)
            // When Is Dropped :
            //                   page down or up : move to the next\prev page in the dropped
            //                   up,down,left,right : move to the next\prev option in the dropped
            //                   Home, End : select the first\end options in the popup(don't need to do nothing)

            TagData tg = ((TagData)comboBox.Tag);

            ((TagData)comboBox.Tag).HandleOnDropDownClosed = true;

            isDropped = comboBox.DroppedDown;

            //Fixed bug #:768284, unexpected behavior of .NET: when Dropped Down is open and press key (navigation\char)
            //                    and in the selection index change open message box\modal window,  we get selection index
            //                    change twice to the same control ignore the second time
            tg.IgnoreTwiceClick = false;
            if (isDropped)
            {
                tg.IgnoreTwiceClickWhenFromValueIs = GuiUtils.getValue(comboBox);
                tg.IgnoreTwiceClick = true;
            }

            switch (keyEventArgs.KeyCode)
            {
            case Keys.Left:
            case Keys.Right:
            case Keys.Down:
            case Keys.Up:
                //Check whether up/down arrow key is presses with ALT.
                if (eventForOpenClosePopup(keyEventArgs))
                {
                    //If combo is not dropped down, then open it, else will be closed.
                    if (!isDropped)
                    {
                        Events.OnComboDroppingDown(mapData.getControl(), mapData.getIdx());
                        keyEventArgs.Handled = true;
                    }
                }
                else
                {
                    keyEventArgs.Handled = true;
                }
                break;

            case Keys.PageUp:
            case Keys.PageDown:
            case Keys.Home:
            case Keys.End:
                keyEventArgs.Handled = true;
                break;

            case Keys.F4:
                // QCR #798995, f4 in windows opens combo and this is unwanted behaviour
                keyEventArgs.Handled = true;
                break;

            case Keys.Tab:
                //we need to handle the key.Tab so no need to update ignoreEvent
                if (comboBox.DroppedDown)
                {
                    CloseComboDropDownForSpecialKeys(comboBox, e);
                }
                break;

            case Keys.Escape:
                ignoreEvent = CloseComboDropDownForSpecialKeys(comboBox, e);
                break;

            case Keys.Enter:
                // in case of selection task, Enter on an open combo should only select. we don't want to exit the task.
                if (comboBox.DroppedDown)
                {
                    ((TagData)comboBox.Tag).IgnoreKeyDown          = true;
                    ((TagData)comboBox.Tag).HandleOnDropDownClosed = false;
                }
                break;

            default:
                // ctrl + key, focuses on the value starting with this char on .net. But in online it doesn't.
                // Also, ctrl+M, might change query to modify and them focus on 'm'. We don't want that.
                if (keyEventArgs.Control)
                {
                    DefaultHandler.suppressKeyPress(keyEventArgs, (Control)sender);
                }

                break;
            }

            return(ignoreEvent);
        }
Beispiel #7
0
        //<summary> get tree child from tree item</summary>
        //<param name="treeNode"></param>
        //<returns></returns>
        internal static TreeChild getTreeChild(TreeNode treeNode)
        {
            Debug.Assert(Misc.IsGuiThread());
            ControlsMap controlsMap = ControlsMap.getInstance();
            MapData     mapdata     = controlsMap.getMapData(treeNode);
            TreeChild   child       = (TreeChild)controlsMap.object2Widget(mapdata.getControl(), mapdata.getIdx());

            return(child);
        }
Beispiel #8
0
        internal bool isLastFocussedControl()
        {
            bool   isLastFocussedCtrl = false;
            Editor editor             = GuiUtils.GetTmpEditorFromTagData(GuiUtils.FindForm(_containerControl));

            if (editor != null && editor is Editor)
            {
                Control control = editor.Control;
                if (control != null && !GuiUtilsBase.isDisposed(control))
                {
                    MapData mapData = ControlsMap.getInstance().getMapData(control);
                    if (mapData != null && GuiMgControl == mapData.getControl() && _mgRow == mapData.getIdx())
                    {
                        isLastFocussedCtrl = true;
                    }
                }
            }

            return(isLastFocussedCtrl);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
        /// <summary>
        /// remove rows from table control
        /// </summary>
        /// <param name="rowStart">the index at which to begin remove</param>
        /// <param name="rowsToRemove">number of rows to remove</param>
        internal override void RemoveRows(int rowStart, int rowsToRemove, bool manipulateEditors)
        {
            int numOfRows = _tableControl.getItemsCount();

            if (rowStart < 0 || rowStart >= numOfRows && rowsToRemove <= 0)
            {
                return;
            }

            if (rowStart + rowsToRemove > numOfRows)
            {
                rowsToRemove = numOfRows - rowStart;
            }

            _mgCount -= rowsToRemove;

            for (int idx = rowStart; idx < rowStart + rowsToRemove; idx++)
            {
                _tableControl.RemoveItem(getGuiRowIndex(rowStart));
            }

            if (manipulateEditors)
            {
                // if allowTesting, do not perform remove, use shiftrows instead.
                if (GuiUtils.AccessTest)
                {
                    ShiftEditors(rowStart, -rowsToRemove);
                }
                else
                {
                    RemoveEditorsForVisibleColumns(rowStart, rowsToRemove);
                }
            }

            // update controlsMap
            for (int i = 0; i < _children.Count; i++)
            {
                if (!_children[i].IsTableHeaderChild)
                {
                    ArrayList arrayControl = controlsMap.object2WidgetArray(_children[i], GuiConstants.ALL_LINES);

                    // lg.Dispose() can remove entries from controlsMap and hence arrayControl can be null.
                    // In that case no need to continue even for other columns in same row.
                    if (arrayControl == null)
                    {
                        break;
                    }

                    for (int idx = 0; idx < rowsToRemove && rowStart < arrayControl.Count; idx++)
                    {
                        long           entriesBeforeDispose = arrayControl.Count;
                        LogicalControl lg = (LogicalControl)arrayControl[rowStart] ?? null;
                        if (lg != null)
                        {
                            // As we delete entries from arrayControl, we should adjust _mgRow in
                            // logical controls. _mgRow is used as index to remove Control from map
                            lg._mgRow = rowStart;
                            lg.Dispose();
                        }

                        // LogicalControl.Dispose removes entry from the map only all entries after current
                        // entry are null. If Dispose has not removed the entry, then remove it.
                        if (entriesBeforeDispose == arrayControl.Count)
                        {
                            arrayControl.RemoveAt(rowStart);
                        }
                    }

                    for (int j = rowStart; j < arrayControl.Count; j++)
                    {
                        LogicalControl lg = (LogicalControl)arrayControl[j] ?? null;
                        if (lg != null)
                        {
                            lg._mgRow = j;
                            ((TableCoordinator)lg.Coordinator).MgRow = j;

                            TableEditor editor = getTableEditor(lg);
                            // reapply properties on the editor
                            if (editor != null && editor.Control != null)
                            {
                                TagData tagData = (TagData)(((Control)editor.Control).Tag);
                                if (tagData.MapData is MapData)
                                {
                                    MapData mapData = (MapData)tagData.MapData;
                                    int     row     = mapData.getIdx();
                                    row = j;
                                    mapData.setIdx(row);
                                }
                            }
                        }
                    }
                }
            }

            // remove from _rowsToRefresh
            for (int idx = rowStart; idx < rowStart + rowsToRemove; idx++)
            {
                if (_rowsToRefresh.Contains(getGuiRowIndex(rowStart)))
                {
                    _rowsToRefresh.Remove(getGuiRowIndex(rowStart));
                }
            }
        }
Beispiel #12
0
        /// <summary> refresh temporary editor of static controls</summary>
        /// <param name="form"></param>
        internal static void refreshTmpEditor(Form form)
        {
            Editor editor = GuiUtils.GetTmpEditorFromTagData(form);

            if (editor != null && (!editor.isHidden()))
            {
                if (editor.Control != null)
                {
                    MapData mapData = ControlsMap.getInstance().getMapData(editor.Control);
                    Object  obj     = ControlsMap.getInstance().object2Widget(mapData.getControl(), mapData.getIdx());
                    //for now only refesh static text
                    LgText staticControl = obj as LgText;
                    if (staticControl != null && staticControl.RefreshNeeded)
                    {
                        ((LgText)staticControl).setProperties(editor.Control);
                    }
                }
            }
        }
Beispiel #13
0
 /// <summary>on click</summary>
 /// <param name="controlsMap"></param>
 /// <param name="ctrl"></param>
 /// <param name="mapData"></param>
 /// <param name="mgControl"></param>
 /// <param name="linkLabel"></param>
 private static void OnLinkClicked(MgLinkLabel linkLabel, ControlsMap controlsMap, MapData mapData, GuiMgControl mgControl, bool produceClick)
 {
     Events.OnSelection(GuiUtils.getValue(linkLabel), mgControl, mapData.getIdx(), produceClick);
 }
Beispiel #14
0
        /// <summary> </summary>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            TableControl table        = (TableControl)sender;
            TableManager tableManager = GuiUtils.getTableManager(table);

            if (tableManager == null)
            {
                return;
            }

            switch (type)
            {
            case EventType.PAINT_ITEM:
                tableManager.PaintRow((TablePaintRowArgs)e);
                return;

            case EventType.ERASE_ITEM:
                return;

            case EventType.SCROLL:
                if (((ScrollEventArgs)e).ScrollOrientation == ScrollOrientation.VerticalScroll)
                {
                    tableManager.ScrollVertically((ScrollEventArgs)e);
                }
                return;

#if PocketPC
            case EventType.RESIZE:
                tableManager.resize();
                tableManager.PerformLayout(sender, e);
                break;
#endif

            case EventType.LAYOUT:
                if (((LayoutEventArgs)e).AffectedControl == sender)
                {
#if !PocketPC
                    //Defer the resizing of table until the form is in resize mode.
                    //Resize doesn't mean resizing the table itself but it actually
                    //means post-resize stuff like creating new rows, fetching data, etc.
                    Form parent = GuiUtils.FindForm(table);

                    // Parent can be null, when we just created a control and before attaching parent, we reset its size.
                    if (parent != null)
                    {
                        TagData tagData = (TagData)parent.Tag;
                        if (!tagData.IgnoreWindowResizeAndMove)
                        {
                            tableManager.resize();
                        }
                    }
#else
                    tableManager.resize();
#endif
                }
                return;

            case EventType.MOUSE_DOWN:
                bool leftClickWasPressed = ((MouseEventArgs)e).Button == MouseButtons.Left;

#if !PocketPC
                if (leftClickWasPressed)
                {
                    MapData mapData = tableManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), false, true);
                    if (mapData != null)
                    {
                        int       row       = mapData.getIdx();
                        Modifiers modifiers = GuiUtils.getModifier(Control.ModifierKeys);
                        // Defect 124555. Copy from Gui_Table.cpp LButtonDown_On_Table: for click on a table with AllowDrag
                        // with rows selected and the click on the selected row do not put MUTI_MARK_HIT action.
                        if (row >= 0 && !(((TagData)table.Tag).AllowDrag && tableManager.IsInMultimark && tableManager.IsItemMarked(row)))
                        {
                            Events.OnMultiMarkHit(ControlsMap.getInstance().getMapData(sender).getControl(), row + 1, modifiers);
                        }
                    }
                }
#endif
                break;

            case EventType.REORDER_STARTED:
                TableReorderArgs ea = (TableReorderArgs)e;
                tableManager.reorder(ea.column, ea.NewColumn);
                break;

            case EventType.REORDER_ENDED:
                tableManager.refreshPage();
                break;

            case EventType.DISPOSE_ITEM:
                tableManager.cleanItem(((TableItemDisposeArgs)e).Item);
                return;

            case EventType.HORIZONTAL_SCROLL_VISIBILITY_CHANGED:
                tableManager.resize();
                return;
            }
            DefaultContainerHandler.getInstance().handleEvent(type, sender, e);
        }
Beispiel #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);
        }
Beispiel #16
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();
            TreeView    tree        = (TreeView)sender;
            TreeManager treeManager = GuiUtils.getTreeManager(tree);
            Point       location    = new Point();
            MapData     mapData     = null;
            Point       pt;

            if (e is MouseEventArgs)
            {
                location = ((MouseEventArgs)e).Location;
            }
            if (tree.IsDisposed)
            {
                return;
            }

            switch (type)
            {
            case EventType.GOT_FOCUS:
                treeManager.setFocusTime();
                break;

            case EventType.NODE_MOUSE_HOVER:
                mapData = controlsMap.getMapData(((TreeNodeMouseHoverEventArgs)e).Node);
                break;

            case EventType.MOUSE_LEAVE:
                //workaround for .NET problem mouseleave is sent too much times for every tree node
                //we must check if the tooltip left tree
                pt = tree.PointToClient(Control.MousePosition);
                if (tree.ClientRectangle.Contains(pt))
                {
                    return;
                }
                break;

            case EventType.MOUSE_UP:
                tree.MouseMove      += TreeHandler.getInstance().MouseMoveHandler;
                treeManager.InExpand = false;
                break;

            case EventType.MOUSE_DOWN:
                treeManager.setMouseDownTime();
                break;

            case EventType.MOUSE_MOVE:
                // Mouse move only to decide, whether we should start drag operation or not.
                // Should not handle MouseMove further : Need to handle NodeMouseHover is instead of mousemove

                Control control = (Control)sender;
                if (!treeManager.InExpand && GuiUtils.ShouldPerformBeginDrag(control, (MouseEventArgs)e))
                {
                    mapData = GuiUtils.getContainerManager(control).HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, false);
                    // mapData == null means we are on the node's sign.
                    if (mapData != null)
                    {
                        //Before starting to drag, if we are dragging from a different node
                        //the selected node, move the selected node before starting to drag.
                        // (* it will actually do something only for RTE not RC).
                        if (tree.SelectedNode != null)
                        {
                            MapData oldNodmapDataDrag = controlsMap.getMapData(tree.SelectedNode);
                            int     oldLineDrag       = oldNodmapDataDrag.getIdx();

                            if (mapData.getIdx() != oldLineDrag)
                            {
                                Events.OnTreeNodeSelectChange(mapData.getControl(), oldLineDrag, mapData.getIdx());
                            }
                        }

                        GuiUtils.BeginDrag(control, (MouseEventArgs)e, mapData);
                    }
                }
                return;

            case EventType.DRAG_DROP:
                control = (Control)sender;
                pt      = new Point(((DragEventArgs)e).X, ((DragEventArgs)e).Y);
                Point screen = control.PointToClient(pt);
                mapData = GuiUtils.getContainerManager(control).HitTest(screen, true, false);

                // mapData == null means we are on the node's sign.
                if (mapData != null)
                {
                    //Before starting to drop, if we are dropping on a different node
                    //the selected node, move the selected node before starting to drop.
                    // (* it will actually do something only for RTE not RC).
                    if (tree.SelectedNode != null)
                    {
                        MapData oldNodmapDataDrop = controlsMap.getMapData(tree.SelectedNode);
                        int     oldLineDrop       = oldNodmapDataDrop.getIdx();

                        if (mapData.getIdx() != oldLineDrop)
                        {
                            Events.OnTreeNodeSelectChange(mapData.getControl(), oldLineDrop, mapData.getIdx());
                        }
                    }
                }
                break;

            case EventType.LABEL_EDIT:
                if (!treeManager.IsLabelEditAllowed)
                {
                    ((NodeLabelEditEventArgs)e).CancelEdit = true;
                }
                else
                {
                    mapData = controlsMap.getMapData(((NodeLabelEditEventArgs)e).Node);
                    Events.OnEditNode(mapData.getControl(), mapData.getIdx());
                }
                return;

            case EventType.KEY_DOWN:
                KeyEventArgs keyEventArgs = (KeyEventArgs)e;
                // check if we should handle the key down (in default handler) or let the
                // tree continue with its default behavior.
                if (!Events.ShouldHandleTreeKeyDown(keyEventArgs.KeyCode))
                {
                    return; // let tree send default expand collapse event
                }
                break;

            case EventType.RESIZE:
                treeManager.resize();
                return;

            case EventType.SCROLL:
            case EventType.MOUSE_WHEEL:
                GuiUtils.checkAndCloseTreeEditorOnClick(tree);
                return;

            case EventType.BEFOR_EXPAND:
                treeManager.InExpand = true;

                mapData = controlsMap.getMapData(((TreeViewCancelEventArgs)e).Node);
                TreeChild treeChild = (TreeChild)controlsMap.object2Widget(mapData.getControl(), mapData.getIdx());

                Events.OnExpand(mapData.getControl(), mapData.getIdx());
                ((TreeViewCancelEventArgs)e).Cancel = true;
                return;

            case EventType.BEFOR_COLLAPSE:
                mapData = controlsMap.getMapData(((TreeViewCancelEventArgs)e).Node);
                Events.OnCollapse(mapData.getControl(), mapData.getIdx());
                ((TreeViewCancelEventArgs)e).Cancel = true;
                return;

            case EventType.BEFORE_SELECT:
                MapData oldNodmapData = null;
                int     oldLine       = 0;

                mapData = controlsMap.getMapData(((TreeViewCancelEventArgs)e).Node);
                if (mapData != null)
                {
                    GuiMgControl mgControl = mapData.getControl();
                    int          newLine   = mapData.getIdx();

                    if (tree.SelectedNode != null)
                    {
                        oldNodmapData = controlsMap.getMapData(tree.SelectedNode);
                        oldLine       = oldNodmapData.getIdx();
                    }

                    // if true, cancel the change (true for online, false for RC)
                    // in online there is handling for the select change and we don't want it to
                    // happen here.
                    if (Events.OnTreeNodeSelectChange(mgControl, oldLine, newLine))
                    {
                        ((TreeViewCancelEventArgs)e).Cancel = true;
                    }
                }
                else
                {
                    ((TreeViewCancelEventArgs)e).Cancel = true;
                }

                return;
            }
            DefaultContainerHandler.getInstance().handleEvent(type, (Control)sender, e, mapData);
        }
        /// <summary>
        /// insert rows into table control
        /// </summary>
        /// <param name="rowStart">the index at which to begin insert</param>
        /// <param name="rowsToInsert">number of rows to be inserted</param>
        internal override void InsertRows(int rowStart, int rowsToInsert, bool manipulateEditors)
        {
            if (rowStart < 0 || rowsToInsert <= 0)
            {
                return;
            }

            _mgCount += rowsToInsert;

            for (int idx = rowStart; idx < rowStart + rowsToInsert; idx++)
            {
                _tableControl.InsertItem(getGuiRowIndex(rowStart));
            }

            if (manipulateEditors)
            {
                // if allowTesting, do not perform insert, use shiftrows instead.
                if (GuiUtils.AccessTest)
                {
                    ShiftEditors(rowStart, rowsToInsert);
                }
                else
                {
                    InsertEditorsForVisibleColumns(rowStart, rowsToInsert);
                }
            }

            // move rows after rowStart in controlsMap
            for (int i = 0; i < _children.Count; i++)
            {
                if (!_children[i].IsTableHeaderChild)
                {
                    ArrayList arrayControl = controlsMap.object2WidgetArray(_children[i], GuiConstants.ALL_LINES);

                    if (arrayControl == null)
                    {
                        break;
                    }

                    if (rowStart <= arrayControl.Count)
                    {
                        for (int idx = rowStart; idx < rowStart + rowsToInsert; idx++)
                        {
                            arrayControl.Insert(rowStart, null);
                        }
                    }

                    for (int j = rowStart + rowsToInsert; j < arrayControl.Count; j++)
                    {
                        LogicalControl lg = (LogicalControl)arrayControl[j] ?? null;
                        if (lg != null)
                        {
                            lg._mgRow = j;
                            ((TableCoordinator)lg.Coordinator).MgRow = j;

                            TableEditor editor = getTableEditor(lg);
                            // reapply properties on the editor
                            if (editor != null && editor.Control != null)
                            {
                                TagData tagData = (TagData)(((Control)editor.Control).Tag);
                                if (tagData.MapData is MapData)
                                {
                                    MapData mapData = (MapData)tagData.MapData;
                                    int     row     = mapData.getIdx();
                                    row = j;
                                    mapData.setIdx(row);
                                }
                            }
                        }
                    }
                }
            }
        }