❔ windows form line drawing problem
code:
private void ConnectCircles()
{
for (int i = 0; i < dots.Count - 1; i++)
{
AddAbsoluteSplineWaypoints(dots[i], dots[i + 1]);
}
using (Graphics g = Graphics.FromImage(drawingBitmap))
{
Pen pen = new Pen(Color.Blue, 2);
g.SmoothingMode = SmoothingMode.AntiAlias;
for (int i = 0; i < newDots.Count - 1; i++)
{
string[] waypoint = newDots[i].Split(',');
double x = double.Parse(waypoint[0].Trim());
double y = double.Parse(waypoint[1].Trim());
string[] waypoint2 = newDots[i + 1].Split(',');
double x2 = double.Parse(waypoint2[0].Trim()); // Use waypoint2 instead of waypoint
double y2 = double.Parse(waypoint2[1].Trim()); // Use waypoint2 instead of waypoint
Dot thing = new Dot(x, y);
Console.WriteLine(thing);
Dot thing2 = new Dot(x2, y2);
Console.WriteLine(thing2.X + ", " + thing2.Y);
Point startPoint = new Point((int)Math.Round(thing.X * pictureBox1.Width / (FieldWidthFeet * FeetToInchesConversion)),
(int)Math.Round(thing.Y * pictureBox1.Height / (FieldHeightFeet * FeetToInchesConversion))
);
Point endPoint = new Point(
(int)Math.Round(thing2.X * pictureBox1.Width / (FieldWidthFeet * FeetToInchesConversion)),
(int)Math.Round(thing2.Y * pictureBox1.Height / (FieldHeightFeet * FeetToInchesConversion))
);
pen.Color = Color.Green;
g.DrawLine(pen, startPoint, endPoint);
}
}
pictureBox1.Image = drawingBitmap;
pictureBox1.Invalidate();
} private void ConnectCircles()
{
for (int i = 0; i < dots.Count - 1; i++)
{
AddAbsoluteSplineWaypoints(dots[i], dots[i + 1]);
}
using (Graphics g = Graphics.FromImage(drawingBitmap))
{
Pen pen = new Pen(Color.Blue, 2);
g.SmoothingMode = SmoothingMode.AntiAlias;
for (int i = 0; i < newDots.Count - 1; i++)
{
string[] waypoint = newDots[i].Split(',');
double x = double.Parse(waypoint[0].Trim());
double y = double.Parse(waypoint[1].Trim());
string[] waypoint2 = newDots[i + 1].Split(',');
double x2 = double.Parse(waypoint2[0].Trim()); // Use waypoint2 instead of waypoint
double y2 = double.Parse(waypoint2[1].Trim()); // Use waypoint2 instead of waypoint
Dot thing = new Dot(x, y);
Console.WriteLine(thing);
Dot thing2 = new Dot(x2, y2);
Console.WriteLine(thing2.X + ", " + thing2.Y);
Point startPoint = new Point((int)Math.Round(thing.X * pictureBox1.Width / (FieldWidthFeet * FeetToInchesConversion)),
(int)Math.Round(thing.Y * pictureBox1.Height / (FieldHeightFeet * FeetToInchesConversion))
);
Point endPoint = new Point(
(int)Math.Round(thing2.X * pictureBox1.Width / (FieldWidthFeet * FeetToInchesConversion)),
(int)Math.Round(thing2.Y * pictureBox1.Height / (FieldHeightFeet * FeetToInchesConversion))
);
pen.Color = Color.Green;
g.DrawLine(pen, startPoint, endPoint);
}
}
pictureBox1.Image = drawingBitmap;
pictureBox1.Invalidate();
}