Annotation outline disappearing

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

Moderator: Alex

Post Reply
missionRoom
Posts: 12
Joined: Wed Jan 22, 2020 4:38 pm

Annotation outline disappearing

Post by missionRoom »

I'm saving the current annotation data to an object, and restoring it at a later date. But sometimes the outline is disappearing, it is part of the object when I save it but, but when I restore it, it's sometimes null. Any idea why this might be happening?

Thanks for any help,

Saving

Code: Select all

public void AnnotationsChanged(AnnotationDataController annotationDataController)
{
    this._annotationDatas = new List<AnnotationDataCollection>();

    for (int i = 0; i < annotationDataController.Images.Count; i++)
    {
        AnnotationDataCollection annotatonDataCollection = annotationDataController.GetAnnotations(i);
        this._annotationDatas.Add((AnnotationDataCollection)annotatonDataCollection.Clone());
    }
}
Restoring

Code: Select all

private void LoadAnnotationsFromDisk()
{
    try
    {
        if (DataManager.Instance.AnnotationDatas != null && DataManager.Instance.AnnotationDatas.Count > this.annotationViewer.FocusedIndex)
        {
            if (DataManager.Instance.AnnotationDatas[this.annotationViewer.FocusedIndex].Count > 0)
            {
                foreach(AnnotationData annotationData in DataManager.Instance.AnnotationDatas[this.annotationViewer.FocusedIndex])
                {
                    try
                    {
                        if (!this.annotationViewer.AnnotationDataCollection.Contains(annotationData))
                            this.annotationViewer.AnnotationDataCollection.Add(annotationData);
                    }
                    catch(Exception ex)
                    { }
                }
            }
        }
    }
    catch (Exception ex)
    { }
}
Alex
Site Admin
Posts: 1975
Joined: Thu Jul 10, 2008 2:21 pm

Re: Annotation outline disappearing

Post by Alex »

Hello,

Unfortunately, provided code does not allow to understand the problem.

How do you serialize annotations? If you are saving annotation into XMP packet, please analyze saved XMP packet and check if annotation contains information about outline. If you are saving annotation not into XMP packet, please save annotation in XMP packet and analyze saved XMP packet.

Please send us (to support@vintasoft.com) a small project, which allows to reproduce the problem, if you cannot solve the problem by yourself.

Best regards, Alexander
missionRoom
Posts: 12
Joined: Wed Jan 22, 2020 4:38 pm

Re: Annotation outline disappearing

Post by missionRoom »

I'm actually not saving the annotation to a file (it's a poorly named method). I'm just saving it in memory, changing the image collection on the viewer, then changing it back to the original image collection and restoring the annotations from the AnnotationDataCollection. Somewhere in that, the outline is disappearing, all other properties are still there.
missionRoom
Posts: 12
Joined: Wed Jan 22, 2020 4:38 pm

Re: Annotation outline disappearing

Post by missionRoom »

I've sent a simple example project to the support email. Thanks
Alex
Site Admin
Posts: 1975
Joined: Thu Jul 10, 2008 2:21 pm

Re: Annotation outline disappearing

Post by Alex »

Hello,

Thank you for sample project, we reproduced the problem.

When you adding annotation to the annotation collection of annotation viewer, annotation viewer takes control over annotation.
When you closing images in annotation viewer, annotation viewer disposes images and annotations.
Disposed annotation does not have Outline.

For solving the problem you need to clone annotation before adding it to the annotation collection of annotation viewer.

Please change code:

Code: Select all

if (!this.annotationViewer1.AnnotationDataCollection.Contains(annotationData) && annotationData.Outline != null)
   this.annotationViewer1.AnnotationDataCollection.Add(annotationData);
to the following code:

Code: Select all

this.annotationViewer1.AnnotationDataCollection.Add((AnnotationData)annotationData.Clone());
Best regards, Alexander
Post Reply