Leadtools.Windows.Annotations Requires Document/Medical license. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
SerializePassword Property
See Also  Example
Leadtools.Windows.Annotations Namespace > AnnObjectBase Class : SerializePassword Property





Gets or sets a value indicating whether the password is saved when this AnnObjectBase is serialized. This is a dependency property.

Syntax

Visual Basic (Declaration) 
Public Property SerializePassword As Boolean
Visual Basic (Usage)Copy Code
Dim instance As AnnObjectBase
Dim value As Boolean
 
instance.SerializePassword = value
 
value = instance.SerializePassword
C# 
public bool SerializePassword {get; set;}
C++/CLI 
public:
property bool SerializePassword {
   bool get();
   void set (bool value);
}
XAML Attributes Usage 

<object SerializePassword=bool .../>

Dependencies Property Information 

Identifier field

SerializePasswordProperty

Metadata properties set to true

None

XAML Attributes Usage 

<object SerializePassword=bool .../>

Dependencies Property Information 

Identifier field

SerializePasswordProperty

Metadata properties set to true

None

Return Value

true if this password is saved when this AnnObjectBase is serialized; false otherwise.

Example

This example will implement copying/pasting all objects from a container to the clipboard.

Visual BasicCopy Code
'''
Private Shared ReadOnly clipboardFormatName As String = "LeadtoolsWindowsAnnotations"
Public Sub AnnObject_SerializePassword(ByVal container As AnnContainer)
   ' first create a temporary object collection and copy all objects in the container into it
   Dim destObjects As System.Collections.ObjectModel.ObservableCollection(Of AnnObjectBase) = New System.Collections.ObjectModel.ObservableCollection(Of AnnObjectBase)()
   For Each srcObj As AnnObjectBase In container.Children
      Dim destObj As AnnObjectBase = CType(IIf(TypeOf srcObj.Clone() Is AnnObjectBase, srcObj.Clone(), Nothing), AnnObjectBase)
      ' we do not want to save the password of locked objects to the clipbaord
      destObj.SerializePassword = False
      destObjects.Add(destObj)
   Next srcObj
   ' copy this object collection to the clipboard
   Dim dataObj As DataObject = New DataObject(clipboardFormatName, destObjects)
   Clipboard.SetDataObject(dataObj)
End Sub

Private Sub PasteObjectsFromClipboard(ByVal container As AnnContainer)
   ' check if the clipboard has LEADTOOLS annotations objects
   Dim data As IDataObject = Clipboard.GetDataObject()
   If Not data Is Nothing Then
      If data.GetDataPresent(clipboardFormatName) Then
         ' get the object collection from the clipboard
         Dim objects As System.Collections.ObjectModel.ObservableCollection(Of AnnObjectBase) = CType(IIf(TypeOf data.GetData(clipboardFormatName) Is System.Collections.ObjectModel.ObservableCollection(Of AnnObjectBase), data.GetData(clipboardFormatName), Nothing), System.Collections.ObjectModel.ObservableCollection(Of AnnObjectBase))

         ' move the objects from this collection to the container
         Do While objects.Count > 0
            Dim obj As AnnObjectBase = objects(0)
            objects.RemoveAt(0)
            container.Children.Add(obj)
         Loop
      End If
   End If
End Sub
C#Copy Code
///  
private static readonly string clipboardFormatName = "LeadtoolsWindowsAnnotations"; 
public void AnnObject_SerializePassword(AnnContainer container) 

   // first create a temporary object collection and copy all objects in the container into it 
   System.Collections.ObjectModel.ObservableCollection<AnnObjectBase> destObjects = new System.Collections.ObjectModel.ObservableCollection<AnnObjectBase>(); 
   foreach(AnnObjectBase srcObj in container.Children) 
   { 
      AnnObjectBase destObj = srcObj.Clone() as AnnObjectBase; 
      // we do not want to save the password of locked objects to the clipbaord 
      destObj.SerializePassword = false; 
      destObjects.Add(destObj); 
   } 
   // copy this object collection to the clipboard 
   DataObject dataObj = new DataObject(clipboardFormatName, destObjects); 
   Clipboard.SetDataObject(dataObj); 

 
private void PasteObjectsFromClipboard(AnnContainer container) 

   // check if the clipboard has LEADTOOLS annotations objects 
   IDataObject data = Clipboard.GetDataObject(); 
   if(data != null) 
   { 
      if(data.GetDataPresent(clipboardFormatName)) 
      { 
         // get the object collection from the clipboard 
         System.Collections.ObjectModel.ObservableCollection<AnnObjectBase> objects = data.GetData(clipboardFormatName) as System.Collections.ObjectModel.ObservableCollection<AnnObjectBase>; 
 
         // move the objects from this collection to the container 
         while(objects.Count > 0) 
         { 
            AnnObjectBase obj = objects[0]; 
            objects.RemoveAt(0); 
            container.Children.Add(obj); 
         } 
      } 
   } 
}

Remarks

Serialization is used throughout the annotation toolkit to save object states. For example, the annotation mode uses serialization to implement undo/redo buffers, copying/pasting objects to/from the clipboard as well as loading/saving objects to files or memory. Setting this property to false will not store the password field of a locked object when the object is serialized. This is not necessary in some situations such as implementing undo/redo buffers, but is very important to applications that do not want to save the password when objects are saved to disk files.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family

See Also

SerializePassword requires a Document/Medical product license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features and Unlocking Special LEAD Features.