Saving Annotation

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
Steve_Thompson
Posts: 3
Joined: Sun Nov 13, 2011 5:27 am

Saving Annotation

Post by Steve_Thompson » Sun Nov 13, 2011 5:42 am

I can add additional parameters to a particular annotation by creating a new class and then inheriting the annotation class - such as RulerAnnotation.

My problem is that I want to save the properties when I save the annotation. I can override the Serialize and Deserialize methods to do this to save in Binary format with no problem. I want to save them in Xml - however, routines in the base class for Xml seem to be marked as not overridable. Can this be changed to use both Serial and Xml save formats?

Public Class MyRulerAnnotation
Inherits RulerAnnotation

Public Property Part As String

''' Not Allowed
'Protected Overrides Sub WriteXmlContent(writer As XmlWriter)
'End Sub

''' Not allowed
'Protected Overrides Sub ReadXmlContent(reader As XmlReader)
'End Sub


Protected Overrides Sub Serialize(writer As System.IO.BinaryWriter)
MyBase.Serialize(writer)
writer.Write(Part)
End Sub

Protected Overrides Sub Deserialize(reader As System.IO.BinaryReader)
MyBase.Deserialize(reader)
Part = reader.ReadString
End Sub
End Class

Alex
Site Admin
Posts: 1461
Joined: Thu Jul 10, 2008 2:21 pm

Re: Saving Annotation

Post by Alex » Wed Nov 16, 2011 8:24 am

Hello Steve,

Custom annotation can be saved in XML or Binary format but cannot be saved in WANG format.

AnnotationBase.WriteXmlContent method is used when annotation is saving to XML packet. AnnotationBase.ReadXmlContent method is used when annotation is loading from XML packet. These methods can be overriden if custom annotation has custom fields/properties.

AnnotationBase.Serialize method is used when annotation is saving to Binary packet. AnnotationBase.Deserialize method is used when annotation is loading from Binary packet. These methods can be overriden if custom annotation has custom fields/properties.

Important: Custom annotation must have public constructor without parameters for serialization of annotation.


Please read the "Programming - Annotate images - Create a custom annotation" article in the documentation.

VintaSoftImaging.NET SDK has documentation in CHM format (Vintasoft.Imaging.chm file). You can find this file in the "\Documentation\" folder of the application installation.


Best regards, Alexander

Steve_Thompson
Posts: 3
Joined: Sun Nov 13, 2011 5:27 am

Re: Saving Annotation

Post by Steve_Thompson » Wed Nov 16, 2011 7:33 pm

Thanks. But I think you misunderstood the problem/question. I am not creating a new custom annotation. I am extending an existing annotation - ie the RulerAnnotation by adding a property to it and then using the Serialize method to save and retrieve that property (no problems with the Serialize - works fine). However, I want to save/retrieve it using XML - but those methods when you inherit the RulerAnnotation are marked as not overrideable. So, no I cannot save custom properties in XML (see the sample code provided). Now if I create a new annotation using the AnnotationBase I can do what you outlined - but as I have indicated - I am simply extending the RulerAnnotation. If I am doing something else wrong let me know, however, I don't believe the generic response you gave answered the specific question asked.

Alex
Site Admin
Posts: 1461
Joined: Thu Jul 10, 2008 2:21 pm

Re: Saving Annotation

Post by Alex » Thu Nov 17, 2011 8:48 am

Hello Steve,

I'm not sure I have understood you.

You need to create custom annotation derived from AnnotationBase or derived class and override AnnotationBase.WriteXmlContent and AnnotationBase.ReadXmlContent methods if you want to add new functionality to annotation, for example, add new field or property.

You need to use the AnnotationBase.WriteXml / AnnotationBase.ReadXml methods if you want to deserialize /serialize annotation as XMP packet.

Have I answered to your question?

Best regards, Alexander

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests