Hi,
Is there any way to perform a fixed zoom on a multiscaleimage in deep zoom? i.e. click once to zoom about point X,Y to 2x, click again to restore to the original position and zoom level?
I have written the code to zoom in and out but calling zoomaboutlogicalpoint midway through the zoom process results in zooming out too far (I guess due to the 1/2 factor in the mouse up event - can I obtain the zoom level?). Also I'd like the zoomed out image to be central (I guess i change the point to zoom to that midway in the image but this doesnt seem to work, perhaps I need to factor in the ViewPort position?)
e.g.
private void msi_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point p = e.GetPosition(msi);
Zoom(2, p);
}
private void msi_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Point p = e.GetPosition(msi);
Zoom(1/2, p);
}
public void Zoom(double zoom, Point pointToZoom)
{
bool zoomingIn = zoom > 1;
bool zoomingOut = zoom < 1;
double minViewportWidth = 0.05;
double maxViewportWidth = 1;
if (msi.ViewportWidth < minViewportWidth && zoomingIn)
{
return;
}
if (msi.ViewportWidth > maxViewportWidth && zoomingOut)
{
return;
}
Point logicalPoint = this.msi.ElementToLogicalPoint(pointToZoom);
this.msi.ZoomAboutLogicalPoint(zoom, logicalPoint.X, logicalPoint.Y);
}
Thanks.