Page 1 of 1

Annotation outline disappearing

Posted: Wed Feb 05, 2020 4:36 pm
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)
    { }
}

Re: Annotation outline disappearing

Posted: Thu Feb 06, 2020 9:41 am
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

Re: Annotation outline disappearing

Posted: Thu Feb 06, 2020 11:41 am
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.

Re: Annotation outline disappearing

Posted: Thu Feb 06, 2020 12:45 pm
by missionRoom
I've sent a simple example project to the support email. Thanks

Re: Annotation outline disappearing

Posted: Fri Feb 07, 2020 10:45 am
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