GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / SetRegionPage Method
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.
The new number of the page, where the specified highlighted region is to be drawn.
Example





In This Topic
SetRegionPage Method (GdViewer)
In This Topic
Sets the number of the page on which a highlighted region is to be drawn (placed). 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 the page of each highlighted region using the GetRegionPage method.

Syntax
'Declaration
 
Public Function SetRegionPage( _
   ByVal RegionID As Integer, _
   ByVal Page As Integer _
) As GdPictureStatus
public GdPictureStatus SetRegionPage( 
   int RegionID,
   int Page
)
public function SetRegionPage( 
    RegionID: Integer;
    Page: Integer
): GdPictureStatus; 
public function SetRegionPage( 
   RegionID : int,
   Page : int
) : GdPictureStatus;
public: GdPictureStatus SetRegionPage( 
   int RegionID,
   int Page
) 
public:
GdPictureStatus SetRegionPage( 
   int RegionID,
   int Page
) 

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.
Page
The new number of the page, where the specified highlighted region is to be drawn.

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.
Remarks
Be aware that if the required region does not exist, the method will fail.
Example
How to set the proper page number for the defined highlighted region.
'We assume that the GdViewer1 control has been properly integrated.
'Please use the multipage document for this example.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim text_to_find As String = "GdPicture"
    GdViewer1.RemoveAllRegions()
    GdViewer1.DisplayPage(1)
    'Determining highlighted regions according to the given text.
    Dim text_found As Boolean = GdViewer1.SearchText(text_to_find, 0, True)
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If text_found AndAlso (GdViewer1.RegionCount() > 0) Then
            'The first region surely exists.
            Dim regID As Integer = GdViewer1.GetRegionID(1)
            GdViewer1.SetRegionName(regID, "Region1")
            GdViewer1.SetRegionColor(regID, GdViewer1.ARGBI(255, 0, 191, 255))
            'Taking properties from the first region.
            Dim left As Single = GdViewer1.GetRegionLeft(regID), top As Single = GdViewer1.GetRegionTop(regID)
            Dim width As Single = GdViewer1.GetRegionWidth(regID), height As Single = GdViewer1.GetRegionHeight(regID)
            For p As Integer = 2 To GdViewer1.PageCount
                'Adding regions on the same position on each page as the first one is (with the different color)
                'to compare them with those found by the toolkit using the SearchText() method if any exists.
                regID = GdViewer1.AddRegionInches("Region" + p.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGBI(255, 0, 191, 255))
                GdViewer1.SetRegionPage(regID, p)
            Next
            GdViewer1.Redraw()
            'Now you can scroll the viewer to find the newly added regions.
        Else
            MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionPage")
        End If
    Else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionPage")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionPage")
End If
//We assume that the GdViewer1 control has been properly integrated.
//Please use the multipage document for this example.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string text_to_find = "GdPicture";
    GdViewer1.RemoveAllRegions();
    GdViewer1.DisplayPage(1);
    //Determining highlighted regions according to the given text.
    bool text_found = GdViewer1.SearchText(text_to_find, 0, true);
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        if (text_found && (GdViewer1.RegionCount()> 0))
        {
            //The first region surely exists.
            int regID = GdViewer1.GetRegionID(1);
            GdViewer1.SetRegionName(regID, "Region1");
            GdViewer1.SetRegionColor(regID, GdViewer1.ARGBI(255, 0, 191, 255));
            //Taking properties from the first region.
            float left = GdViewer1.GetRegionLeft(regID), top = GdViewer1.GetRegionTop(regID);
            float width = GdViewer1.GetRegionWidth(regID), height = GdViewer1.GetRegionHeight(regID);
            for (int p = 2; p <= GdViewer1.PageCount; p++)
            {
                //Adding regions on the same position on each page as the first one is (with the different color)
                //to compare them with those found by the toolkit using the SearchText() method if any exists.
                regID = GdViewer1.AddRegionInches("Region" + p.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, GdViewer1.ARGBI(255, 0, 191, 255));
                GdViewer1.SetRegionPage(regID, p);
            }
            GdViewer1.Redraw();
            //Now you can scroll the viewer to find the newly added regions.
        }
        else
            MessageBox.Show("The given text has not been found.", "GdViewer.SetRegionPage");
    }
    else
        MessageBox.Show("The search process has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionPage");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionPage");
See Also