SetRegionColorSelection Method (GdViewer)
In This Topic
Sets the fill color of a highlighted region, when it is selected by the user. The region is 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 determine this fill color of each highlighted region using the GetRegionColorSelection method.
Sets the fill color of a highlighted region, when it is selected by the user. The region is specified by its unique identifier related to the document
currently displayed in the GdViewer control.
Syntax
'Declaration
Public Function SetRegionColorSelection( _
ByVal As Integer, _
ByVal As Color _
) As GdPictureStatus
public GdPictureStatus SetRegionColorSelection(
int ,
Color
)
public function SetRegionColorSelection(
: Integer;
: Color
): GdPictureStatus;
public function SetRegionColorSelection(
: int,
: Color
) : GdPictureStatus;
public: GdPictureStatus SetRegionColorSelection(
int ,
Color
)
public:
GdPictureStatus SetRegionColorSelection(
int ,
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.
- ColorSelection
- A color object that defines the new fill color of the specified highlighted region when it is selected by the user.
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 redefine the color for the user selection of highlighted regions.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim text_to_find As String = "GdPicture"
Dim regID As Integer = 0, occurrence As Integer = 1
Dim left As Double = 0, top As Double = 0, width As Double = 0, height As Double = 0
'Removing previously defined regions, if any.
GdViewer1.RemoveAllRegions()
While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, True, left, top, width, height)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
regID = GdViewer1.AddRegion("", left, top, width, height, Color.FromArgb(176, 224, 230), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
GdViewer1.SetRegionName(regID, "Region" + regID.ToString())
'Setting the custom color for user selection.
GdViewer1.SetRegionColorSelection(regID, Color.FromArgb(0, 191, 255))
occurrence += 1
Else
Exit While
End If
Else
Exit While
End If
End While
If GdViewer1.GetStat() = GdPictureStatus.OK Then
GdViewer1.Redraw()
If GdViewer1.RegionCount() = 0 Then MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionColorSelection")
Else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
int regID = 0, occurrence = 1;
double left = 0, top = 0, width = 0, height = 0;
//Removing previously defined regions, if any.
GdViewer1.RemoveAllRegions();
while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, true, ref left, ref top, ref width, ref height))
{
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
regID = GdViewer1.AddRegion("", left, top, width, height, Color.FromArgb(176, 224, 230), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
GdViewer1.SetRegionName(regID, "Region" + regID.ToString());
//Setting the custom color for user selection.
GdViewer1.SetRegionColorSelection(regID, Color.FromArgb(0, 191, 255));
occurrence += 1;
}
else
break;
}
else
break;
}
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
GdViewer1.Redraw();
if (GdViewer1.RegionCount() == 0)
MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionColorSelection");
}
else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection");
Example
How to redefine the color for the user selection of highlighted regions.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim text_to_find As String = "GdPicture"
Dim regID As Integer = 0, occurrence As Integer = 1
Dim left As Double = 0, top As Double = 0, width As Double = 0, height As Double = 0
'Removing previously defined regions, if any.
GdViewer1.RemoveAllRegions()
While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, True, left, top, width, height)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
regID = GdViewer1.AddRegion("", left, top, width, height, Color.FromArgb(176, 224, 230), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
GdViewer1.SetRegionName(regID, "Region" + regID.ToString())
'Setting the custom color for user selection.
GdViewer1.SetRegionColorSelection(regID, Color.FromArgb(0, 191, 255))
occurrence += 1
Else
Exit While
End If
Else
Exit While
End If
End While
If GdViewer1.GetStat() = GdPictureStatus.OK Then
GdViewer1.Redraw()
If GdViewer1.RegionCount() = 0 Then MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionColorSelection")
Else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
int regID = 0, occurrence = 1;
double left = 0, top = 0, width = 0, height = 0;
//Removing previously defined regions, if any.
GdViewer1.RemoveAllRegions();
while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, true, ref left, ref top, ref width, ref height))
{
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
regID = GdViewer1.AddRegion("", left, top, width, height, Color.FromArgb(176, 224, 230), GdPicture14.WPF.GdViewer.RegionFillMode.Multiply);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
GdViewer1.SetRegionName(regID, "Region" + regID.ToString());
//Setting the custom color for user selection.
GdViewer1.SetRegionColorSelection(regID, Color.FromArgb(0, 191, 255));
occurrence += 1;
}
else
break;
}
else
break;
}
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
GdViewer1.Redraw();
if (GdViewer1.RegionCount() == 0)
MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionColorSelection");
}
else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionColorSelection");
See Also
Reference
GdViewer Class
GdViewer Members
GetRegionColorSelection Method
GetRegionID Method
AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) Method
GetRegionColorSelection Method
RegionCount Method
GetRegionID Method
SearchText(String,Int32,Boolean) Method
SearchText(String,Int32,Boolean,Boolean) Method
SearchText(Int32,String,Int32,Boolean,Double,Double,Double,Double) Method
SearchText(Int32,String,Int32,Boolean,Boolean,Double,Double,Double,Double) Method
AddRegion(String,Double,Double,Double,Double,Color,RegionFillMode) Method
RemoveAllRegions Method