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
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.
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):
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