GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / RemoveAllRegions Method
Example





In This Topic
RemoveAllRegions Method (GdViewer)
In This Topic
Removes 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 AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) or AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) methods. 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 RemoveAllRegions() As GdPictureStatus
public GdPictureStatus RemoveAllRegions()
public function RemoveAllRegions(): GdPictureStatus; 
public function RemoveAllRegions() : GdPictureStatus;
public: GdPictureStatus RemoveAllRegions(); 
public:
GdPictureStatus RemoveAllRegions(); 

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.
Example
How to remove all previously defined highlighted regions to replace them with the new ones.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim text_to_find As String = "GdPicture"
    Dim occurrence As Integer = 1
    Dim left As Single = 0, top As Single = 0, width As Single = 0, height As Single = 0
    Dim text_found As Boolean = False
    GdViewer1.RemoveAllRegions()
    While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, True, left, top, width, height)
        text_found = True
        GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGB(255, 176, 224, 230))
        occurrence = occurrence + 1
    End While
    If text_found Then
        GdViewer1.Redraw()
        MessageBox.Show("The number of highlighted regions: " + GdViewer1.RegionCount().ToString(), "GdViewer.RemoveAllRegions")
    Else
        MessageBox.Show("The given text has not been found.", "GdViewer.RemoveAllRegions")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.RemoveAllRegions")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string text_to_find = "GdPicture";
    int occurrence = 1;
    float left = 0, top = 0, width = 0, height = 0;
    bool text_found = false;
    GdViewer1.RemoveAllRegions();
    while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, true, ref left, ref top, ref width, ref height))
    {
        text_found = true;
        GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGB(255, 176, 224, 230));
        occurrence = occurrence + 1;
    }
    if (text_found)
    {
        GdViewer1.Redraw();
        MessageBox.Show("The number of highlighted regions: " + GdViewer1.RegionCount().ToString(), "GdViewer.RemoveAllRegions");
    }
    else
        MessageBox.Show("The given text has not been found.", "GdViewer.RemoveAllRegions");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.RemoveAllRegions");
See Also