public static void OnZoomChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PreviewContent pc = (PreviewContent)d; double zoomFactor = Math.Min(pc.PreviewScroller.ActualWidth / pc.Profile.Monitors.VirtualScreenWidth, pc.PreviewScroller.ActualHeight / pc.Profile.Monitors.VirtualScreenHeight); if ((bool)e.NewValue) { pc.PreviewScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; pc.PreviewScroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; pc.Preview.ZoomFactor = 1d; pc.ZoomPanel.Visibility = Visibility.Visible; DoubleAnimation da = new DoubleAnimation(); da.From = zoomFactor; da.To = 1d; da.Duration = new Duration(TimeSpan.FromSeconds(0.75)); da.FillBehavior = FillBehavior.Stop; pc.Preview.BeginAnimation(ProfilePreview.ZoomFactorProperty, da); } else { pc.ZoomPanel.Visibility = Visibility.Collapsed; DoubleAnimation da = new DoubleAnimation(); da.From = pc.Preview.ZoomFactor; da.To = zoomFactor; da.Duration = new Duration(TimeSpan.FromSeconds(0.75)); da.Completed += new EventHandler(pc.Zoom_Completed); da.FillBehavior = FillBehavior.Stop; pc.Preview.BeginAnimation(ProfilePreview.ZoomFactorProperty, da); } }
public static void OnZoomLevelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PreviewContent pc = (PreviewContent)d; pc.Preview.ZoomFactor = _zoomCalibration.Interpolate((double)e.NewValue); }