GdPicture.NET Reference Guide
SetRegionColor Method (GdViewer)
Example 





GdPicture14.WPF Namespace > GdViewer Class : SetRegionColor Method
A unique region identifier of the specified region. You can obtain this identifier using the GetRegionID method or when creating regions using the AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) method.
A color object that defines the new fill color of the specified region.
Sets the fill color of a highlighted region specified by its unique identifier 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 the fill color of each highlighted region when adding regions using the AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) method. You can determine the fill color of each highlighted region using the GetRegionColor method.

Please note that you need to redraw the control using the Redraw method to immediately apply the newly defined color.

Sets the fill color of a highlighted region specified by its unique identifier related to the document currently displayed in the GdViewer control.
Syntax
'Declaration
 
Public Function SetRegionColor( _
   ByVal RegionID As Integer, _
   ByVal Color As Color _
) As GdPictureStatus
public GdPictureStatus SetRegionColor( 
   int RegionID,
   Color Color
)
public function SetRegionColor( 
    RegionID: Integer;
    Color: Color
): GdPictureStatus; 
public function SetRegionColor( 
   RegionID : int,
   Color : Color
) : GdPictureStatus;
public: GdPictureStatus SetRegionColor( 
   int RegionID,
   Color Color
) 
public:
GdPictureStatus SetRegionColor( 
   int RegionID,
   Color Color
) 

Parameters

RegionID
A unique region identifier of the specified region. You can obtain this identifier using the GetRegionID method or when creating regions using the AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) method.
Color
A color object that defines the new fill color of the specified region.

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.
Remarks
Be aware that if the required region does not exist, the method will fail.

Just to inform you, that the default fill color set by the toolkit is yellow, ARGB(255, 255, 0).

Example
How to change the fill color of highlighted regions.
'We assume that the GdViewer1 control has been properly integrated and your document has been properly displayed as well.
            
'To successfully follow this example, please use the code snippet attached to AddRegion or AddRegionInches methods
'to define highlighted regions or define some highlighted regions using SearchText methods by yourself.
Dim regID As Integer = 0, regCount As Integer = GdViewer1.RegionCount()
If regCount > 0 Then
    Dim firstRegColor As Color = GdViewer1.GetRegionColor(GdViewer1.GetRegionID(0))
    Dim currColor As Color, newColor As Color = Color.Rgb(65, 190, 190)
    For j As Integer = 0 To regCount-1
        regID = GdViewer1.GetRegionID(j)
        currColor = GdViewer1.GetRegionColor(regID)
        If currColor = firstRegColor Then GdViewer1.SetRegionColor(regID, newColor)
    Next
    'Redrawing regions with the newly defined color.
    GdViewer1.Redraw()
Else
    MessageBox.Show("No highlighted region found related to this document. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColor")
End If
//We assume that the GdViewer1 control has been properly integrated and your document has been properly displayed as well.
            
//To successfully follow this example, please use the code snippet attached to AddRegion or AddRegionInches method
//to define highlighted regions or define some highlighted regions using SearchText methods by yourself.
int regID = 0, regCount = GdViewer1.RegionCount();
if (regCount > 0)
{
    Color firstRegColor = GdViewer1.GetRegionColor(GdViewer1.GetRegionID(0));
    Color currColor, newColor = Color.FromArgb(255, 65, 190, 190);
    for (int j = 0; j < regCount; j++)
    {
        regID = GdViewer1.GetRegionID(j);
        currColor = GdViewer1.GetRegionColor(regID);
        if (currColor == firstRegColor)
            GdViewer1.SetRegionColor(regID, newColor);
    }
    //Redrawing regions with the newly defined color.
    GdViewer1.Redraw();
}
else
    MessageBox.Show("No highlighted region found related to this document. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColor");
See Also

Reference

GdViewer Class
GdViewer Members
GetRegionColor Method
RegionCount Method
GetRegionID Method
SearchText(String,Int32,Boolean) Method
SearchText(String,Int32,Boolean,Boolean) Method
AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) Method