GetRegionColor Method (GdViewer)
In This Topic
Gets 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 AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) or AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) methods or directly using the SetRegionColor(Int32,Color) method.
Syntax
'Declaration
Public Function GetRegionColor( _
ByVal As Integer _
) As Color
public Color GetRegionColor(
int
)
public function GetRegionColor(
: Integer
): Color;
public function GetRegionColor(
: int
) : Color;
public: Color GetRegionColor(
int
)
public:
Color GetRegionColor(
int
)
Parameters
- RegionID
- A unique region identifier of the specified region. You can obtain this identifier using the GetRegionID method or when creating regions using AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) or AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) methods.
Return Value
The fill color of the specified region. The
GetStat method can be subsequently used to determine if this method has been successful.
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(1))
Dim currColor As Color = Color.Black, newColor As Color = GdViewer1.ARGB(65, 190, 190)
For j As Integer = 1 To regCount
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.GetRegionColor")
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 methods
//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(1));
Color currColor = Color.Black, newColor = GdViewer1.ARGB(65, 190, 190);
for (int j = 1; 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.GetRegionColor");
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(1))
Dim currColor As Color = Color.Black, newColor As Color = GdViewer1.ARGB(65, 190, 190)
For j As Integer = 1 To regCount
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.GetRegionColor")
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 methods
//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(1));
Color currColor = Color.Black, newColor = GdViewer1.ARGB(65, 190, 190);
for (int j = 1; 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.GetRegionColor");
See Also
Reference
GdViewer Class
GdViewer Members
AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) Method
AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) Method
SetRegionColor(Int32,Color) Method
GetRegionID Method
AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) Method
AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) Method
GetStat Method
SetRegionColor(Int32,Color) Method
RegionCount Method
GetRegionID Method
SearchText(String,Int32,Boolean) Method
AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) Method
AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) Method
GetRegionBorderColor Method
SetRegionBorderColor(Int32,Color) Method