Page 1 of 1

Set Annotation visible false

Posted: Mon Aug 22, 2011 3:22 pm
by MichaelHerrmanns
Hello,

I want to write a function to switch all annotations of a image to visible false or true.
For this I use this code:

Code: Select all

Dim images As ImageCollection = AnnotationViewer1.Images
        Dim annotations As AnnotationController = New AnnotationController(images)
        Dim imageIndex As Integer, annoIndex As Integer
        For imageIndex = 0 To images.Count - 1
            Dim imageAnnotations As AnnotationCollection = annotations(imageIndex)
            For annoIndex = 0 To imageAnnotations.Count - 1
                Debug.Print(imageAnnotations(annoIndex).Visible.ToString)

                imageAnnotations(annoIndex).Visible = Not imageAnnotations(annoIndex).Visible

            Next annoIndex
        Next imageIndex
But I must reload the image to see the annoations visible false/true.

Any idea

regards
Michael

Re: Set Annotation visible false

Posted: Tue Aug 23, 2011 12:49 pm
by Alex
Hello Michael,

Your code has logical mistake - you need to use annotation controller associated with annotation viewer instead of creating new annotation controller.

Here is your code:

Code: Select all

Dim annotations As AnnotationController = New AnnotationController(images)
and here is correct code:

Code: Select all

Dim annotations As AnnotationController = annotationViewer1.Annotations
Best regards, Alexander

Re: Set Annotation visible false

Posted: Wed Nov 09, 2011 4:17 pm
by MichaelHerrmanns
Hello Alex,

Thank you very much.

Now it is working.

Best regards

Michael