Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.5.2
|
Leadtools.Annotations Namespace > AnnObject Class : SerializePassword Property |
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
This example will implement copying/pasting all objects from a container to the clipboard.
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); } } } }