示例#1
0
        public override void Execute()
        {
            IMoveable m = Target as IMoveable;

            if (m != null)
            {
                var vector = new SharpDX.Vector2(m.Location.X - X, m.Location.Y - Y);
                var length = vector.Length();
                vector.Normalize();
                float dx, dy;
                dx = vector.X;
                dy = vector.Y;
                Task moveTask = new Task(() =>
                {
                    var i = 0.0f;
                    while (length >= i)
                    {
                        m.Offset(-dx, -dy);
                        Thread.Sleep(1);
                        i += 1;
                    }
                });
                moveTask.Start();
            }
        }
示例#2
0
        public override void MouseMoveAction(System.Windows.Forms.MouseEventArgs e)
        {
            var mouseLocation = new SharpDX.Point(e.Location.X, e.Location.Y);

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                var dx = mouseLocation.X - this.StartDragPoint.X;
                var dy = mouseLocation.Y - this.StartDragPoint.Y;
                if (isRect)
                {
                    selectionRect.Width  += dx;
                    selectionRect.Height += dy;
                }
                IMoveable q = draggedFigure as IMoveable;
                if (q != null)
                {
                    q.Offset(dx, dy);
                }
                UpdateMarkers();
            }
            else
            {
                var figure = FindFigureByPoint(mouseLocation);
                if (figure is Marker)
                {
                    this.ActiveCursor = System.Windows.Forms.Cursors.SizeAll;
                }
                else
                if (figure != null)
                {
                    this.ActiveCursor = System.Windows.Forms.Cursors.Hand;
                }
                else
                {
                    this.ActiveCursor = System.Windows.Forms.Cursors.Cross;
                }
                this.StartDragPoint = mouseLocation;
            }
        }