[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Problem with Rectangle.Inflate

devdiscuss

12/15/2004 4:07:00 PM

I'm having a problem understanding the proper behavior when inflating
rectangles. I'm painting a rectangle which has a variable width,
surrounding border. I also want to paint a selection border around it (for
a simple design surface.)

To paint the rectangle I do the following:

1. Calc the content rectangle --> new Rectangle( Location, Size )
2. Fill the content rectangle
3. Calc the border rectangle --> Rectangle contentRc = Rectangle.Inflate(
contentRc, BorderWidth, BorderWidth )
4. Draw the border rectangle (with a brush the width of the BorderWidth)
5. Calc the selection rectangle (assume its 8 pixels wide) --> Rectangle
selRc = Rectangle.Inflate( contentRc, 8, 8 )
6. Draw the selection rectangle (width 8 pixels)

When I do this... I the 3rd selection rectangle is not correctly aligned
with the 2nd border rect. A small gap exists between the two. Am I missing
something as to how to calculate these rectangles properly?

Thanks!