How do I get the AnnotationIdx of a newly created annot?

Discussions about annotation support.
Post Reply
cavazorro
Posts: 2
Joined: Tue May 15, 2012 5:35 pm

How do I get the AnnotationIdx of a newly created annot?

Post by cavazorro » Tue May 15, 2012 5:52 pm

Hi, I'm writing an application where I let the user create an arrow, I then catch the AnnotationAddedByUser event and add a TextAnnotation (with an annotationManager) that is supposed to be linked or grouped with the arrow such that if the arrow is moved or resized, the text annotation is also moved. The problem is I can't get a handle to the text annotation I created with the annotation manager. I'm trying to find a way to get the AnnotationIdx at the time the text annotation is created, but I can't find it.

I also tried adding the annotationtext to an array and then recover it and edit it, it does change it in the array but not in the gdViewer.

Any help would be greatly appreciated.

Thanks.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: How do I get the AnnotationIdx of a newly created annot?

Post by Loïc » Tue May 15, 2012 10:15 pm

Hello,

The AnnotationIdx parameter is an index between 0 and Annotation count - 1. Therefore, the annotation index of the latest added annotation is equal to the number of annotations less 1.

If you are sill not able to do what you are trying to achieve, just write a code snippet and I will provide some guidance.

Kind regards,

Loïc

cavazorro
Posts: 2
Joined: Tue May 15, 2012 5:35 pm

Re: How do I get the AnnotationIdx of a newly created annot?

Post by cavazorro » Wed May 16, 2012 12:11 am

I found a way of doing it, it would be awesome if the gdviewer had an annotations collection exposed to the programmer. Also, it would be very helpful if the annotations had an Id in addition to the index so that we can reference them directly instead of having to search for it everytime we need to do something with one specific annotation. In this scenario, we can't use the index because the index can change if an annotation is deleted....

All in all, it's a great tool, great job!!!

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: How do I get the AnnotationIdx of a newly created annot?

Post by Loïc » Wed May 16, 2012 9:58 am

Hello,
it would be awesome if the gdviewer had an annotations collection exposed to the programmer.
Hey, have a look here: https://www.gdpicture.com/whats-new-v9.php
GdViewer: new method GetAnnotationManager(). (BETA 9.0.3)
Also, it would be very helpful if the annotations had an Id in addition to the index
There is no sense for that. Since you can get each annotation objects.
In this scenario, we can't use the index because the index can change if an annotation is deleted....
If you get the annotation object there is no problem.

IE:

Code: Select all

Annotation annot = AnnotationManager.GetAnnotationFromIdx(Idx);
All in all, it's a great tool, great job!!!
Thank you! We'll publish the V9 soon. It we be even more better :)

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest