GetRegionName Method (GdViewer)
In This Topic
Gets the name 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 name 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 SetRegionName method.
Syntax
'Declaration
Public Function GetRegionName( _
ByVal As Integer _
) As String
public string GetRegionName(
int
)
public function GetRegionName(
: Integer
): String;
public function GetRegionName(
: int
) : String;
public: string* GetRegionName(
int
)
public:
String^ GetRegionName(
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 name of the specified region. The
GetStat method can be subsequently used to determine if this method has been successful.
Example
Both these examples ilustrate you how to find out a name of a defined highlighted region.
This example presents some region properties set by the toolkit.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim text_to_find As String = "GdPicture"
GdViewer1.RemoveAllRegions()
Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 0, True, True)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If text_found Then
'Taking the first region to determine default values for some region properties set by the toolkit.
Dim regID As Integer = GdViewer1.GetRegionID(1)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of highlighted regions: " + GdViewer1.RegionCount().ToString()
message = message + vbCrLf + "name: " + GdViewer1.GetRegionName(regID).ToString()
message = message + " color: " + GdViewer1.GetRegionColor(regID).ToString()
message = message + vbCrLf + "border width: " + GdViewer1.GetRegionBorderWidth(regID).ToString()
message = message + " border color: " + GdViewer1.GetRegionBorderColor(regID).ToString()
message = message + " color selection: " + GdViewer1.GetRegionColorSelection(regID).ToString()
MessageBox.Show(message, "GdViewer.GetRegionColor")
Else
MessageBox.Show("The regionID has not been found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName")
End If
Else
MessageBox.Show("The given text has not been found.", "GdViewer.GetRegionName")
End If
Else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string text_to_find = "GdPicture";
GdViewer1.RemoveAllRegions();
bool text_found = GdViewer1.SearchText(text_to_find, 0, true, true);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (text_found)
{
//Taking the first region to determine default values for some region properties set by the toolkit.
int regID = GdViewer1.GetRegionID(1);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
string message = "The number of highlighted regions: " + GdViewer1.RegionCount().ToString();
message = message + "\nname: " + GdViewer1.GetRegionName(regID).ToString();
message = message + " color: " + GdViewer1.GetRegionColor(regID).ToString();
message = message + "\nborder width: " + GdViewer1.GetRegionBorderWidth(regID).ToString();
message = message + " border color: " + GdViewer1.GetRegionBorderColor(regID).ToString();
message = message + " color selection: " + GdViewer1.GetRegionColorSelection(regID).ToString();
MessageBox.Show(message, "GdViewer.GetRegionColor");
}
else
{
MessageBox.Show("The regionID has not been found. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName");
}
}
else
MessageBox.Show("The given text has not been found.", "GdViewer.GetRegionName");
}
else
MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName");
This example shows you how to find out the name of the highlighted region.
'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 message As String = "The number of regions: " + regCount.ToString()
For j As Integer = 1 To regCount
regID = GdViewer1.GetRegionID(j)
message = message + vbCrLf + "regID: " + regID.ToString() + " prev.name: " + GdViewer1.GetRegionName(regID) + " current name: "
GdViewer1.SetRegionName(regID, "Region" + regID.ToString())
message += GdViewer1.GetRegionName(regID)
Next
MessageBox.Show(message, "GdViewer.GetRegionName")
Else
MessageBox.Show("No highlighted region found related to this document. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName")
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)
{
string message = "The number of regions: " + regCount.ToString();
for (int j = 1; j <= regCount; j++)
{
regID = GdViewer1.GetRegionID(j);
message = message + "\nregID: " + regID.ToString() + " prev.name: " + GdViewer1.GetRegionName(regID) + " current name: ";
GdViewer1.SetRegionName(regID, "Region" + regID.ToString());
message += GdViewer1.GetRegionName(regID);
}
MessageBox.Show(message, "GdViewer.GetRegionName");
}
else
MessageBox.Show("No highlighted region found related to this document. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetRegionName");
See Also
Reference
GdViewer Class
GdViewer Members
SetRegionName Method
RegionCount Method
GetRegionID Method
RemoveAllRegions Method
SearchText(String,Int32,Boolean) Method
AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) Method
AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) Method