GdPicture.NET Reference Guide
ZoomRect Method (GdViewer)
Example 





GdPicture14.WPF Namespace > GdViewer Class : ZoomRect Method
Adjusts the current zoom to the area covered by the specified rectangle of selection. You can use the IsRect method to determine if any rectangle of selection is defined.

The viewer control is subsequently refreshed to zoom on the defined rectangle.

Syntax
'Declaration
 
Public Function ZoomRect() As GdPictureStatus
public GdPictureStatus ZoomRect()
public function ZoomRect(): GdPictureStatus; 
public function ZoomRect() : GdPictureStatus;
public: GdPictureStatus ZoomRect(); 
public:
GdPictureStatus ZoomRect(); 

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Be aware that if the rectangle of selection is not defined, this method will fail.

Please note that the ZoomMode property is set to ViewerZoomMode.ZoomModeCustom using this method.

The ZoomChanged event, respectively the PreviewZoomChanged event, is raised using this method.

You can also try the Document Viewer Sample in your [INSTALLATION FOLDER]/Samples/WPF folder to find out, how to utilize zooming features in your application.

Example
Please try the Document Viewer Sample in your [INSTALLATION FOLDER]/Samples/WPF folder to find out, how to utilize zooming features in your application.How to zoom to the determined rectangle of area selection.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim text_to_find As String = "GdPicture"
    GdViewer1.ClearRect()
    GdViewer1.RectIsEditable = False
    Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 1, True)
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If text_found AndAlso GdViewer1.IsRect() Then
            GdViewer1.CenterOnRect()
            GdViewer1.ZoomRect()
        Else
            MessageBox.Show("The given text has not been found.", "GdViewer.ZoomRect")
        End If
    Else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.ZoomRect")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.ZoomRect")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string text_to_find = "GdPicture";
    GdViewer1.ClearRect();
    GdViewer1.RectIsEditable = false;
    bool text_found = GdViewer1.SearchText(text_to_find, 1, true);
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        if (text_found && GdViewer1.IsRect())
        {
            GdViewer1.CenterOnRect();
            GdViewer1.ZoomRect();
        }
        else
            MessageBox.Show("The given text has not been found.", "GdViewer.ZoomRect");
    }
    else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.ZoomRect");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.ZoomRect");
See Also

Reference

GdViewer Class
GdViewer Members
IsRect Method
SetRectCoordinatesOnViewerPixel Method
ZoomDocumentArea(Double,Double,Double,Double) Method
CenterOnRect Method
Zoom Property
ZoomMode Property
ZoomChanged Event
PreviewZoomChanged Event