Reference Guide
GdPicture14.WPF 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 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 Sub RemoveAllRegions() 
    public void RemoveAllRegions()
    public procedure RemoveAllRegions(); 
    public function RemoveAllRegions();
    public: void RemoveAllRegions(); 
    public:
    void RemoveAllRegions(); 
    Remarks
    You can regularly apply the GetStat method to determine if this method has been successful.
    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 Double = 0, top As Double = 0, width As Double = 0, height As Double = 0
        Dim text_found As Boolean = 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.AddRegion("Region" + occurrence.ToString(), left, top, width, height, Color.FromArgb(255, 176, 224, 230), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply)
            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.AddRegion("Region" + occurrence.ToString(), left, top, width, height, Color.FromArgb(255, 176, 224, 230), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply);
            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