Ejemplo n.º 1
0
        private void MouseMove_Select(Point eLocation)
        {
            #region Mouse
            if (DrawObj.Exists(shape => shape.Select(eLocation)))
            {
                pnlPaint.Cursor = Cursors.SizeAll;
            }
            else
            {
                pnlPaint.Cursor = Cursors.Cross;
            }
            #endregion

            //Nếu đang vẽ 1 region để chọn hình, thì thay đổi kích thước của region đó
            if (SelectedShape != null)
            {
                if (IsZooming)
                {
                    SelectedShape.Zoom(FirstPoint, eLocation);
                }
                else
                {
                    SelectedShape.Move(FirstPoint, eLocation);
                }
                FirstPoint = eLocation;     //Cập nhật lại FirstPoint
            }
            else
            {
                //Vẽ 1 rectangle trống
                int minX = Math.Min(FirstPoint.X, eLocation.X);
                int minY = Math.Min(FirstPoint.Y, eLocation.Y);
                int dx   = Math.Abs(eLocation.X - FirstPoint.X);
                int dy   = Math.Abs(eLocation.Y - FirstPoint.Y);
                SelectedRegion.Location = new Point(minX, minY);
                SelectedRegion.Width    = dx;
                SelectedRegion.Height   = dy;
            }
            RePaint();
        }