ImageGear for .NET
UserData Property
See Also  Example Send Feedback
ImageGear21.Art Assembly > ImageGear.ART Namespace > ImGearARTMark Class : UserData Property




Glossary Item Box

Gets or sets the user data specified for the mark.

Syntax

 
Visual Basic
C#
Managed Extensions for C++
C++/CLI
 
 

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

C#Copy Code
[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;
        }
    }
}
Visual BasicCopy Code
<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
C#Copy Code
// 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);
Visual BasicCopy Code
' 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

©2013. Accusoft Corporation. All Rights Reserved.