Hello,
Ok. How to describe my problem :-/
I'm making a 2D drawing program. Currently working on lines.
So I got a class line which holds the draw method.
And I've created a list of lines + a line object.
In the form I have a listbox where every line is added.
And when I doubleclick on an item in the listbox I want the program to draw the clicked line on pictureBox1.
What happends now is that I am able to draw lines, and each line is added to the lines list and listBox1. But nothing happends when I doubleclick an item in listBox1.
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
mouseDownPoint = new Point(e.X, e.Y);
listBox1.SelectedIndex = -1;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
toolStripStatusLabel3.Text = "X: " + e.X + " Y: " + e.Y;
if (e.Button == MouseButtons.Left)
{
if (drawLineBtn.Checked)
{
line.P1 = mouseDownPoint;
line.P2 = new Point(e.X, e.Y);
pictureBox1.Invalidate();
}
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (drawLineBtn.Checked)
{
listBox1.Items.Add(line);
lines.Add(line);
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if (listBox1.SelectedIndex == -1)
line.Draw(e.Graphics);
else if (listBox1.SelectedIndex != -1)
lines[listBox1.SelectedIndex].Draw(e.Graphics);
}
private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
pictureBox1.Invalidate();
}