Gets or sets a value indicating whether the password is saved when this AnnObject is serialized.
public virtual bool SerializePassword { get; set; } Public Overridable Property SerializePassword As Boolean
true if this password is saved when this AnnObject is serialized; false otherwise.
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.
This example will implement copying/pasting all objects from a container to the clipboard.
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 itRasterCollection<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 clipbaorddestObj.SerializePassword = false;destObjects.Add(destObj);}// copy this object collection to the clipboardDataFormats.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 objectsIDataObject data = Clipboard.GetDataObject();if (data != null){DataFormats.Format format = DataFormats.GetFormat(clipboardFormatName);if (data.GetDataPresent(clipboardFormatName)){// get the object collection from the clipboardRasterCollection<AnnObject> objects = data.GetData(clipboardFormatName) as RasterCollection<AnnObject>;// move the objects from this collection to the containerwhile (objects.Count > 0){AnnObject obj = objects[0];objects.RemoveAt(0);container.Objects.Add(obj);}}}}
Imports LeadtoolsImports Leadtools.AnnotationsImports Leadtools.CodecsImports Leadtools.WinFormsImports 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 itDim destObjects As RasterCollection(Of AnnObject) = New RasterCollection(Of AnnObject)()For Each srcObj As AnnObject In container.ObjectsDim 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 clipbaorddestObj.SerializePassword = FalsedestObjects.Add(destObj)Next srcObj' copy this object collection to the clipboardDim format As DataFormats.Format = DataFormats.GetFormat(clipboardFormatName)Dim dataObj As DataObject = New DataObject(clipboardFormatName, destObjects)Clipboard.SetDataObject(dataObj)End SubPrivate Sub PasteObjectsFromClipboard(ByVal container As AnnContainer)' check if the clipboard has LEADTOOLS annotations objectsDim data As IDataObject = Clipboard.GetDataObject()If Not data Is Nothing ThenDim format As DataFormats.Format = DataFormats.GetFormat(clipboardFormatName)If data.GetDataPresent(clipboardFormatName) Then' get the object collection from the clipboardDim 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 containerDo While objects.Count > 0Dim obj As AnnObject = objects(0)objects.RemoveAt(0)container.Objects.Add(obj)LoopEnd IfEnd IfEnd Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
