Page 1 of 1

DeleteAnnotations question

Posted: Thu Feb 28, 2019 9:53 pm
by reisrf
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

Re: DeleteAnnotations question

Posted: Mon Mar 04, 2019 5:51 pm
by Kamil
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

Re: DeleteAnnotations question

Posted: Mon Mar 04, 2019 7:02 pm
by reisrf
Kamil, many thanks