Namespace:
System.Windows.Controls
Assembly:
System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
Public Sub ZoomAboutLogicalPoint ( _
zoomIncrementFactor As Double, _
zoomCenterLogicalX As Double, _
zoomCenterLogicalY As Double _
)
Dim instance As MultiScaleImage
Dim zoomIncrementFactor As Double
Dim zoomCenterLogicalX As Double
Dim zoomCenterLogicalY As Double
instance.ZoomAboutLogicalPoint(zoomIncrementFactor, _
zoomCenterLogicalX, zoomCenterLogicalY)
public void ZoomAboutLogicalPoint(
double zoomIncrementFactor,
double zoomCenterLogicalX,
double zoomCenterLogicalY
)
Parameters
- zoomIncrementFactor
- Type: System..::.Double
Specifies the zoom. This number is greater than 0. A value of 1 specifies that the image fit the allotted page size exactly. A number greater than 1 specifies to zoom in. If a value of 0 or less is used, failure is returned and no zoom changes are applied.
- zoomCenterLogicalX
- Type: System..::.Double
X coordinate for the point on the MultiScaleImage that is zoomed in on. This is a logical point (between 0 and 1).
- zoomCenterLogicalY
- Type: System..::.Double
Y coordinate for the point on the MultiScaleImage that is zoomed in on. This is a logical point (between 0 and 1).
This method enables zooming and panning on the MultiScaleImage. The first parameter (zoomIncrementFactor) is the zoom multiplier which is incremented from the current zoom factor of the image. For example, a value of 1 specifies the default zoom and a value of 3 specifies that it is zoomed in 3 times. If you want to zoom again using the same value, you would zoom in at 3 * 3 which is 9 times from the default 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 (and where to pan to). A logical point uses normalized values (between 0 and 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 following example shows how to use the ZoomAboutLogicalPoint method to zoom in on the center of an image when the mouse pointer moves over the image, and then return back when the mouse pointer leaves the image.
Run this sample
<MultiScaleImage x:Name="deepZoomObject" Source="source/items.bin"
ImageOpenSucceeded="DeepZoomObject_ImageOpenSucceeded"
MouseEnter="DeepZoomObject_MouseEnter"
MouseLeave="DeepZoomObject_MouseLeave"/>
private void DeepZoomObject_ImageOpenSucceeded(object sender, RoutedEventArgs e)
{
// Turn the animations off when the image first loads. This avoids
// the default behavior of the image initially zooming into view.
// However, you will probably want to turn the animations on later
// so that the user will have animations when they pan and zoom.
deepZoomObject.UseSprings = false;
}
private void DeepZoomObject_MouseEnter(object sender, MouseEventArgs e)
{
// If animation springs were turned off, then
// turn them back on
if (deepZoomObject.UseSprings == false)
{
deepZoomObject.UseSprings = true;
}
// 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);
}
private void DeepZoomObject_MouseLeave(object sender, MouseEventArgs e)
{
double zoom = 1;
zoom = zoom / 3;
// This time the zoom is reversed (1/3) although the pan
// remains the same - zoom back out from the middle.
this.deepZoomObject.ZoomAboutLogicalPoint(zoom, .5, .5);
}
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Reference