GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / ClearRect Method
Example





In This Topic
ClearRect Method (GdViewer)
In This Topic
Removes the rectangle of area selection, which is related to the document currently displayed in the GdViewer control, and deletes the corresponding rectangle's data, which are the location point and dimensions, as well. Removing means that no rectangle of selection is defined further, with the rectangle not drawn within the control anymore. You can find out, if this rectangle is currently defined and drawn, using the IsRect method.

As said, the rectangle of selection always relates to the displayed document, so its location point and dimensions are cleared when reloading documents within the viewer. On the other hand, the current values of the border size and the border color properties of the rectangle do not change when reloading documents or clearing the above-specified rectangle's data.

Syntax
'Declaration
 
Public Sub ClearRect() 
public void ClearRect()
public procedure ClearRect(); 
public function ClearRect();
public: void ClearRect(); 
public:
void ClearRect(); 
Remarks
Be aware that you are allowed to define only one rectangle of selection within the GdViewer control. Likewise, this rectangle always relates to the currently displayed document, meaning that without displaying some document you cannot specify the new rectangle of selection.
Example
How to clear the previously specified rectangle of selection and define the new one.
'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 Rect() = GdViewer1.GetSelectedTextRegions()
    If (GdViewer1.GetStat() = GdPictureStatus.OK) AndAlso (regions.Length > 0) Then
        Dim rect As Rect = regions(0)
        GdViewer1.SetRectCoordinatesOnDocumentInch(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.ClearRect")
    End If
Else
    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.ClearRect")
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();
    Rect[] regions = GdViewer1.GetSelectedTextRegions();
    if ((GdViewer1.GetStat() == GdPictureStatus.OK) && (regions.Length > 0))
    {
        //The first region surely exists.
        Rect rect = regions[0];
        GdViewer1.SetRectCoordinatesOnDocumentInch(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.ClearRect");
}
else
    MessageBox.Show("The text can't be selected. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.ClearRect");
See Also