GdPicture.NET.14 (COM - ActiveX)~GdPicture14_namespace / GdPicture.NET.14 (COM - ActiveX)~GdPicture14.GdViewer / AddRegionInches(String,Single,Single,Single,Single,ForegroundMixMode,Int32) Method
The name of the newly added highlighted region. It can be an empty string.
The horizontal (X) coordinate (0-based) of the top left point, in inches, of the highlighted region's rectangle, related to the current page.
The vertical (Y) coordinate (0-based) of the top left point, in inches, of the highlighted region's rectangle, related to the current page.
The width, in inches, of the highlighted region's rectangle, related to the current page.
The height, in inches, of the highlighted region's rectangle, related to the current page.
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.
A color value that defines the fill color of the newly added highlighted region. You can obtain a suitable color using the GdViewer.ARGBI method.
Example





In This Topic
    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 GdViewer.RegionCount method.

    Please note that highlighted regions are also determined using GdViewer.SearchText, SearchText_2 and SearchText_5 methods.

    You can also benefit from using several events related to highlighted regions like GdViewer.RegionEditedByUser, GdViewer.RegionMovedByUser , GdViewer.RegionResizedByUser and GdViewer.RegionSelectedByUser.

    Syntax
    'Declaration
     
    
    Public Function AddRegionInches( _
       ByVal Name As String, _
       ByVal Left As Single, _
       ByVal Top As Single, _
       ByVal Width As Single, _
       ByVal Height As Single, _
       ByVal MixMode As ForegroundMixMode, _
       ByVal RegionColor As Integer _
    ) As Integer
    public int AddRegionInches( 
       string Name,
       float Left,
       float Top,
       float Width,
       float Height,
       ForegroundMixMode MixMode,
       int RegionColor
    )
    public function AddRegionInches( 
        Name: String;
        Left: Single;
        Top: Single;
        Width: Single;
        Height: Single;
        MixMode: ForegroundMixMode;
        RegionColor: Integer
    ): Integer; 
    public function AddRegionInches( 
       Name : String,
       Left : float,
       Top : float,
       Width : float,
       Height : float,
       MixMode : ForegroundMixMode,
       RegionColor : int
    ) : int;
    public: int AddRegionInches( 
       string* Name,
       float Left,
       float Top,
       float Width,
       float Height,
       ForegroundMixMode MixMode,
       int RegionColor
    ) 
    public:
    int AddRegionInches( 
       String^ Name,
       float Left,
       float Top,
       float Width,
       float Height,
       ForegroundMixMode MixMode,
       int RegionColor
    ) 

    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 GdViewer.ARGBI method.

    Return Value

    A unique region identifier of the newly added highlighted region. Please always use the GdViewer.GetStat method to determine if this method has been successful.
    Remarks
    Be aware that highlighted regions are redefined using GdViewer.SearchText, SearchText_2 and SearchText_5 methods.
    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_4(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_4(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