public override void HandleMouseMove(MouseEventArgs e) { base.HandleMouseMove(e); if (prePoint == default) { return; } var targetPoints = new List <Point>(points); var currentPoint = e.GetPosition(Canvas); currentPoint = AlignPointToXY(currentPoint); targetPoints.Add(currentPoint); if (element == null) { element = new DrawingLineString(targetPoints, targetPoints.First() == targetPoints.Last()); Canvas.AddVisual(element); } else { (element as DrawingLineString).Update(targetPoints, targetPoints.First() == targetPoints.Last()); } element.Render(DrawingCanvas.DefaultPen); }
public override void HandleMouseDown(MouseButtonEventArgs e) { base.HandleMouseDown(e); if (e.ChangedButton != MouseButton.Left) { return; } var point = e.GetPosition(Canvas); if (prePoint == default || (prePoint != default && point != prePoint)) { var drawingPoint = new DrawingPoint(point); drawingPoint.Render(DrawingCanvas.DefaultPen); Canvas.AddVisual(drawingPoint); } prePoint = point; }