GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / SetRegionEditable 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.
Set this parameter to true if you want to allow users to edit the specified region, otherwise set it to false.
Example





In This Topic
SetRegionEditable Method (GdViewer)
In This Topic
Specifies if users can edit 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.

All newly added regions are editable by default. You can change this behaviour for all regions at once by setting the RegionsAreEditable property.

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

Syntax
'Declaration
 
Public Function SetRegionEditable( _
   ByVal RegionID As Integer, _
   ByVal Editable As Boolean _
) As GdPictureStatus
public GdPictureStatus SetRegionEditable( 
   int RegionID,
   bool Editable
)
public function SetRegionEditable( 
    RegionID: Integer;
    Editable: Boolean
): GdPictureStatus; 
public function SetRegionEditable( 
   RegionID : int,
   Editable : boolean
) : GdPictureStatus;
public: GdPictureStatus SetRegionEditable( 
   int RegionID,
   bool Editable
) 
public:
GdPictureStatus SetRegionEditable( 
   int RegionID,
   bool Editable
) 

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.
Editable
Set this parameter to true if you want to allow users to edit the specified region, otherwise set it to false.

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.

Just to inform you, that all newly added regions are editable by default. You are allowed to change this behaviour for all regions at once by setting the RegionsAreEditable property.

Example
How to disable editing of the 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 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())
                'Preventing users from editing determined regions.
                GdViewer1.SetRegionEditable(regID, False)
                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.SetRegionEditable")
    Else
        MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionEditable")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionEditable")
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());
                //Preventing users from editing determined regions.
                GdViewer1.SetRegionEditable(regID, false);
                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.SetRegionEditable");
    }
    else
        MessageBox.Show("An error has occurred. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionEditable");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetRegionEditable");
See Also