
Adding Interactivity to a Deep Zoom Image
After you load a Deep Zoom image, the user cannot yet interact with the image. To enable interaction, you need to handle MultiScaleImage events and use code to provide the zooming and panning functionality.
The following example uses the MouseEnter event to zoom into the middle of the image when the mouse pointer moves over the image.
Run this sample
<MultiScaleImage x:Name="deepZoomObject" Source="source/dzc_output.xml"
MouseEnter="DeepZoomObject_MouseEnter" />
Private Sub DeepZoomObject_MouseEnter(ByVal sender As Object, ByVal e As MouseEventArgs)
' The ZoomAboutLogicalPoint method allows you to zoom and pan
' in the same step. The first parameter is the zoom (3x) and the
' third and fourth parameters are the respective x and y coordinates
' of the logical point to zoom around.
Me.deepZoomObject.ZoomAboutLogicalPoint(3, 0.5, 0.5)
End Sub
private void DeepZoomObject_MouseEnter(object sender, MouseEventArgs e)
{
// The ZoomAboutLogicalPoint method allows you to zoom and pan
// in the same step. The first parameter is the zoom (3x) and the
// third and fourth parameters are the respective x and y coordinates
// of the logical point to zoom around.
this.deepZoomObject.ZoomAboutLogicalPoint(3, .5, .5);
}
In the preceding example, the ZoomAboutLogicalPoint method is what does the zooming and panning. The first parameter is the zoom multiplier, which is incremented from the current zoom factor of the image. For example, in this example the default zoom is 1, so the value 3 means that it is zoomed in 3 times. If you were to zoom again using the same value, you would be zoomed in at 3*3 which is 9 times from the original size.
The second and third parameters of the ZoomAboutLogicalPoint method are the respective x and y coordinates of the logical point of where to zoom around (or where to pan to). A logical point uses normalized values (0 to 1) for x and y positions within the image. Therefore, the value 0.5,0.5 is in the middle of the image because 0.5 is in the middle of 0 and 1. If you specified a coordinate value less than or equal to 0 or greater than or equal to 1, the image would pan completely out of view.
The area of the image the user views at any given time is called the viewport area. The following illustration shows what the viewport area looks like conceptually.