Пример #1
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);
        }
Пример #2
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)
        {
            MapData mapData = ControlsMap.getInstance().getMapData(sender);

            if (mapData == null)
            {
                return;
            }

            Object guiMgObject = mapData.getControl();

            if (guiMgObject == null)
            {
                guiMgObject = mapData.getForm();
            }
            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgObject));

            try
            {
                switch (type)
                {
#if !PocketPC
                case EventType.SCROLL:
                {
                    if (sender is ScrollableControl)
                    {
                        ScrollableControl scrollableControl = sender as ScrollableControl;
                        TagData           tg = (TagData)scrollableControl.Tag;
                        if (scrollableControl.BackgroundImage != null)
                        {
                            scrollableControl.Invalidate();
                        }
                        else
                        {
                            //This is a.Net bug. When scrollbar gets hidden during the process of thumb drag, framework still keeps
                            //a rectangular bar visible to keep dragging on. Now, this rectangle is not removed even when the scrolling is stopped.
                            //The workaround is to repaint the form if scrollbar is not present on the form when scroll dragging is stopped.

                            ScrollEventArgs se = (ScrollEventArgs)e;
                            if (se.Type == ScrollEventType.ThumbPosition)
                            {
                                bool hasVerticalScrollBar = scrollableControl.AutoScrollMinSize.Height > scrollableControl.ClientSize.Height;

                                if (!hasVerticalScrollBar)
                                {
                                    scrollableControl.Invalidate();
                                }
                            }
                        }
                    }
                }
                break;
#endif
                case EventType.RESIZE:
                    onResize((Control)sender);
                    break;
                }
                DefaultContainerHandler.getInstance().handleEvent(type, sender, e);

#if PocketPC
                // paint the subform's border. Do it after the controls are painted, so we can paint over them.
                if (type == EventType.PAINT && ((MgPanel)sender).BorderStyle != BorderStyle.None)
                {
                    BorderRenderer.PaintBorder(((PaintEventArgs)e).Graphics, ((Control)sender).ClientRectangle,
                                               Color.Black, ControlStyle.Windows, false);
                }
#endif
            }
            finally
            {
                contextIDGuard.Dispose();
            }
        }
Пример #3
0
        /// <summary> </summary>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            TableColumn column        = (TableColumn)sender;
            TagData     td            = (TagData)column.Tag;
            LgColumn    columnManager = td.ColumnManager;
            int         direction     = -1;
            String      columnHeaderString;

            if (columnManager == null)
            {
                return;
            }

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(columnManager.GuiMgControl));

            try
            {
                switch (type)
                {
                case EventType.AFTER_COLUMN_TRACK:
                    columnManager.updateWidth();
                    break;

                case EventType.COLUMN_CLICK:
                    direction = columnManager.getSortDirection();

                    //As event is raise by click action, then the argument for the event will be
                    //column title if its not null else it will be in form of Column:XXX
                    //XXX - column number
                    columnHeaderString = (!String.IsNullOrEmpty(column.Text)
                                          ? column.Text
                                          : "Column: " + (columnManager.MgColumnIdx + 1));

                    Events.OnColumnClick(columnManager.GuiMgControl, direction, columnHeaderString);
                    break;

                case EventType.COLUMN_FILTER_CLICK:
                    columnHeaderString = (!String.IsNullOrEmpty(column.Text)
                        ? column.Text
                        : "Column: " + (columnManager.MgColumnIdx + 1));
                    int index = column.Index;

                    //Calculate column top left point
                    Header columnHeader = ((HeaderSectionEventArgs)e).Item.Header;
                    Panel  panel        = GuiUtils.getParentPanel(columnHeader.Parent);
                    Point  panelStart   = panel.PointToScreen(new Point());
                    panelStart.Offset(panel.AutoScrollPosition);
                    Point columnStart = columnHeader.PointToScreen(new Point(columnHeader.GetHeaderSectionStartPos(((HeaderSectionEventArgs)e).Item.Index), 0));

                    int x      = columnStart.X - panelStart.X;
                    int y      = columnStart.Y - panelStart.Y;
                    int width  = ((HeaderSectionEventArgs)e).Item.Width;
                    int height = ((HeaderSectionEventArgs)e).Item.Header.Height;

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

            Manager.ContextIDGuard contextIDGuard = null;

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

                        controlsMap = ControlsMap.getInstance();

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

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

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

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

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

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

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

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

                            GuiUtils.setTooltip(control, "");
                        }

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

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

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

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

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

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

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

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

                    return;


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

                    break;

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

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

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

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

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

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

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

                    mapData = controlsMap.getMapData(sender);

                    if (mapData == null)
                    {
                        break;
                    }

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

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

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

                            guiMenuEntry.removeMenuIsInstantiated(guiMgForm, menuStyle);

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

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

                            menu.Tag = null;
                        }
                    }

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

                    break;

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

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

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

                default:
                    System.Console.Out.WriteLine(type.ToString());
                    break;
                }
            }
            finally
            {
                if (contextIDGuard != null)
                {
                    contextIDGuard.Dispose();
                }
            }
        }
Пример #9
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);
        }