private void StartResizing(SelectionArea area, SelectionArea.ResizeSide side)
        {
            _currentEditMode = EditMode.RESIZING;

            _activeResizeArea                  = area;
            _activeResizeAreaSide              = side;
            _activeResizeAreaXbeforeStart      = area.OffsetX;
            _activeResizeAreaYbeforeStart      = area.OffsetY;
            _activeResizeAreaWidthbeforeStart  = area.AreaWidth;
            _activeResizeAreaHeightbeforeStart = area.AreaHeight;

            switch (side)
            {
            case SelectionArea.ResizeSide.LEFT:
                drawCanvas.Cursor = Cursors.SizeWE;
                break;

            case SelectionArea.ResizeSide.TOP:
                drawCanvas.Cursor = Cursors.SizeNS;
                break;

            case SelectionArea.ResizeSide.RIGHT:
                drawCanvas.Cursor = Cursors.SizeWE;
                break;

            case SelectionArea.ResizeSide.BOTTOM:
                drawCanvas.Cursor = Cursors.SizeNS;
                break;
            }
        }
 public void StartRotating(SelectionArea area)
 {
     _currentEditMode  = EditMode.ROTATING;
     _activeRotateArea = area;
     _activeRotateAreaRotationBeforeStart    = area.Rotation;
     _activeRotateAreaCenterPointBeforeStart = area.CalculateCenterPoint();
 }
        private void drawCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            _isMouseDown    = true;
            _mouseDownPoint = e.GetPosition(drawCanvas);

            if (_currentEditMode == EditMode.INSERTING)
            {
                SelectionArea area = new SelectionArea(drawCanvas, _mouseDownPoint.X, _mouseDownPoint.Y);
                area.AddToCanvas(drawCanvas);
                _areas.Add(area);

                _activeInsertArea = area;

                AttachMouseEvents(area);
            }
        }
        private void AttachMouseEvents(SelectionArea area)
        {
            area.ResizeLeftRect.MouseDown += (object sender, MouseButtonEventArgs e) => {
                StartResizing(area, SelectionArea.ResizeSide.LEFT);
            };
            area.ResizeTopRect.MouseDown += (object sender, MouseButtonEventArgs e) => {
                StartResizing(area, SelectionArea.ResizeSide.TOP);
            };
            area.ResizeRightRect.MouseDown += (object sender, MouseButtonEventArgs e) => {
                StartResizing(area, SelectionArea.ResizeSide.RIGHT);
            };
            area.ResizeBottomRect.MouseDown += (object sender, MouseButtonEventArgs e) => {
                StartResizing(area, SelectionArea.ResizeSide.BOTTOM);
            };

            area.RotatorEllipse.MouseDown += (object sender, MouseButtonEventArgs e) => {
                StartRotating(area);
            };
        }
        private void drawCanvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            _isMouseDown      = false;
            drawCanvas.Cursor = Cursors.Pen;

            if (_currentEditMode == EditMode.INSERTING)
            {
                _activeInsertArea = null;
            }
            else if (_currentEditMode == EditMode.RESIZING)
            {
                _activeResizeArea     = null;
                _activeResizeAreaSide = SelectionArea.ResizeSide.NONE;
                _currentEditMode      = EditMode.INSERTING;
            }
            else if (_currentEditMode == EditMode.ROTATING)
            {
                _activeRotateArea = null;
                _currentEditMode  = EditMode.INSERTING;
            }
        }