private void pbMain_MouseDown(object sender, MouseEventArgs e) { if (e.Clicks != 1) { return; } switch (_drawMode) { case DrawMode.Undefined: case DrawMode.DragAndDrop: { if (_currentShapeFactory != null) { _lastShape = _currentShapeFactory.GetShape(_currentPen, _currentBrush); _lastShape.SetPostition(e.Location); _drawMode = _lastShape.DrawMode(); _history.Add(_lastShape); UpdateUndoRedo(); pbMain.Invalidate(); } break; } case DrawMode.ByPoint: { if (_lastShape != null) { _lastShape.AddPoint(e.Location); _drawMode = _lastShape.DrawMode(); pbMain.Invalidate(); } break; } } }