Page 1 of 1

Custom draw on RectangularSelection

Posted: Mon Jul 17, 2017 4:20 pm
by SebastianB
Hello,

I am building an application based on the ImageViewer Control where you can add several selections using the MultiRectangularSelectionTool. To manage extra information for each selection I created a derived class of RectangularSelection. This part works fine.

I want to draw some text (later a small icon as well) when the RectangularSelection is drawn. I am overriding Draw(). But I got stuck, even with looking into the examples I cannot find any solution to draw into selection. Some text is drawn, but left in the top left corner of the ImageViewer or just moving some pixels when the SelectionTool is moved. Even though the ClipBound of the Graphics objects from the overridden Draw-Method are looking weird.
I have no control of where the text in drawn. Here is the latest piece of code I have tried:

Code: Select all

var rect = ((RectangularObjectTransformer) base.Transformer).InteractiveObject.GetBoundingBox();
var x = rect.X;
var y = rect.Y;
g.DrawString(base.SelectedRect.ToString(), new Font("Arial", 8), new SolidBrush(Color.Red), x,y);
I guess I am pretty close but I don't know in which direction I should proceed.

Thanks for your help!
Sebastian

Re: Custom draw on RectangularSelection

Posted: Mon Jul 17, 2017 4:42 pm
by SebastianB
I found the solution by myself.
I called base.Draw() at the beginning of the overridden Draw-method. This is not correct.
After calling the base.Draw() after my custom draw operations it worked fine.

Re: Custom draw on RectangularSelection

Posted: Mon Jul 17, 2017 4:55 pm
by Alex
Hello Sebastian,

Thank you for information.

Best regards, Alexander