Export (0) Print
Expand All

MultiScaleImage.ElementToLogicalPoint Method

Silverlight

Gets a point with logical coordinates (values between 0 and 1) from a point of the MultiScaleImage.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

public Point ElementToLogicalPoint(
	Point elementPoint
)

Parameters

elementPoint
Type: System.Windows.Point
The point on the MultiScaleImage to translate into a point with logical coordinates (values between 0 and 1).

Return Value

Type: System.Windows.Point
The logical point translated from the elementPoint.

Logical coordinates (also known as normalized coordinates) are between 0 and 1. This method takes a coordinate of the MultiScaleImage and returns the corresponding logical coordinate. For example, if the MultiScaleImage is 800 x 800 pixels, then the center point is at the coordinates of 400, 400. If you specified an elementPoint with coordinates of 400, 400, then this method would return a point with logical coordinates of 0.5, 0.5.

This method is useful in conjunction with the ZoomAboutLogicalPoint method, which only takes logical points. For example, you can use the ElementToLogicalPoint method to translate the current point the mouse pointer is over the MultiScaleSubImage into a logical point. Then. You can use that logical point in the ZoomAboutLogicalPoint method to zoom in on that point.

The following example shows how to zoom in on an image in the area that you click.

Run this sample


<Grid x:Name="LayoutRoot" Background="White">
    <MultiScaleImage x:Name="MyMSI" Source="source/dzc_output.xml"  MouseEnter="MyMSI_MouseEnter" MouseLeftButtonDown="MyMSI_LeftButtonDown" 
                     ImageOpenSucceeded="MyMSI_ImageOpenSucceeded" MouseLeave="MyMSI_MouseLeave" />

</Grid>



double zoom = 1;
double minzoom = 0.00001;
Point lastMouseLogicalPos = new Point();

private void MyMSI_LeftButtonDown(object sender, MouseButtonEventArgs e)
{
    double newzoom = zoom / 1.3;
    if (newzoom < minzoom) 
    { 
        newzoom = minzoom; 
    }
    lastMouseLogicalPos = e.GetPosition(this.MyMSI);
    Point logicalPoint = this.MyMSI.ElementToLogicalPoint(lastMouseLogicalPos);
    this.MyMSI.ZoomAboutLogicalPoint(zoom / newzoom, logicalPoint.X, logicalPoint.Y);
    zoom = newzoom;

}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft