AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) Method
In This Topic
Adds and highlights a new region on the current page of the document displayed in the GdViewer control according to what you have specified. This method uses inches to define the position and the size of the region's rectangle.
The region is highlighted immediately using the specified color. At the same, it is added to the list of all highlighted regions related to the displayed document. You can find out the number of currently defined highlighted regions using the RegionCount method.
Please note that highlighted regions are also determined using both SearchText(String,Int32,Boolean) and SearchText(String,Int32,Boolean,Boolean) methods.
You can also benefit from using several events related to highlighted regions like RegionEditedByUser, RegionMovedByUser , RegionResizedByUser and RegionSelectedByUser.
Syntax
'Declaration
Public Overloads Function AddRegionInches( _
ByVal As String, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As ForegroundMixMode, _
ByVal As Integer _
) As Integer
public int AddRegionInches(
string ,
float ,
float ,
float ,
float ,
ForegroundMixMode ,
int
)
public function AddRegionInches(
: String;
: Single;
: Single;
: Single;
: Single;
: ForegroundMixMode;
: Integer
): Integer;
public function AddRegionInches(
: String,
: float,
: float,
: float,
: float,
: ForegroundMixMode,
: int
) : int;
public: int AddRegionInches(
string* ,
float ,
float ,
float ,
float ,
ForegroundMixMode ,
int
)
public:
int AddRegionInches(
String^ ,
float ,
float ,
float ,
float ,
ForegroundMixMode ,
int
)
Parameters
- Name
- The name of the newly added highlighted region. It can be an empty string.
- Left
- The horizontal (X) coordinate (0-based) of the top left point, in inches, of the highlighted region's rectangle, related to the current page.
- Top
- The vertical (Y) coordinate (0-based) of the top left point, in inches, of the highlighted region's rectangle, related to the current page.
- Width
- The width, in inches, of the highlighted region's rectangle, related to the current page.
- Height
- The height, in inches, of the highlighted region's rectangle, related to the current page.
- MixMode
- A member of the ForegroundMixMode enumeration. Specifies the foreground mix mode used to combine the region fill color
and the displayed area of the image covered by this region when highlighting.
- RegionColor
- A color value that defines the fill color of the newly added highlighted region. You can obtain a suitable color using the ARGBI method.
Return Value
A unique region identifier of the newly added highlighted region. The
GetStat method can be subsequently used to determine if this method has been successful.
Example
How to define highlighted regions according to the searched text.
'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 Single = 0, top As Single = 0, width As Single = 0, height As Single = 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.AddRegionInches("", left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGBI(255, 176, 224, 230))
If GdViewer1.GetStat() = GdPictureStatus.OK Then
GdViewer1.SetRegionName(regID, "Region" + regID.ToString())
occurrence += 1
Else
Exit While
End If
Else
Exit While
End If
End While
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If GdViewer1.RegionCount() = 0 Then MessageBox.Show("The given text has not been found.", "GdViewer.AddRegionInches")
Else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches")
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;
float 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.AddRegionInches("", left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGBI(255, 176, 224, 230));
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
GdViewer1.SetRegionName(regID, "Region" + regID.ToString());
occurrence += 1;
}
else
break;
}
else
break;
}
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (GdViewer1.RegionCount() == 0)
MessageBox.Show("The given text has not been found.", "GdViewer.AddRegionInches");
}
else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches");
Example
How to define highlighted regions according to the searched text.
'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 Single = 0, top As Single = 0, width As Single = 0, height As Single = 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.AddRegionInches("", left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGBI(255, 176, 224, 230))
If GdViewer1.GetStat() = GdPictureStatus.OK Then
GdViewer1.SetRegionName(regID, "Region" + regID.ToString())
occurrence += 1
Else
Exit While
End If
Else
Exit While
End If
End While
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If GdViewer1.RegionCount() = 0 Then MessageBox.Show("The given text has not been found.", "GdViewer.AddRegionInches")
Else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches")
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;
float 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.AddRegionInches("", left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGBI(255, 176, 224, 230));
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
GdViewer1.SetRegionName(regID, "Region" + regID.ToString());
occurrence += 1;
}
else
break;
}
else
break;
}
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (GdViewer1.RegionCount() == 0)
MessageBox.Show("The given text has not been found.", "GdViewer.AddRegionInches");
}
else
MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.AddRegionInches");
See Also
Reference
GdViewer Class
GdViewer Members
Overload List
RegionCount Method
SearchText(String,Int32,Boolean) Method
SearchText(String,Int32,Boolean,Boolean) Method
RegionEditedByUser Event
RegionMovedByUser Event
RegionResizedByUser Event
RegionSelectedByUser Event
ARGBI Method
SearchText(String,Int32,Boolean) Method
SearchText(String,Int32,Boolean,Boolean) Method
GetStat Method
AddRegion(String,Int32,Int32,Int32,Int32,ForegroundMixMode,Int32) Method
RegionCount Method
RemoveAllRegions Method
ARGBI Method
SearchText(String,Int32,Boolean,Boolean,Boolean) Method
SearchText(Int32,String,Int32,Boolean,Boolean,Boolean,Single,Single,Single,Single) Method