The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
The width, in pixels, of the rectangle of selection.
The height, in pixels, of the rectangle of selection.
Example





In This Topic
GdPicture14 Namespace / GdViewer Class / SetRectCoordinatesOnViewer Method

SetRectCoordinatesOnViewer Method (GdViewer)

In This Topic
Determines the rectangle of area selection refering to the displayed viewer area. This method sets the specified coordinates and dimensions, in pixels, to identify the rectangle of selection related to the document displayed in the GdViewer control. The specified rectangle is immediately drawn on the viewer area using the predefined parameters. Please ensure, that all given values correspond to the viewer area.

Be aware that the rectangle of selection always relates to the displayed document. On the other hand, you can specify the border size of this rectangle using the RectBorderSize property and the border color of this rectangle using the RectBorderColor property to be applied permanently.

Syntax
'Declaration
 
Public Sub SetRectCoordinatesOnViewer( _
   ByVal Left As Integer, _
   ByVal Top As Integer, _
   ByVal Width As Integer, _
   ByVal Height As Integer _
) 
public void SetRectCoordinatesOnViewer( 
   int Left,
   int Top,
   int Width,
   int Height
)
public procedure SetRectCoordinatesOnViewer( 
    Left: Integer;
    Top: Integer;
    Width: Integer;
    Height: Integer
); 
public function SetRectCoordinatesOnViewer( 
   Left : int,
   Top : int,
   Width : int,
   Height : int
);
public: void SetRectCoordinatesOnViewer( 
   int Left,
   int Top,
   int Width,
   int Height
) 
public:
void SetRectCoordinatesOnViewer( 
   int Left,
   int Top,
   int Width,
   int Height
) 

Parameters

Left
The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
Top
The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
Width
The width, in pixels, of the rectangle of selection.
Height
The height, in pixels, of the rectangle of selection.
Remarks
Be aware that you are allowed to define only one rectangle of selection within the current viewer. Likewise, the rectangle of selection always relates to the currently displayed document, meaning that without displaying some document you cannot specify the new rectangle of selection.

Just to remind you, that all coordinates are 0-based with the origin being in the top left corner in the viewer area.

Example
How to draw a rectangle of selection around the text found.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim text_to_find As String = "GdPicture"
    GdViewer1.RemoveAllRegions()
    Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 0, True)
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If text_found Then
            'The first region surely exists.
            Dim regID As Integer = GdViewer1.GetRegionID(1)
            GdViewer1.DisplayPage(GdViewer1.GetRegionPage(regID))
            Dim DocumentLeft As Integer = GdViewer1.GetRegionLeftPixels(regID)
            Dim DocumentTop As Integer = GdViewer1.GetRegionTopPixels(regID)
            Dim ViewerLeft As Integer = 0, ViewerTop As Integer = 0
            GdViewer1.CoordDocumentToViewer(DocumentLeft, DocumentTop, ViewerLeft, ViewerTop)
            Dim ViewerWidth As Integer = GdViewer1.GetRegionWidthPixels(regID)
            Dim ViewerHeight As Integer = GdViewer1.GetRegionHeightPixels(regID)
            GdViewer1.SetRectCoordinatesOnViewer(ViewerLeft, ViewerTop, ViewerWidth, ViewerHeight)
        Else
            MessageBox.Show("The given text has not been found.", "GdViewer.SetRectCoordinatesOnViewer")
        End If
    Else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnViewer")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnViewer")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string text_to_find = "GdPicture";
    GdViewer1.RemoveAllRegions();
    bool text_found = GdViewer1.SearchText(text_to_find, 0, true);
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        if (text_found)
        {
            //The first region surely exists.
            int regID = GdViewer1.GetRegionID(1);
            GdViewer1.DisplayPage(GdViewer1.GetRegionPage(regID));
            int DocumentLeft = GdViewer1.GetRegionLeftPixels(regID);
            int DocumentTop = GdViewer1.GetRegionTopPixels(regID);
            int ViewerLeft = 0, ViewerTop = 0;
            GdViewer1.CoordDocumentToViewer(DocumentLeft, DocumentTop, ref ViewerLeft, ref ViewerTop);
            int ViewerWidth = GdViewer1.GetRegionWidthPixels(regID);
            int ViewerHeight = GdViewer1.GetRegionHeightPixels(regID);
            GdViewer1.SetRectCoordinatesOnViewer(ViewerLeft, ViewerTop, ViewerWidth, ViewerHeight);
        }
        else
            MessageBox.Show("The given text has not been found.", "GdViewer.SetRectCoordinatesOnViewer");
    }
    else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnViewer");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRectCoordinatesOnViewer");
See Also