Page 1 of 1
Loading EmbeddedImageAnnotations from XML
Posted: Thu Apr 14, 2011 4:57 pm
by m.zuidhoek
Hello there,
Currently I'm trying to save annotations to a XML file so they can be edited at a later time. However, every time i try to load the XML file, any EmbeddedImageAnnotations stored in the file are not loaded. I checked the XML files to make sure the annotations were saved at all, but they are present in the file. Checking the AnnotationCollection after the loading shows that the EmbeddedImageAnnotations are in fact
not loaded, leaving me clueless as to where they have gone to.
Does anyone have a idea why only this type of annotations won't show up after loading the file?
I'll include a piece of XML Code that contains one of the EmbeddedImageAnnotations
Code: Select all
<SymbolAnnotation assembly="ctlAnnotation" namespace="ctlAnnotation">
<Guid type="System.Guid">
<![CDATA[ ab0441f9-cf6c-4d31-963e-0ce57d2ca2af]]>
</Guid>
<CreationTime type="System.String">
<![CDATA[ 2011-04-14T15:10:29]]>
</CreationTime>
<ModifiedTime type="System.String">
<![CDATA[ 2011-04-14T15:10:29]]>
</ModifiedTime>
<Location type="System.String">
<![CDATA[ 112,69.5]]>
</Location>
<Rotation type="System.Single">0</Rotation>
<Size type="System.String">
<![CDATA[ 24,24]]>
</Size>
<Visible type="System.Boolean">True</Visible>
<HorizontalMirrored type="System.Boolean">False</HorizontalMirrored>
<VerticalMirrored type="System.Boolean">False</VerticalMirrored>
<Border type="System.Boolean">False</Border>
<ZOrder type="System.Int32">0</ZOrder>
<BackColor type="System.Int32">-1</BackColor>
<Outline type="Vintasoft.Annotation.AnnotationPen">
<Width type="System.Single">1</Width>
<Color type="System.Drawing.Color">-16777216</Color>
<DashOffset type="System.Single">0</DashOffset>
<MiterLimit type="System.Single">10</MiterLimit>
<Brush type="System.Drawing.Brush">Solid FF000000</Brush>
</Outline>
<Symmetry type="System.Boolean">False</Symmetry>
<Brush type="System.String">Solid FFFFFFFF</Brush>
<ImageData type="System.String">
<![CDATA[89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7AF4000000017352474200AECE1CE90000000467414D410000B18F0BFC6105000000206348524D00007A26000080840000FA00000080E8000075300000EA6000003A98000017709CBA513C00000083494441545847ED96510AC03008437BFF4B77F4A32065BA48043BC8605F95E4F1987463E8910119700DCCE9CB5967DE5BA67417D8C0A8F83CA3416CE00A430A9019188C517CC2C3A55FBA334134046360835210155F3A0590D11DCDBE6D535536942300196835D0BA86D79447D73AB4C7D9A1D21BF157E5F69F210BAE7919908146030F66CDC7395BCE56450000000049454E44AE426082]]>
</ImageData>
</SymbolAnnotation>
M. Zuidhoek
Re: Loading EmbeddedImageAnnotations from XML
Posted: Thu Apr 14, 2011 5:07 pm
by Alex
Hello,
You have created custom annotation as I have understood. We need to reproduce your problem - please send us code of your custom annotation class and XMP file with annotation.
Best regards, Alexander
Re: Loading EmbeddedImageAnnotations from XML
Posted: Mon Apr 18, 2011 9:56 am
by m.zuidhoek
Hello Alex,
Here's the code of the custom annotation class:
Code: Select all
Imports Vintasoft.Annotation
Public Class SymbolAnnotation
Inherits EmbeddedImageAnnotation
Public File As Bitmap
Private ColorChanger As ColorManager
Public Sub New(ByVal Image As Bitmap)
ColorChanger = ColorManager.GetInstance()
ColorChanger.File = Image
Me.Image = Image
File = Image
End Sub
Public Overrides Function Clone() As Object
Dim Result As New SymbolAnnotation(File)
CopyTo(Result)
Return Result
End Function
'Executes actions that must be done before the user starts building the annotation (like setting color)
Protected Overrides Sub OnStartBuilding(ByVal point As System.Drawing.PointF)
point = New PointF(point.X + 24, point.Y)
MyBase.OnStartBuilding(point)
Me.Border = False
Me.Image = ColorChanger.ChangeColor()
End Sub
'The actual building
Protected Overrides Sub OnBuilding(ByVal mouse As System.Windows.Forms.MouseEventArgs, ByVal action As Vintasoft.Annotation.MouseActions)
MyBase.OnBuilding(mouse, action)
End Sub
'Actions that will be executed when building is complete (like checking if the annotation isn't so small it will become invisible when unselected)
Protected Overrides Sub OnFinishBuilding(ByVal point As System.Drawing.PointF)
MyBase.OnFinishBuilding(point)
CheckAndSetHeight()
CheckAndSetWidth()
End Sub
Private Sub CheckAndSetHeight()
If (Me.Size.Height < 24) Then
Me.Size = New SizeF(Me.Size.Width, 24)
End If
End Sub
Private Sub CheckAndSetWidth()
If (Me.Size.Width < 24) Then
Me.Size = New SizeF(24, Me.Size.Height)
End If
End Sub
End Class
Most alterations on the basic EmbeddedImageAnnotation have to do with setting properties such as border and size. I don't think it's anything out of the ordinary.
Also, a full XML file containing 2 EmbeddedImageAnnotations (it should be a image of an arrow on both occasions):
Code: Select all
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreatorTool>Vintasoft Annotation Library 3.1</xmp:CreatorTool>
<xmp:CreateDate><![CDATA[2011-04-14T15:10:31]]></xmp:CreateDate>
</rdf:Description>
<rdf:Description rdf:about="Vintasoft Annotations" xmlns:xmp="http://ns.adobe.com/xap/4.0/">
<Annotations>
<SymbolAnnotation assembly="ctlAnnotation" namespace="ctlAnnotation">
<Guid type="System.Guid"><![CDATA[ab0441f9-cf6c-4d31-963e-0ce57d2ca2af]]></Guid>
<CreationTime type="System.String"><![CDATA[2011-04-14T15:10:29]]></CreationTime>
<ModifiedTime type="System.String"><![CDATA[2011-04-14T15:10:29]]></ModifiedTime>
<Location type="System.String"><![CDATA[112,69.5]]></Location>
<Rotation type="System.Single">0</Rotation>
<Size type="System.String"><![CDATA[24,24]]></Size>
<Visible type="System.Boolean">True</Visible>
<HorizontalMirrored type="System.Boolean">False</HorizontalMirrored>
<VerticalMirrored type="System.Boolean">False</VerticalMirrored>
<Border type="System.Boolean">False</Border>
<ZOrder type="System.Int32">0</ZOrder>
<BackColor type="System.Int32">-1</BackColor>
<Outline type="Vintasoft.Annotation.AnnotationPen">
<Width type="System.Single">1</Width>
<Color type="System.Drawing.Color">-16777216</Color>
<DashOffset type="System.Single">0</DashOffset>
<MiterLimit type="System.Single">10</MiterLimit>
<Brush type="System.Drawing.Brush">Solid FF000000</Brush>
</Outline>
<Symmetry type="System.Boolean">False</Symmetry>
<Brush type="System.String">Solid FFFFFFFF</Brush>
<ImageData type="System.String"><![CDATA[89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7AF4000000017352474200AECE1CE90000000467414D410000B18F0BFC6105000000206348524D00007A26000080840000FA00000080E8000075300000EA6000003A98000017709CBA513C00000083494441545847ED96510AC03008437BFF4B77F4A32065BA48043BC8605F95E4F1987463E8910119700DCCE9CB5967DE5BA67417D8C0A8F83CA3416CE00A430A9019188C517CC2C3A55FBA334134046360835210155F3A0590D11DCDBE6D535536942300196835D0BA86D79447D73AB4C7D9A1D21BF157E5F69F210BAE7919908146030F66CDC7395BCE56450000000049454E44AE426082]]></ImageData>
</SymbolAnnotation>
<SymbolAnnotation assembly="ctlAnnotation" namespace="ctlAnnotation">
<Guid type="System.Guid"><![CDATA[7132164a-bf9e-44de-b2c2-d8707c933782]]></Guid>
<CreationTime type="System.String"><![CDATA[2011-04-14T15:10:29]]></CreationTime>
<ModifiedTime type="System.String"><![CDATA[2011-04-14T15:10:30]]></ModifiedTime>
<Location type="System.String"><![CDATA[93,29]]></Location>
<Rotation type="System.Single">0</Rotation>
<Size type="System.String"><![CDATA[28,24]]></Size>
<Visible type="System.Boolean">True</Visible>
<HorizontalMirrored type="System.Boolean">False</HorizontalMirrored>
<VerticalMirrored type="System.Boolean">False</VerticalMirrored>
<Border type="System.Boolean">False</Border>
<ZOrder type="System.Int32">0</ZOrder>
<BackColor type="System.Int32">-1</BackColor>
<Outline type="Vintasoft.Annotation.AnnotationPen">
<Width type="System.Single">1</Width>
<Color type="System.Drawing.Color">-16777216</Color>
<DashOffset type="System.Single">0</DashOffset>
<MiterLimit type="System.Single">10</MiterLimit>
<Brush type="System.Drawing.Brush">Solid FF000000</Brush>
</Outline>
<Symmetry type="System.Boolean">False</Symmetry>
<Brush type="System.String">Solid FFFFFFFF</Brush>
<ImageData type="System.String"><![CDATA[89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7AF4000000017352474200AECE1CE90000000467414D410000B18F0BFC6105000000206348524D00007A26000080840000FA00000080E8000075300000EA6000003A98000017709CBA513C00000083494441545847ED96510AC03008437BFF4B77F4A32065BA48043BC8605F95E4F1987463E8910119700DCCE9CB5967DE5BA67417D8C0A8F83CA3416CE00A430A9019188C517CC2C3A55FBA334134046360835210155F3A0590D11DCDBE6D535536942300196835D0BA86D79447D73AB4C7D9A1D21BF157E5F69F210BAE7919908146030F66CDC7395BCE56450000000049454E44AE426082]]></ImageData>
</SymbolAnnotation>
</Annotations>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='r'?>
Re: Loading EmbeddedImageAnnotations from XML
Posted: Tue Apr 26, 2011 4:17 pm
by Yuri
To be successfully deserialized the annotation code must contain constructor without params like below:
Code: Select all
Public Class SymbolAnnotation
Inherits EmbeddedImageAnnotation
...
Public Sub New()
End Sub
...
So we've a bit modificated your code and now you'll be able to deserialize the annotation.
Code: Select all
Imports Vintasoft.Annotation
Public Class SymbolAnnotation
Inherits EmbeddedImageAnnotation
Public File As Bitmap
Private ColorChanger As ColorManager
Public Sub New()
'...
End Sub
Public Sub New(ByVal Image As Bitmap)
ColorChanger = ColorManager.GetInstance()
ColorChanger.File = Image
Me.Image = Image
File = Image
End Sub
Public Overrides Function Clone() As Object
Dim Result As New SymbolAnnotation(File)
CopyTo(Result)
Return Result
End Function
'Executes actions that must be done before the user starts building the annotation (like setting color)
Protected Overrides Sub OnStartBuilding(ByVal point As System.Drawing.PointF)
point = New PointF(point.X + 24, point.Y)
MyBase.OnStartBuilding(point)
Me.Border = False
Me.Image = ColorChanger.ChangeColor()
End Sub
'The actual building
Protected Overrides Sub OnBuilding(ByVal mouse As System.Windows.Forms.MouseEventArgs, ByVal action As Vintasoft.Annotation.MouseActions)
MyBase.OnBuilding(mouse, action)
End Sub
'Actions that will be executed when building is complete (like checking if the annotation isn't so small it will become invisible when unselected)
Protected Overrides Sub OnFinishBuilding(ByVal point As System.Drawing.PointF)
MyBase.OnFinishBuilding(point)
CheckAndSetHeight()
CheckAndSetWidth()
End Sub
Private Sub CheckAndSetHeight()
If (Me.Size.Height < 24) Then
Me.Size = New SizeF(Me.Size.Width, 24)
End If
End Sub
Private Sub CheckAndSetWidth()
If (Me.Size.Width < 24) Then
Me.Size = New SizeF(24, Me.Size.Height)
End If
End Sub
End Class
Re: Loading EmbeddedImageAnnotations from XML
Posted: Wed Apr 27, 2011 10:41 am
by m.zuidhoek
Hello Yuri,
That code worked like a charm! Now i'm able to reload the image annotations.
Thank you very much.
M.Zuidhoek