The horizontal (X) coordinate, in pixels, of the point located inside the viewer area.
The vertical (Y) coordinate, in pixels, of the point located inside the viewer area.
Output parameter. The horizontal (X) coordinate, in inches, of the corresponding point located inside the document area.
Output parameter. The vertical (Y) coordinate, in inches, of the corresponding point located inside the document area.
Example





In This Topic
GdPicture14.WPF Namespace / GdViewer Class / CoordViewerPixelToDocumentInch Method

CoordViewerPixelToDocumentInch Method (GdViewer)

In This Topic
Translates the coordinates of the point located in the GdViewer control area (the viewer space), in pixels, to the coordinates of the corresponding point located in the displayed document (the document space), in inches. That said, the point with the coordinates (ViewerLeft, ViewerTop) inside the current page displayed in the viewer area matches to the point with coordinates (DocumentLeft, DocumentTop) inside the page with the same page number in the displayed document.
Syntax
'Declaration
 
Public Sub CoordViewerPixelToDocumentInch( _
   ByVal ViewerLeft As Double, _
   ByVal ViewerTop As Double, _
   ByRef DocumentLeft As Double, _
   ByRef DocumentTop As Double _
) 
public void CoordViewerPixelToDocumentInch( 
   double ViewerLeft,
   double ViewerTop,
   ref double DocumentLeft,
   ref double DocumentTop
)
public procedure CoordViewerPixelToDocumentInch( 
    ViewerLeft: Double;
    ViewerTop: Double;
   var  DocumentLeft: Double;
   var  DocumentTop: Double
); 
public function CoordViewerPixelToDocumentInch( 
   ViewerLeft : double,
   ViewerTop : double,
   DocumentLeft : double,
   DocumentTop : double
);
public: void CoordViewerPixelToDocumentInch( 
   double ViewerLeft,
   double ViewerTop,
   ref double DocumentLeft,
   ref double DocumentTop
) 
public:
void CoordViewerPixelToDocumentInch( 
   double ViewerLeft,
   double ViewerTop,
   double% DocumentLeft,
   double% DocumentTop
) 

Parameters

ViewerLeft
The horizontal (X) coordinate, in pixels, of the point located inside the viewer area.
ViewerTop
The vertical (Y) coordinate, in pixels, of the point located inside the viewer area.
DocumentLeft
Output parameter. The horizontal (X) coordinate, in inches, of the corresponding point located inside the document area.
DocumentTop
Output parameter. The vertical (Y) coordinate, in inches, of the corresponding point located inside the document area.
Remarks
Just to inform you, that all coordinates are 0-based with the origin being in the top left corner and they are related to the current page determined by the CurrentPage property.
Example
How to determine the area of the point clicked by the mouse.
Private Sub GdViewer1_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs)
    'We assume that the GdViewer1 control has been properly integrated.
    Dim message As String = "This point is inside the document area."
    Dim ViewerLeft As Double = e.GetPosition(Me).X, ViewerTop As Double = e.GetPosition(Me).Y
    Dim DocumentLeft As Double = 0, DocumentTop As Double = 0
    GdViewer1.CoordViewerPixelToDocumentInch(ViewerLeft, ViewerTop, DocumentLeft, DocumentTop)
    Dim widthInches As Double = GdViewer1.PageInchWidth / GdViewer1.PageHorizontalResolution
    Dim heightInches As Double = GdViewer1.PageInchHeight / GdViewer1.PageVerticalResolution
    If DocumentLeft < 0 OrElse DocumentTop < 0 OrElse DocumentLeft >= widthInches OrElse DocumentTop >= heightInches Then
        message = "This point is outside the document area."
    End If
    MessageBox.Show(message, "GdViewer.CoordViewerPixelToDocumentInch")
End Sub
//We assume that the GdViewer1 control has been properly integrated.
void GdViewer1_MouseClick(object sender, MouseEventArgs e)
{
    string message = "This point is inside the document area.";
    double ViewerLeft = e.GetPosition(this).X, ViewerTop = e.GetPosition(this).Y;
    double DocumentLeft = 0, DocumentTop = 0;
    GdViewer1.CoordViewerPixelToDocumentInch(ViewerLeft, ViewerTop, ref DocumentLeft, ref DocumentTop);
    double widthInches = GdViewer1.PageInchWidth / GdViewer1.PageHorizontalResolution;
    double heightInches = GdViewer1.PageInchHeight / GdViewer1.PageVerticalResolution;
    if (DocumentLeft < 0 || DocumentTop < 0 || DocumentLeft >= widthInches || DocumentTop >= heightInches)
    {
        message = "This point is outside the document area.";
    }
    MessageBox.Show(message, "GdViewer.CoordViewerPixelToDocumentInch");
}
See Also