Esempio n. 1
0
        protected internal override void OnMouseMove(object sender, MouseEventArgs e)
        {
            base.OnMouseMove(sender, e);

            _delta = Math.Sqrt((_position1.X - e.X) * (_position1.X - e.X) + (_position1.Y - e.Y) * (_position1.Y - e.Y));

            if (_delta >= 10 && InUse)
            {
                _position2 = new PointF(e.X / canvas.ZoomFactor, e.Y / canvas.ZoomFactor);

                if (base.canvas.SnapToGrid)
                {
                    var cellsize = (int)(canvas.GridCellSize / canvas.ZoomFactor);
                    int newX     = (int)Math.Round((double)(_position2.X / cellsize)) * cellsize;
                    int newY     = (int)Math.Round((double)(_position2.Y / cellsize)) * cellsize;

                    _position2 = new PointF(newX, newY);
                }

                Boundary bounds = new Boundary(_position1, _position2);
                _shape = Shapes.Clone <T>(bounds);

                canvas.Invalidate();
            }
        }