GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / HorizontalResolution Property
Example





In This Topic
HorizontalResolution Property (GdViewer)
In This Topic
Gets the horizontal resolution in DPI (dots per inch) of the current page of the document displayed in the GdViewer control.
Syntax
'Declaration
 
Public ReadOnly Property HorizontalResolution As Single
public float HorizontalResolution {get;}
public read-only property HorizontalResolution: Single; 
public function get HorizontalResolution : float
public: __property float get_HorizontalResolution();
public:
property float HorizontalResolution {
   float get();
}

Property Value

The current page horizontal resolution, in DPI.
Remarks
Please note that the resulting value also depends on the currently set zoom factor.
Example
How to locate the clicked point.
'We assume that the GdViewer1 control has been properly integrated.
Sub GdViewer1_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim message As String = "This point is inside the document area."
    Dim ViewerLeft As Integer = e.X, ViewerTop As Integer = e.Y
    Dim DocumentLeft As Double = 0, DocumentTop As Double = 0
    GdViewer1.CoordViewerPixelToDocumentInch(ViewerLeft, ViewerTop, DocumentLeft, DocumentTop)
    If DocumentLeft < 0 OrElse DocumentTop < 0 Then
        message = "This point is outside the document area."
    Else
        Dim widthInches As Double = 0, heightInches As Double = 0
        If GdViewer1.GetDocumentType() = DocumentType.DocumentTypePDF Then
            widthInches = GdViewer1.PdfGetPageWidth() / 72
            heightInches = GdViewer1.PdfGetPageHeight() / 72
        Else
            widthInches = GdViewer1.PageWidth / GdViewer1.HorizontalResolution
            heightInches = GdViewer1.PageHeight / GdViewer1.VerticalResolution
        End If
        If DocumentLeft >= widthInches OrElse DocumentTop >= heightInches Then
            message = "This point is outside the document area."
        End If
    End If
    MessageBox.Show(message, "GdViewer.HorizontalResolution")
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.";
    int ViewerLeft = e.X, ViewerTop = e.Y;
    double DocumentLeft = 0, DocumentTop = 0;
    GdViewer1.CoordViewerPixelToDocumentInch(ViewerLeft, ViewerTop, ref DocumentLeft, ref DocumentTop);
    if (DocumentLeft < 0 || DocumentTop < 0)
    {
        message = "This point is outside the document area.";
    }
    else
    {
        double widthInches = 0, heightInches = 0;
        if (GdViewer1.GetDocumentType() == DocumentType.DocumentTypePDF)
        {
            widthInches = GdViewer1.PdfGetPageWidth() / 72;
            heightInches = GdViewer1.PdfGetPageHeight() / 72;
        }
        else
        {
            widthInches = GdViewer1.PageWidth / GdViewer1.HorizontalResolution;
            heightInches = GdViewer1.PageHeight / GdViewer1.VerticalResolution;
        }
        if (DocumentLeft >= widthInches || DocumentTop >= heightInches)
        {
            message = "This point is outside the document area.";
        }
    }
    MessageBox.Show(message, "GdViewer.HorizontalResolution");
}
See Also