private void DrawingCanvas_MouseDown(object sender, MouseButtonEventArgs e) { if (e.RightButton == MouseButtonState.Pressed) { _currentPolyLine.Points.Add(_currentPolyLine.Points[0]); _currentPolyLine = new Polyline(); _currentPolyLine.StrokeThickness = 1; _currentPolyLine.Stroke = new SolidColorBrush(Colors.Black); DrawingCanvas.Children.Add(_currentPolyLine); _polyLines.Add(_currentPolyLine); } else { var point = Mouse.GetPosition(DrawingCanvas); var pointRounded = new System.Windows.Point(Math.Round(point.X), Math.Round(point.Y)); _currentPolyLine.Points.Add(pointRounded); } }