private void canvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (cbxShapes.SelectedIndex == -1) { return; } Point p = e.GetPosition(canvas); DrawableObject obj = (DrawableObject)(cbxShapes.SelectedItem as DrawableObject).Clone(); obj.StartPoint = new Point2D(p.X, p.Y); obj.EndPoint = new Point2D(p.X, p.Y); _drawingObject = obj; _suitableDrawing = GetSuitableDrawing(obj); if (_suitableDrawing != null) { _suitableDrawing.Draw(canvas, obj); _isDrawing = true; } }
private void canvas_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { _drawingObject = null; _suitableDrawing = null; _isDrawing = false; }