void OnZoomDelta(object sender, C1ZoomDeltaEventArgs e) { var maxZoom = Math.Min(ActualWidth / Rectangle.ActualWidth, ActualHeight / Rectangle.ActualHeight) / 2; var newZoom = Math.Min(maxZoom, _initialZoom * e.UniformCumulativeScale); var maxX = FramePanel.ActualWidth - Rectangle.ActualWidth * newZoom; var maxY = FramePanel.ActualHeight - Rectangle.ActualHeight * newZoom; double newX, newY; Zoom(maxZoom, _initialZoom, _initialPosition, _relativePosition, newZoom, out newX, out newY); Clip(maxX, maxY, ref newX, ref newY); SetZoom(newZoom, newX, newY, false); }
void OnZoomDelta(object sender, C1ZoomDeltaEventArgs e) { var maxZoom = Math.Min(FramePanel.GetActualWidth() / Rectangle.GetActualWidth(), FramePanel.GetActualHeight() / Rectangle.GetActualHeight()) / 2; var newZoom = Math.Min(maxZoom, _initialZoom * e.UniformCumulativeScale); var maxX = FramePanel.GetActualWidth() - Rectangle.GetActualWidth() * newZoom; var maxY = FramePanel.GetActualHeight() - Rectangle.GetActualHeight() * newZoom; double newX, newY; Zoom(maxZoom, _initialZoom, _initialPosition, _relativePosition, newZoom, out newX, out newY); newX = newX + e.CumulativeTranslation.X; newY = newY + e.CumulativeTranslation.Y; Clip(maxX, maxY, ref newX, ref newY); SetZoom(newZoom, newX, newY, false); }