Example





In This Topic
GdPicture14 Namespace / GdViewer Class / CenterOnRect() Method

CenterOnRect() Method

In This Topic
Moves the current page of the document displayed in the GdViewer control within the control to set the rectangle of area selection, if any is defined, in the middle of the control. You can use the IsRect method to find out, if the rectangle of selection is currently specified.
Syntax
'Declaration

 

Public Sub CenterOnRect() 
public void CenterOnRect()
public procedure CenterOnRect(); 
public function CenterOnRect();
public: void CenterOnRect(); 
public:

void CenterOnRect(); 
Remarks
You can regularly apply the GetStat method to determine if this method has been successful.

Just to inform you, that both the horizontal and the vertical scrollbars are set to new positions, if required. The ScrollViewer event is not raised using this method.

Likewise to remind you, that the current page is determined by the CurrentPage property.

Example
How to make the newly defined rectangle of selection visible in the viewer.
'We assume that the GdViewer1 control has been properly integrated

'and your document has been properly displayed as well.

If GdViewer1.SelectAllText() = GdPictureStatus.OK Then

    If GdViewer1.IsRect() Then GdViewer1.ClearRect()

    Dim regions As RectangleF() = GdViewer1.GetSelectedTextRegions()

    If (GdViewer1.GetStat() = GdPictureStatus.OK) AndAlso (regions.Count() > 0) Then

        'The first region surely exists.

        Dim rect As RectangleF = regions.ElementAt(0)

        GdViewer1.SetRectCoordinatesOnDocumentInches(rect.Left, rect.Top, rect.Width, rect.Height)

        GdViewer1.CenterOnRect()

    Else

        MessageBox.Show("The text region can't be found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CenterOnRect")

    End If

Else

    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CenterOnRect")

End If
//We assume that the GdViewer1 control has been properly integrated

//and your document has been properly displayed as well.

if (GdViewer1.SelectAllText() == GdPictureStatus.OK)

{

    if (GdViewer1.IsRect()) GdViewer1.ClearRect();

    RectangleF[] regions = GdViewer1.GetSelectedTextRegions();

    if ((GdViewer1.GetStat() == GdPictureStatus.OK) && (regions.Count() > 0))

    {

        //The first region surely exists.

        RectangleF rect = regions.ElementAt(0);

        GdViewer1.SetRectCoordinatesOnDocumentInches(rect.Left, rect.Top, rect.Width, rect.Height);

        GdViewer1.CenterOnRect();

    }

    else

        MessageBox.Show("The text region can't be found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CenterOnRect");

}

else

    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CenterOnRect");
See Also