Custom draw on RectangularSelection

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Moderator: Alex

Post Reply
SebastianB
Posts: 20
Joined: Thu Sep 27, 2012 12:39 pm

Custom draw on RectangularSelection

Post 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
SebastianB
Posts: 20
Joined: Thu Sep 27, 2012 12:39 pm

Re: Custom draw on RectangularSelection

Post 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.
Alex
Site Admin
Posts: 2300
Joined: Thu Jul 10, 2008 2:21 pm

Re: Custom draw on RectangularSelection

Post by Alex »

Hello Sebastian,

Thank you for information.

Best regards, Alexander
Post Reply