Page 1 of 1

Howto set the postion of Textannotation.Textbox

Posted: Fri Feb 17, 2012 10:44 am
by MichaelHerrmanns
Hello,

I have a question of howto positioning the textbox of an textannotation.
When I use the location propety of the textannotation, then sometimes depending on the resolution of the picture
the textbox appears on the right place. In other times the textbox appears somewhere.

The reason of my question is, that I want to open the textbox even when the textannotation is buildet.
viewtopic.php?f=16&t=1722
In other situations (the user edit the text) the textbox everytime appears on the right place.

Best regards

Michael

Re: Howto set the postion of Textannotation.Textbox

Posted: Fri Feb 17, 2012 4:04 pm
by Alex
Hello Michael,

You can use the PointToControl method of the ImageViewer class and determine coordinates of left-top corner of annotation in the viewer space:

Code: Select all

Point leftTop = new Point((int)(textAnno.Location.X - textAnno.Size.Width / 2), (int)(textAnno.Location.Y - textAnno.Size.Height / 2));
textBox.Location = viewer.PointToControl(leftTop);
Best regards, Alexander

Re: Howto set the postion of Textannotation.Textbox

Posted: Mon Feb 20, 2012 11:50 am
by MichaelHerrmanns
Hello Alex,

it works perfectly.
Thank you very much.

best regards

Michael