ImageGear .NET - Updated
UserData Property (ImGearARTRedaction)
Example 




ImageGear24.Art Assembly > ImageGear.ART Namespace > ImGearARTRedaction Class : UserData Property
Gets or sets the user data specified for the mark.
Syntax
'Declaration
 
Public Overrides Property UserData As Object
'Usage
 
Dim instance As ImGearARTRedaction
Dim value As Object
 
instance.UserData = value
 
value = instance.UserData
public override object UserData {get; set;}
public: __property Object* get_UserData() override;
public: __property void set_UserData( 
   Object* value
) override;
public:
property Object^ UserData {
   Object^ get() override;
   void set (    Object^ value) override;
}

Property Value

Object value.
Remarks
You can load/save the data associated with this property from/to XML.

In order to do that you need to declare serializable class, create and initialize an object of that class, and attach it to ImGearARTMark.UserData.

Example
[Serializable]
public class UserData
{
    private string _textData;
    private int _integerData;

    public UserData(string textData, int integerData)
    {
        this.TextData = textData;
        this.IntegerData = integerData;
    }

    public string TextData
    {
        get
        {
            return _textData;
        }

        private set
        {
            _textData = value;
        }
    }

    public int IntegerData
    {
        get
        {
            return _integerData;
        }

        private set
        {
            _integerData = value;
        }
    }
}
<SerializableAttribute()> _
Public Class UserData
    Private _textData As String
    Private _integerData As String

    Public Sub New(ByVal textData As String, ByVal integerData As Integer)
        Me.TextData = textData
        Me.IntegerData = integerData
    End Sub
    Public Property TextData() As String
        Get
            Return _textData
        End Get
        Set(ByVal Value As String)
            _textData = Value
        End Set
    End Property
    Public Property IntegerData() As Integer
        Get
            Return _integerData
        End Get
        Set(ByVal Value As Integer)
            _integerData = Value
        End Set
    End Property
End Class
// Create user data.
UserData userData = new UserData("Text data to export to XML.", 99);

// Get annotation to assign user data to.
ImGearARTMark mark = igARTPage.MarkGet(markId);

// Set corresponding property of the mark.
mark.UserData = userData;

// Save page with annotation and user data to a stream.
ImGearART.SavePage(igARTPage, stream, 0, ImGearSavingModes.OVERWRITE, ImGearARTSaveType.XML);

stream.Seek(0, SeekOrigin.Begin);

// Create new ART Page from the stream and get the annotation with the user data.
ImGearARTPage newArtPage = ImGearART.LoadPage(stream, 0);
ImGearARTMark newMark = newArtPage.MarkGet(markId);
UserData newUserData = (UserData)newMark.UserData;

System.Diagnostics.Debug.Assert(newUserData.IntegerData == userData.IntegerData);
System.Diagnostics.Debug.Assert(newUserData.TextData == userData.TextData);
' Create user data.
Dim userData As UserData = New UserData("Textual data to export to XML", 99)

' Get annotation to assign user data to.
Dim mark As ImGearARTMark = igARTPage.MarkGet(markId)

' Set corresponding property of the mark.
mark.UserData = userData

' Save page with annotation and user data to a stream.
ImGearART.SavePage(igARTPage, stream, 0, ImGearSavingModes.OVERWRITE, ImGearARTSaveType.XML)

stream.Seek(0, SeekOrigin.Begin)

' Create new ART Page from the stream and get the annotation with the user data.
Dim newArtPage As ImGearARTPage = ImGearART.LoadPage(stream, 0)
Dim newMark As ImGearARTMark = newArtPage.MarkGet(markId)
Dim newUserData As UserData = CType(newMark.UserData, UserData)

System.Diagnostics.Debug.Assert(newUserData.IntegerData = userData.IntegerData)
System.Diagnostics.Debug.Assert(newUserData.TextData = userData.TextData)
See Also

Reference

ImGearARTRedaction Class
ImGearARTRedaction Members