Ejemplo n.º 1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                this.Cursor = Cursors.Arrow;
                Point mousePoint = Gsc2Goc(new Point(e.X, e.Y));

                if ((resizeAction != null) &&
                    ((document.Action == DesignerAction.Select) ||
                     ((document.Action == DesignerAction.Connect) &&
                      (resizeAction.IsResizingLink))))
                {
                    this.Cursor = resizeAction.UpdateResizeCornerCursor(mousePoint);
                }

                if (document.Action == DesignerAction.Connect)
                {
                    BaseElement mousePointerElementTMP = document.FindElement(mousePoint);
                    if (mousePointerElement != mousePointerElementTMP)
                    {
                        if (mousePointerElementTMP is ConnectorElement)
                        {
                            mousePointerElement = mousePointerElementTMP;
                            mousePointerElement.Invalidate();
                            this.Invalidate(mousePointerElement, true);
                        }
                        else if (mousePointerElement != null)
                        {
                            mousePointerElement.Invalidate();
                            this.Invalidate(mousePointerElement, true);
                            mousePointerElement = null;
                        }
                    }
                }
                else
                {
                    this.Invalidate(mousePointerElement, true);
                    mousePointerElement = null;
                }
            }

            if (e.Button == MouseButtons.Left)
            {
                Point dragPoint = Gsc2Goc(new Point(e.X, e.Y));

                if ((resizeAction != null) && (resizeAction.IsResizing))
                {
                    resizeAction.Resize(AlignToGrid(dragPoint));
                    this.Invalidate();
                }

                if ((moveAction != null) && (moveAction.IsMoving))
                {
                    moveAction.Move(AlignToGrid(dragPoint));
                    this.Invalidate();
                }

                if ((isMultiSelection) || (isAddSelection))
                {
                    Point p = Gsc2Goc(new Point(e.X, e.Y));
                    p = AlignToGrid(p);
                    selectionArea.Size = new Size(p.X - selectionArea.Location.X, p.Y - selectionArea.Location.Y);
                    selectionArea.Invalidate();
                    this.Invalidate(selectionArea, true);
                }

                if (isAddLink)
                {
                    selectedElement = document.FindElement(dragPoint);
                    if (CanAddLink(connStart, selectedElement))
                    {
                        linkLine.Connector2 = (ConnectorElement)selectedElement;
                    }
                    else
                    {
                        linkLine.Connector2 = connEnd;
                    }

                    IMoveController ctrl = (IMoveController)((IControllable)connEnd).GetController();
                    ctrl.Move(dragPoint);

                    //this.Invalidate(linkLine, true); //TODO
                    base.Invalidate();
                }
            }

            base.OnMouseMove(e);
        }