LEADTOOLS Annotations (Leadtools.Annotations assembly)

SerializePassword Property (AnnObject)

Show in webframe
Example 





Gets or sets a value indicating whether the password is saved when this AnnObject is serialized.
Syntax
public virtual bool SerializePassword {get; set;}
'Declaration
 
Public Overridable Property SerializePassword As Boolean
'Usage
 
Dim instance As AnnObject
Dim value As Boolean
 
instance.SerializePassword = value
 
value = instance.SerializePassword

            

            
public:
virtual property bool SerializePassword {
   bool get();
   void set (    bool value);
}

Property Value

true if this password is saved when this AnnObject is serialized; false otherwise.
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.
Example
Copy Code  
Imports Leadtools
Imports Leadtools.Annotations
Imports Leadtools.Codecs
Imports Leadtools.WinForms
Imports Leadtools.Drawing

''' 
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
using Leadtools;
using Leadtools.Annotations;
using Leadtools.Codecs;
using Leadtools.WinForms;
using Leadtools.Drawing;

/// 
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);
         }
      }
   }
}
Requirements

Target Platforms

See Also

Reference

AnnObject Class
AnnObject Members

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.