MultiScaleImage.ElementToLogicalPoint Method
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)
Parameters
- elementPoint
- Type: System.Windows.Point
The point on the MultiScaleImage to translate into a point with logical coordinates (values between 0 and 1).
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.
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; }
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.