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





RegionCount Method (GdViewer)
Returns the number of all highlighted regions related to the document currently displayed in the GdViewer control. These regions, if present, determines the currently defined highlighted regions on the displayed document.

You can define a highlighted region using the AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) method. Be aware that highlighted regions are also determined using both SearchText(String,Int32,Boolean) and SearchText(String,Int32,Boolean,Boolean) methods.

Syntax
'Declaration
 
Public Function RegionCount() As Integer
 

Return Value

The number of all highlighted regions currently defined on the displayed document.
Remarks
You can regularly apply the GetStat method to determine if this method has been successful.

Just to inform you, that you are allowed to completely remove all defined highlighted regions using the RemoveAllRegions method

Example
How to find out the number of all determined highlighted regions after searching for given text.
'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, True)
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If text_found Then
            GdViewer1.Redraw()
            MessageBox.Show("The number of highlighted regions: " + GdViewer1.RegionCount().ToString(), "GdViewer.RegionCount")
        Else
            MessageBox.Show("The given text has not been found.", "GdViewer.RegionCount")
        End If
    Else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.RegionCount")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.RegionCount")
End If
See Also