Пример #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            var mouse = MouseZoom(e.Location);

            if (draggedShape != null)
            {
                DragShape(e);
                if (!dragStarted && shapeInitialLocation != draggedShape.Location)
                {
                    foreach (var conn in Connector.GetConnections(draggedShape.Task))
                    {
                        conn.UnRoute();
                    }
                    dragStarted = true;
                    Invalidate();
                }
            }
            else if (rubberBand != null)
            {
                rubberBand.MouseMove(mouse);
            }
            else if (draggedSegment != null)
            {
                if (!dragStarted)
                {
                    if (draggedSegment.PrepareDrag(segmentGrabPoint))
                    {
                        dragStarted = true;
                    }
                    else
                    {
                        draggedSegment = null;
                        return;
                    }
                }
                Invalidate(draggedSegment.DragTo(mouse));
            }
            else if (panning)
            {
                Cursor = Cursors.SizeAll;    // TODO: Get the correct Grabby Hand cursor

                // If the diagram has shrunk then permit scrolling to the new extended limits
                // (minLeft, minTop are the normal scroll limits for a diagram that has not just been shrunk)
                var llimit = Math.Min(Left, minLeft);
                var tlimit = Math.Min(Top, minTop);
                // Scroll the diagram
                var left = Math.Min(0, Math.Max(llimit, Left + e.X - panClick.X));
                var top  = Math.Min(0, Math.Max(tlimit, Top + e.Y - panClick.Y));
                Location = new Point(left, top);
            }
            else if (selectionFrame != null)
            {
                selectionFrame.UpdateFrame(PointToScreen(e.Location));
            }
            else
            {
                var obj = view.HitTest(mouse);
                if (!ReadOnly && obj != null)
                {
                    Cursor.Current = obj.GetCursor;
                }
            }
        }