private void DoImageMove(object sender, System.Windows.Input.MouseEventArgs e) { ContentControl image = sender as ContentControl; if (image == null) { return; } TransformGroup group = ImageGird.FindResource("ImageTransformResource") as TransformGroup; TranslateTransform transform = group.Children[1] as TranslateTransform; System.Windows.Point position = e.GetPosition(image); transform.X += position.X - PreviousMousePoint.X; transform.Y += position.Y - PreviousMousePoint.Y; PreviousMousePoint = position; translateChanged.X = transform.X; translateChanged.Y = transform.Y; TransformGroup transGroup = (TransformGroup)baseCanvas.RenderTransform; ScaleTransform scaleTrans = transGroup.Children[0] as ScaleTransform; TranslateTransform translateTrans = transGroup.Children[1] as TranslateTransform; translateTrans.X = transform.X; translateTrans.Y = transform.Y; }
private void ImageLeft_MouseWheel(object sender, MouseWheelEventArgs e) { ContentControl image = sender as ContentControl; if (image == null) { return; } TransformGroup group = ImageGird.FindResource("ImageTransformResource") as TransformGroup; System.Windows.Point point = e.GetPosition(image); double scale = e.Delta * 0.001; ZoomImage(group, point, scale); }