Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic CustomDrawing: Bounds are different for Fill- and Draw-Methods (Read 2319 times)
Achim
Junior Member
**
Offline


MindFusion rocks!

Posts: 70
Location: Bayreuth, Germany
Joined: Jun 28th, 2012
CustomDrawing: Bounds are different for Fill- and Draw-Methods
Jan 25th, 2013 at 1:20pm
Print Post  
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:

Code
Select All
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:

Code
Select All
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
  

Bildschirmfoto_2013-01-25_um_14_04_56_Kopie.png (Attachment deleted)
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: CustomDrawing: Bounds are different for Fill- and Draw-Methods
Reply #1 - Jan 25th, 2013 at 2:16pm
Print Post  
Hi,

Unfortunately this is a 'feature' of the GDI+ engine. Our GdiGraphics implementation simply redirects the calls to a true .NET Graphics instance, which performs the actual painting. You can check a discussion about it here.

I wish I could provide you with a better solution, but the only thing I can think of is to adjust the bounds with one pixel before calling the Draw methods.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint