// start selection/resizing/moving protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (IsSelectionAreaPresent()) // we have selected area { if (!selectionArea.Contains(e.Location)) { // we are outside of selected => erase current selection selectionArea = new Rectangle(0, 0, 0, 0); Invalidate(); croppingState = CroppingState.NONE; return; } else // we are within the selection area { DragCorner dc = PointAtDragCorner(selectionArea, e.Location); if (dc != DragCorner.NONE) { // we are at a corner of selection => we start resizing croppingState = CroppingState.RESIZING; // it is a special drag, where the corners are pulled for resizing dragPreviousPoint = e.Location; // initial previous drag location } else { // we are inside selection => we start dragging croppingState = CroppingState.DRAGGING; dragPreviousPoint = e.Location; // initial previous drag location } } } else // we just start selecting { croppingState = CroppingState.SELECTING; selectionStartPoint = e.Location; // initial selection area location } }
private void clearSelectionArea() { selectionArea = new Rectangle(0, 0, 0, 0); Invalidate(); croppingState = CroppingState.NONE; }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); croppingState = CroppingState.NONE; }