Rectangle in pixel, user coordinates in mm, TODO-draw the pointscorrect.

A

Andreas Ott

Picture:
http://www1.minpic.de/bild_anzeigen.php?id=77964&key=8973453&ende

Project:
http://www.fileuploadx.de/478056

Hello,

I have a rectangle in pixels.
There I would like to draw a rectangle in mm in correct relation to
the panel.

Question: Transformation pixel in mm, see above.

My problem, understanding problem, how I get that now it?

If rectangle is ok, which define zero point, draw.
If that is ok, the list with points draws.

Finished .

Thanks.

Greeting Andreas



private void panelInput_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
int counter = 1;

Font drawFont = new Font("Arial", 10);
SolidBrush drawBrush = new SolidBrush(Color.Black);

// Pixel vom Panel ermitteln
int pixelLeft = panelInput.Left;
int pixelTop = panelInput.Top;
int pixelRight = panelInput.Right;
int pixelBottom = panelInput.Bottom;

// Außenmaße einholen
Maß abmessungen = produkt.Maße[0];

g.PageUnit = GraphicsUnit.Millimeter;

// Rechteck in das Panel zeichnen
// Create pen.
Pen redPen = new Pen(Color.Red, 20);
g.DrawRectangle(Pens.Red, FactorZollMillimeter *
abmessungen.X1,
FactorZollMillimeter *
abmessungen.Y1,
FactorZollMillimeter *
abmessungen.X2,
FactorZollMillimeter *
abmessungen.Y2);


Matrix mHelp = new Matrix();
// Verschiebung ?=
// mHelp.Translate(- 1, 0);

mHelp.Scale(-g.DpiX / FactorZollMillimeter, g.DpiY /
FactorZollMillimeter);
g.Transform = mHelp;



foreach (Punkt p in produkt.Punkte)
{
// ** Umrechnung mm in pixel
ZeichneKreuz(g, p, 10);
g.DrawString(counter.ToString(), drawFont, drawBrush,
p.X + 3, p.Y + 3);
counter++;
}
}
 
Top