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



Gets or sets a value indicating whether the password is saved when this AnnObject is serialized.

Syntax

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

Return Value

true if this password is saved when this AnnObject 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 = "LeadtoolsAnnotations"
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 RasterCollection(Of AnnObject) = New RasterCollection(Of AnnObject)()
   For Each srcObj As AnnObject In container.Objects
      Dim destObj As AnnObject = CType(IIf(TypeOf srcObj.Clone() Is AnnObject, srcObj.Clone(), Nothing), AnnObject)
      ' 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 format As DataFormats.Format = DataFormats.GetFormat(clipboardFormatName)
   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
      Dim format As DataFormats.Format = DataFormats.GetFormat(clipboardFormatName)
      If data.GetDataPresent(clipboardFormatName) Then
         ' get the object collection from the clipboard
         Dim objects As RasterCollection(Of AnnObject) = CType(IIf(TypeOf data.GetData(clipboardFormatName) Is RasterCollection(Of AnnObject), data.GetData(clipboardFormatName), Nothing), RasterCollection(Of AnnObject))

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

   // first create a temporary object collection and copy all objects in the container into it 
   RasterCollection<AnnObject> destObjects = new RasterCollection<AnnObject>(); 
   foreach(AnnObject srcObj in container.Objects) 
   { 
      AnnObject destObj = srcObj.Clone() as AnnObject; 
      // 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 
   DataFormats.Format format = DataFormats.GetFormat(clipboardFormatName); 
   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) 
   { 
      DataFormats.Format format = DataFormats.GetFormat(clipboardFormatName); 
      if(data.GetDataPresent(clipboardFormatName)) 
      { 
         // get the object collection from the clipboard 
         RasterCollection<AnnObject> objects = data.GetData(clipboardFormatName) as RasterCollection<AnnObject>; 
 
         // move the objects from this collection to the container 
         while(objects.Count > 0) 
         { 
            AnnObject obj = objects[0]; 
            objects.RemoveAt(0); 
            container.Objects.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 Server 2003 family, Windows Server 2008 family

See Also

Leadtools.Annotations requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features