private void TargetImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var position = e.GetPosition(TargetImage); _drawStartPoint.X = (int)Math.Ceiling(position.X); _drawStartPoint.Y = (int)Math.Ceiling(position.Y); if (_drawStartPoint.X > 0) { _drawStartPoint.X--; } if (_drawStartPoint.Y > 0) { _drawStartPoint.Y--; } if (_drawingTool == DrawingTool.TextTool) { InsertTextToImage(); return; } if (_drawingTool == DrawingTool.PickerTool) { DrawingInfo.CurrentColor = System.Windows.Media.Color.FromArgb(255, _pickedColor.R, _pickedColor.G, _pickedColor.B); DrawingInfo.LeftSliderValue = _pickedColor.A; return; } _mouseCaptured = TargetImage.CaptureMouse(); if (_drawingTool == DrawingTool.PenTool || _drawingTool == DrawingTool.EraserTool) { _linePoints.Clear(); _linePoints.Add(new Point(_drawStartPoint.X, _drawStartPoint.Y)); TargetImage_MouseMove(sender, e);//画点 } }
private void TargetImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } var position = e.GetPosition(TargetImage); var x = (int)position.X; var y = (int)position.Y; _startPoint.X = x; _startPoint.Y = y; CropRect.Width = 0; CropRect.Height = 0; TopValueLbl.Content = 0; LeftValueLbl.Content = 0; WidthValueLbl.Content = 0; HeightValueLbl.Content = 0; TargetImage.CaptureMouse(); _isMousePressed = true; }