1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
//Frist we need to create a matrix
Matrix m = new Matrix();
//-----
// then we need to prepare the needed trasformation
m.Translate(-(int)minX_Window,-(int)minY_Window,MatrixOrder.Append);
m.Scale( (int)(viewPort.Width / (maxX_Window - minX_Window)),(int)(-viewPort.Height / (maxY_Window - minY_Window)), MatrixOrder.Append);
m.Translate(viewPort.Left, viewPort.Top + viewPort.Height, MatrixOrder.Append);
// we apply the trasformation to the array of points that we need in the graphics
m.TransformPoints(myPoints );
// in the end we can write the point to the graphics (THIS IS AN EXAMPLE FROM MY IMPLEMENTATION)
foreach(PointF punto in myPoints)
{
if (myPointsreal[i].X <= maxX_Window && myPointsreal[i].Y <= maxY_Window)
{
g.FillEllipse(Brushes.Black, new Rectangle(new Point((int)(punto.X - 2), (int)(punto.Y - 2)), new Size(4, 4)));
g.DrawString(myPointsreal[i].ToString(), new Font("Arial", 10), Brushes.Black,(int)(punto.X), (int)(punto.Y));
g.FillEllipse(Brushes.Red, new Rectangle(new Point((int)(punto.X - 2), (int)(viewPort.Y + viewPort.Height - 2)), new Size(4, 4)));
g.FillEllipse(Brushes.Red, new Rectangle(new Point((int)(viewPort.X), (int)(int)(punto.Y - 2)), new Size(4, 4)));
}
}
|