You don't want to clear the graphic click in the new menu item.
You cleaned up picturebox in the paint incident.
You set a flag, such as bool creatNew = false.
Private void new toolstrip menuitem _ click (object sender, eventarges e)
{
= true
pictureBox 1。 Refresh ();
}
In the paint incident,
If (create a new)
{
e.graphics . Clear();
}
If you draw a picture, you'd better draw it in the drawing event.
In addition, when you clear the picture, the data elements of your storage line such as line[k, 2] should also be cleared, otherwise it will still be drawn in.
It is best to use a list or queue to store the elements to be drawn, then empty them in the paint event, and then draw everything in it.
the second question
You'd better define the category of lines.
It includes start coordinates, end coordinates and color.
The line class can inherit the shape class, so you can do the same if you want to expand the drawing function in the future.
Don't use public brushes. If you use a common brush, one color changes, and of course all colors change.