Hi there,
I'm developing a custom drawing engine for the Calendar control - especially for the resource view. Now I've experienced the following problem: in a custom drawing method the passed Bounds-object is interpreted differently when using either a "Draw" method or a "Fill" method.
While the X and Y position is the same for filling and drawing, the width and height is handled differently. So when I'm filling the background for the whole bounds, and after that drawing a rectangle for the whole bounds the two objects do not fit. The "drawn" object is one pixel wider and one pixel higher.
The code I've used for the screenshot is as follows:
var bnd = args.Bounds;
args.Graphics.FillRectangle(Brushes.GreenYellow, bnd);
var p = new Pen(Color.DarkGreen, 1);
p.DashStyle = DashStyle.Dot;
args.Graphics.DrawRectangle(p, bnd);
While this is quite simple to handle for Rectangles etc. it becomes very difficult, when drawing polygones, circles or bitmaps that should be exactly positioned.
Is it possible to provide a bugfix release that interprets the boundings/coordinates exactly the same way for filling and drawing? So that the following code produces exactly two identical shapes:
var pa = new Point[]
{
new Point(bnd.X+bnd.Width/2, bnd.Y),
new Point(bnd.X+bnd.Width, bnd.Y+bnd.Height/2),
new Point(bnd.X+bnd.Width/2, bnd.Y+bnd.Height)
};
args.Graphics.FillPolygon(Brushes.Magenta, pa);
args.Graphics.DrawPolygon(Pens.BlueViolet, pa);
In the current version the shape of the filled polygone is different from the drawn. It would be very handy when both would be the same.
Best regards and have a nice weekend
Achim