sasa lazic

sasa lazic

  • NA
  • 104
  • 50.1k

Draw Polygon

Oct 23 2015 7:15 AM
Hello,
 
I cant draw polygon using system Drawing.
 
My Coordinates
 Name Y X H
5 0592612.238 0758030.902 1520.23
22 0592571.590 0758534.210 152.25
23 0592612.269 0758575.110 654.05
25 0592604.649 0758680.098 382.14
28 0592384.293 0758597.392 548.45
34 0592155.367 0758760.827 12.21
35 0592061.813 0758730.954 98.34
5 0592612.238 0758030.902 874.15
 
 this moment i am using only Y and X coord.
 
my code
brTacaka - is means number of point 
ime - is means point name
tacke3D - is class for reading file with coordinates 
 
int brTacaka = tacke3D.Count(i => i.ime != "");
System.Drawing.Graphics g;
Point[] p = new Point[brTacaka];
System.Drawing.Pen pen1 = new System.Drawing.Pen(Color.Blue, 2F);
List<double> minimumX = new List<double>();
List<double> minimumY = new List<double>();
for (int i = 0; i < brTacaka; i++)
{
minimumX.Add(tacke3D[i].x);
minimumY.Add(tacke3D[i].y);
}
double minX = minimumX.Min();
double minY = minimumY.Min();
for (int i = 0; i < brTacaka; i++)
{
int a = Convert.ToInt32(tacke3D[i].y - minY);
int b = Convert.ToInt32(tacke3D[i].x - minX);
p[i] = new Point(a, b);
}
g = pictureBox1.CreateGraphics();
g.DrawPolygon(pen1, p);
 
 
Picture box Weidght 485, Height 331
 
Where is the problem
 
Thanks in advance