Esempio n. 1
0
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap controlsMap     = ControlsMap.getInstance();
            MgPanel     tabControlPanel = (MgPanel)sender;

            TabControl tabControl = ((TagData)(tabControlPanel.Tag)).ContainerTabControl;

            MapData mapData = controlsMap.getMapData(tabControl);

            switch (type)
            {
            case EventType.PAINT:
                ControlRenderer.FillRectAccordingToGradientStyle(((PaintEventArgs)e).Graphics, tabControlPanel.ClientRectangle, tabControlPanel.BackColor,
                                                                 tabControlPanel.ForeColor, ControlStyle.NoBorder, false, tabControlPanel.GradientColor,
                                                                 tabControlPanel.GradientStyle);
                break;
            }

            DefaultContainerHandler.getInstance().handleEvent(type, (Control)sender, e, mapData);

            if (type == EventType.DISPOSED)
            {
                tabControl.Tag = null;
            }
        }
Esempio n. 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;
            }

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