private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { try { if ((SV.ActualWidth == 0) | (SV.ActualHeight == 0)) { return; } double oldWidth = 0; double oldHeight = Picture.ActualHeight; if (Picture.Width == double.NaN) { oldWidth = Picture.ActualWidth; } else { oldWidth = Picture.Width; } Picture.Width = (SV.ActualWidth - 18) * e.NewValue / 100; Picture.Height = (SV.ActualHeight - 18) * e.NewValue / 100; SV.ScrollToHorizontalOffset(SV.HorizontalOffset + (-oldWidth + Picture.Width) / 2); SV.ScrollToVerticalOffset(SV.VerticalOffset + (-oldHeight + Picture.Height) / 2); } catch { } }
private void Image_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Point P = e.GetPosition(Canv); SV.ScrollToHorizontalOffset((P.X * Zoom.Value) - HRect.Width / 2); SV.ScrollToVerticalOffset((P.Y * Zoom.Value) - HRect.Height / 2); } }
private void ScrollBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { SV.ScrollToHorizontalOffset(e.NewValue); }