J
Jon Slaughter
How does DrawRectangle position a rectangle w.r.t to the Rectangle passed?
Lets suppose I use a pen of width 5. Are the lines centered about the passed
Rectangle or is it enclosed or offset? Are there ways to change the default
behavior?
The reason I ask is cause when I do
g.DrawRectangle(P, this.ClientRectangle) for drawing a rectangle as the
border for a control(button) and the width of P is larger than 1(or even
when its not it still looks wrong) the lines thickness is not what its
suppose to be,
Basically my code is
g.FillRegion(B, this.Region);
g.DrawRectangle(S, r1);
g.DrawRectangle(H, r2);
which draws two rectangles as the "border" for a button control. S and H are
pens for shadow and highlight.
my code for the rectangles is something like
Rectangle r1 = new Rectangle(2, 2, this.Width-x-2, this.Height-x-2);
Rectangle r2 = new Rectangle(1 + x+1+1, 1 + x+1+1, this.Width - x - 1 -
x-y-2-2, this.Height - x - 1 - x-y-2-2);
were x is the pens with. the values are not correct now as I was playing
around with them to see try and get it right.
Basicaly my first border would be (0,0, this.Width, this.Height) but because
of the way its draw I have to offset it some. the second border would then
be draw on the inside of this rectangle.
What I essentially want is to draw a rectangle that is interior to the pass
rectangle parameter and not where the lines of the rectangle are centered on
it. For larger pens it will should still be on the interior.
Its not to hard to convert from one method to the other if I knew which one
it used. Although there is the slight problem with rounding for pens of odd
width.
Thanks,
Jon
Lets suppose I use a pen of width 5. Are the lines centered about the passed
Rectangle or is it enclosed or offset? Are there ways to change the default
behavior?
The reason I ask is cause when I do
g.DrawRectangle(P, this.ClientRectangle) for drawing a rectangle as the
border for a control(button) and the width of P is larger than 1(or even
when its not it still looks wrong) the lines thickness is not what its
suppose to be,
Basically my code is
g.FillRegion(B, this.Region);
g.DrawRectangle(S, r1);
g.DrawRectangle(H, r2);
which draws two rectangles as the "border" for a button control. S and H are
pens for shadow and highlight.
my code for the rectangles is something like
Rectangle r1 = new Rectangle(2, 2, this.Width-x-2, this.Height-x-2);
Rectangle r2 = new Rectangle(1 + x+1+1, 1 + x+1+1, this.Width - x - 1 -
x-y-2-2, this.Height - x - 1 - x-y-2-2);
were x is the pens with. the values are not correct now as I was playing
around with them to see try and get it right.
Basicaly my first border would be (0,0, this.Width, this.Height) but because
of the way its draw I have to offset it some. the second border would then
be draw on the inside of this rectangle.
What I essentially want is to draw a rectangle that is interior to the pass
rectangle parameter and not where the lines of the rectangle are centered on
it. For larger pens it will should still be on the interior.
Its not to hard to convert from one method to the other if I knew which one
it used. Although there is the slight problem with rounding for pens of odd
width.
Thanks,
Jon