Converts a point from control (display) to image coordinates.
Supported in Silverlight, Windows Phone 7
Syntax
Visual Basic (Declaration) | |
---|
Public Overridable Function PointToImageCoordinates( _
ByVal point As Point _
) As Point |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As ImageViewer
Dim point As Point
Dim value As Point
value = instance.PointToImageCoordinates(point) |
Parameters
- point
- The source point in control (display) coordinates.
Return Value
A
System.Windows.Point that contains the converted values in image coordinates.
Example
Visual Basic | Copy Code |
---|
Private Class PointToImageCoordinatesWindow : Inherits Window
Private theImage As ImageViewer
Public Sub New()
' Create the viewer
theImage = New ImageViewer()
' Create Dock Panel
Dim panel As DockPanel = New DockPanel()
Content = panel
DockPanel.SetDock(theImage, Dock.Bottom)
theImage.HorizontalAlignment = HorizontalAlignment.Center
theImage.VerticalAlignment = VerticalAlignment.Bottom
panel.Children.Add(theImage)
' load an image into the viewer
theImage.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))
theImage.SizeMode = SizeMode.Fit
Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)
AddHandler theImage.MouseDown, AddressOf theImage_MouseClick
End Sub
Private Sub theImage_MouseClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Dim point As Point = theImage.PointToImageCoordinates(e.GetPosition(Me))
Dim s As String = String.Format("Point accroding the image coordinates {0}", point.ToString())
MessageBox.Show(s)
End Sub
End Class
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class |
C# | Copy Code |
---|
class PointToImageCoordinatesWindow : Window
{
ImageViewer theImage;
public PointToImageCoordinatesWindow()
{
// Create the viewer
theImage = new ImageViewer();
// Create Dock Panel
DockPanel panel = new DockPanel();
Content = panel;
DockPanel.SetDock(theImage, Dock.Bottom);
theImage.HorizontalAlignment = HorizontalAlignment.Center;
theImage.VerticalAlignment = VerticalAlignment.Bottom;
panel.Children.Add(theImage);
// load an image into the viewer
theImage.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));
theImage.SizeMode = SizeMode.Fit;
Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);
theImage.MouseDown += new MouseButtonEventHandler(theImage_MouseClick);
}
void theImage_MouseClick(object sender, MouseButtonEventArgs e)
{
Point point = theImage.PointToImageCoordinates(e.GetPosition(this));
string s = string.Format("Point accroding the image coordinates {0}", point.ToString());
MessageBox.Show(s);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
} |
SilverlightCSharp | Copy Code |
---|
class PointToImageCoordinatesWindow : ChildWindow
{
ImageViewer theImage;
public PointToImageCoordinatesWindow()
{
// Create the viewer
theImage = new ImageViewer();
// Create Dock Panel
StackPanel panel = new StackPanel();
Content = panel;
theImage.HorizontalAlignment = HorizontalAlignment.Center;
theImage.VerticalAlignment = VerticalAlignment.Bottom;
panel.Children.Add(theImage);
// load an image into the viewer
theImage.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "cannon.jpg"));
theImage.SizeMode = SizeMode.Fit;
Title = string.Format("Size mode = {0}, click to change", theImage.SizeMode);
theImage.MouseLeftButtonDown += new MouseButtonEventHandler(theImage_MouseLeftButtonDown);
}
void theImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point point = theImage.PointToImageCoordinates(e.GetPosition(this));
string s = string.Format("Point accroding the image coordinates {0}", point.ToString());
MessageBox.Show(s);
}
} |
SilverlightVB | Copy Code |
---|
Private Class PointToImageCoordinatesWindow : Inherits ChildWindow
Private theImage As ImageViewer
Public Sub New()
' Create the viewer
theImage = New ImageViewer()
' Create Dock Panel
Dim panel As StackPanel = New StackPanel()
Content = panel
theImage.HorizontalAlignment = HorizontalAlignment.Center
theImage.VerticalAlignment = VerticalAlignment.Bottom
panel.Children.Add(theImage)
' load an image into the viewer
theImage.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "cannon.jpg"))
theImage.SizeMode = SizeMode.Fit
Title = String.Format("Size mode = {0}, click to change", theImage.SizeMode)
AddHandler theImage.MouseLeftButtonDown, AddressOf theImage_MouseLeftButtonDown
End Sub
Private Sub theImage_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Dim point As Point = theImage.PointToImageCoordinates(e.GetPosition(Me))
Dim s As String = String.Format("Point accroding the image coordinates {0}", point.ToString())
MessageBox.Show(s)
End Sub
End Class |
Remarks
Requirements
Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also