private void HandleMouseEvent(InputEventMouse eventMouse) { var mousePos = eventMouse.Position; switch (eventMouse) { case InputEventMouseButton eventMouseButton: if (eventMouseButton.ButtonIndex == (int)ButtonList.Left) { if (!_drawingLine && eventMouseButton.Pressed) { if (_brushMode == PaintControls.BrushMode.Pencil || _brushMode == PaintControls.BrushMode.Eraser) { _painter.Add( new Painter.Line(color: _color, thickness: (int)_brushSize), mousePos); // Console.WriteLine($"New point {mousePos}"); } } else if (_drawingLine && !eventMouseButton.Pressed) { if (ShouldAcceptMousePos(mousePos)) { _painter.AddPoint(mousePos); } } _drawingLine = eventMouseButton.Pressed; } break; case InputEventMouseMotion eventMouseMotion: if (!ShouldAcceptMousePos(mousePos)) { break; } if (_drawingLine && mousePos.DistanceSquaredTo(_lastMousePos) >= 1f) { _painter.AddPoint(mousePos); } break; } _lastMousePos = mousePos; }