Hi, Assume drawing a house on the lower left corner of one form:
protected override void OnPaint(PaintEventArgs e)
{
float zoom = 1F;
e.Graphics.Transform = new System.Drawing.Drawing2D.Matrix(
new System.Drawing.RectangleF(0, 0, Width, Height),
new System.Drawing.PointF[]{
new System.Drawing.PointF(0,Height/zoom),
new System.Drawing.PointF(Width/zoom,Height/zoom),
new System.Drawing.PointF(0,0)});
Pen p = new Pen(Color.Black, 1);
e.Graphics.DrawLine(p, 0, 0, 100, 0);
e.Graphics.DrawLine(p, 100, 0, 100, 100);
e.Graphics.DrawLine(p, 100, 100, 0, 100);
e.Graphics.DrawLine(p, 0, 100, 0, 0);
e.Graphics.DrawLine(p, 0, 100, 50, 150);
e.Graphics.DrawLine(p, 50, 150, 100, 100);
}
My problem is that with this transformation some parts of that house will disappear. And if I set zoom to something other than 1, the house will move on the form. Can anybody please say where is my fault?
View Complete Post