DeleteAnnotations question

Example requests & Code samples for GdPicture Toolkits.
Post Reply
reisrf
Posts: 27
Joined: Thu May 28, 2015 4:30 pm

DeleteAnnotations question

Post by reisrf » Thu Feb 28, 2019 9:53 pm

I am loading a gdViewer with a TIF and creating many annotations.
the GdViewer is connected to an annotation manager. Annotations are created through the annotation manager

_annotMgr.InitFromGdViewer(gdViewer1);

Then I have tried the following steps to delete all annotations

int qtyAnnotations = _annotMgr.GetAnnotationCount();
if (qtyAnnotations > 0)
{

for (int i = qtyAnnotations - 1; i >= 0; i--)
{
_annotMgr.DeleteAnnotation(i);
}


gdViewer1.Redraw();
}


I can confirm the annotations are deleted, because _annotMgr.GetAnnotationCount() here returns 0.

But the annotation remains displayed in the gdViewer.

Then I have added this code to remove the annotation from gdviewer

qtyAnnotations = gdViewer1.GetAnnotationCount();
if (qtyAnnotations > 0)
{

for (int i = qtyAnnotations - 1; i >= 0; i--)
{
gdViewer1.DeleteAnnotation(i);
}
gdViewer1.Redraw();
}


I thought only the first block of code,iterating and deleting all annotations using the annotation manager would be enough, but is not. I am missing some line?


thanks in advance

Robson Reis

Kamil
Posts: 3
Joined: Mon Mar 04, 2019 5:33 pm

Re: DeleteAnnotations question

Post by Kamil » Mon Mar 04, 2019 5:51 pm

Hello Robson,

The solution here is quite simple. You are just using the wrong way, how to initialize the AnnotationManager object.
You need to replace this line:

_annotMgr.InitFromGdViewer(gdViewer1);

with this line:

AnnotationManager _annotMgr = gdViewer1.GetAnnotationManager();

Now, you don't have to use the second part of your code.

Best regards,
Kamil Dubík
GdPicture Support Team

reisrf
Posts: 27
Joined: Thu May 28, 2015 4:30 pm

Re: DeleteAnnotations question

Post by reisrf » Mon Mar 04, 2019 7:02 pm

Kamil, many thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests