Hi i would like to know how can i get points from the second line i draw. Here is my code, for now i can draw lines with mouse event and draw lines with a button where i write the coordinates of the points. public partial class Form1 : Form { Graphics drawArea; private Point p1, p2; List p1List = new List(); List p2List = new List();
public Form1()
{
InitializeComponent();
drawArea = panel1.CreateGraphics();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics graphicsObj;
graphicsObj = CreateGraphics();
Pen p = new Pen(System.Drawing.Color.Black, 1);
for (int x = 0; x < p1List.Count; x++)
{
drawArea.DrawLine(p, p1List[x], p2List[x]);
}
}
private void button1_Click(object sender, EventArgs e)
{
p1.X = Convert.ToInt32(textBox1.Text);
p1.Y = Convert.ToInt32(textBox3.Text);
p2.X = Convert.ToInt32(textBox2.Text);
p2.Y = Convert.ToInt32(textBox4.Text);
Pen p = new Pen(System.Drawing.Color.Black, 2);
drawArea.DrawLine(p, p1.X, p1.Y, p2.X, p2.Y);
}
void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (p1.X == 0)
{
p1.X = e.X;
p1.Y = e.Y;
}
else
{
p2.X = e.X;
p2.Y = e.Y;
p1List.Add(p1);
p2List.Add(p2);
panel1.Invalidate();
p1.X = 0;
}
}
}
}