Hello,
I need to custom draw the cells of my table nodes.
The problem I encounter is related (I think) with the Diagram.PageUnit which is set to the default millimeter in my app. And I want in my custom draw cell event handler to draw a line by 1 pixel width:
e.Graphics.DrawLine(new Pen(e.Table.Pen.Color),
new PointF(e.Bounds.Left, e.Bounds.Bottom), new PointF(e.Bounds.Right, e.Bounds.Bottom));
But the drawn line appears to be 3 pixels wide. That's I abelive because the diagram has its PageUnit set to millimeter. A I can't change the diagram PageUnit (all distances are already set in code using millimeters), how can I draw 1 pixel wide lines here?
I've tried the following but the the lines were not properly positioned inside the table:
e.Graphics.PageUnit = GraphicsUnit.Pixel;
float DpmX = e.Graphics.DpiX / MM_PER_INCH;
float DpmY = e.Graphics.DpiY / MM_PER_INCH;
float boundsLeftDots = e.Bounds.Left * DpmX;
float boundsRightDots = e.Bounds.Right * DpmX;
float boundsBottomDots = e.Bounds.Bottom * DpmY;
e.Graphics.DrawLine(new Pen(e.Table.Pen.Color),
new PointF(boundsLeftDots, boundsBottomDots - 1), new PointF(boundsRightDots, boundsBottomDots - 1));
e.Graphics.DrawLine(new Pen(Color.White),
new PointF(boundsLeftDots, boundsBottomDots), new PointF(boundsRightDots, boundsBottomDots));
e.Graphics.PageUnit = GraphicsUnit.Millimeter;
where
private const float MM_PER_INCH = 25.4F;
So, I've tried to convert all the dimensions from MM to pixels, draw the lines (I wand a shadow like border cell) and the return to the default PageUnit.
But it doesn't seems to work like this.
So, how can I draw in "pixel" mode in the custom draw event handler even the diagram's PageUnit is set to Millimeter?
Thanks,
Bogdan