Picture上画 (有点闪动,以后再想办法)
public partial class Form2 : Form
{
	public Form2()
	{
		InitializeComponent();
		this.Load += Form2_Load;
	}
	private void Form2_Load(object sender, EventArgs e)
	{
		//bmpOriginal = new Bitmap(@"F:\test_netcore\ConsoleApp3\img\202205271132367.jpg");
		//bmp = new Bitmap(@"F:\test_netcore\ConsoleApp3\img\202205271132367.jpg");
		bmp = Properties.Resources._202205271132367A;
		//pictureBox1.Image = bmp;
		//g = Graphics.FromImage(bmp);
		g = pictureBox1.CreateGraphics();
		gBmp = Graphics.FromImage(bmp);
		pen = new Pen(Color.Black);
		pen.Width = 3;
		pen.Color = Color.Blue;
		//pen2 = new Pen(this.BackColor);
		pen2 = new Pen(pictureBox1.BackColor);
		pen2.Width = 3;
		points = new List<Point>();
		pointsArr = new List<List<Point>>();
		pictureBox1.Image = bmp;
	}
	bool startFlag = false;
	bool cancelFalg = true;
	Point point1, point2;
	List<Point> points, points_dc;  //points_dc用作深拷贝
	List<List<Point>> pointsArr;
	Graphics g, gBmp;
	Pen pen, pen2;
	Bitmap bmp, bmpOriginal;
	//Color bmpForeColor;
	private void button1_Click(object sender, EventArgs e)
	{
		if (cancelFalg)
		{
			this.button1.Text = "不画了";
			cancelFalg = false;
			startFlag = false;
			//points.Clear();
			if (points.Count > 0)
			{
				pointsArr.Add(points);
				points.Clear();
			}
		}
		else
		{
			this.button1.Text = "开始画";
			cancelFalg = true;
		}
	}
	private void button2_Click(object sender, EventArgs e)
	{
		pictureBox1.Image = bmp;
	}
	private void pictureBox1_Paint(object sender, PaintEventArgs e)
	{
		//this.pictureBox1.Refresh();
	}
	private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
	{
		if (cancelFalg) return;
		if (e.Button == MouseButtons.Left)
		{
			if (!startFlag) //第一次按下鼠标
			{
				startFlag = true;
				point1 = e.Location;
				points.Add(point1);
			}
			else //第二次按下鼠标
			{
				point2 = e.Location;
				g.DrawLine(pen, point1, point2);
				//也写到图片中去
				gBmp.DrawLine(pen, point1, point2);
				points.Add(point2);
				point1 = e.Location;
					
			}
		}
		else
		{
			if (points.Count == 0) return;
			int length = points.Count;
			//g.DrawLine(pen2, points[length - 1], point2);	//这里不需要了, 因移动的线都没有真正画上去
			startFlag = false;
			if (points.Count >= 2)
			{
				points_dc = new List<Point>();
				points_dc = Clone(points);
				pointsArr.Add(points_dc);
			}
			points.Clear();
			//右击时所有多边形重新画一遍(在picturebox上)
			if (pointsArr.Count > 0)
			{
				for (int i = 0; i < pointsArr.Count; i++)
				{
					g.DrawLines(pen, pointsArr[i].ToArray());
				}
			}
			//右击的时候也写到图片中去
			if (pointsArr.Count > 0)
			{
				for (int i = 0; i < pointsArr.Count; i++)
				{
					gBmp.DrawLines(pen, pointsArr[i].ToArray());
				}
			}
		}
	}
	private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
	{
		if (cancelFalg) return;
		if (!startFlag) return;
		g.DrawLine(pen, point1, e.Location);
		pictureBox1.Invalidate();
		//pictureBox1.Refresh(); 或者都可以
	}
	public List<Point> Clone(List<Point> inputList)
	{
		BinaryFormatter bf = new BinaryFormatter();
		using (MemoryStream ms = new MemoryStream())
		{
			bf.Serialize(ms, inputList);
			ms.Position = 0;
			return bf.Deserialize(ms) as List<Point>;
		}
	}
	//public <T> Clone(<T> inputList)
	//{
	//	BinaryFormatter bf = new BinaryFormatter();
	//	using (MemoryStream ms = new MemoryStream())
	//	{
	//		bf.Serialize(ms, inputList);
	//		ms.Position = 0;
	//		return bf.Deserialize(ms) as List<Point>;
	//	}
	//}
	//public List<T> ListClone(List<T> inputList)
	//{
	//	BinaryFormatter Formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
	//	System.IO.MemoryStream stream = new System.IO.MemoryStream();
	//	Formatter.Serialize(stream, inputList);
	//	stream.Position = 0;
	//	List<T> outList = Formatter.Deserialize(stream) as List<T>;
	//	stream.Close();
	//	return outList;
	//}
}
窗体上画
public partial class Form1 : Form
{
	public Form1()
	{
		InitializeComponent();
		this.Load += Form1_Load;
	}
	private void Form1_Load(object sender, EventArgs e)
	{
		g = this.CreateGraphics();
		pen = new Pen(Color.Black);
		pen.Width = 3;
		pen.Color = Color.Blue;
		pen2 = new Pen(this.BackColor);
		pen2.Width = 3;
		points = new List<Point>();
		pointsArr = new List<List<Point>>();
			
	}
	bool startFlag = false;
	bool cancelFalg = true;
	Point point1, point2;
	List<Point> points, points_dc;	//points_dc用作深拷贝
	List<List<Point>> pointsArr;
	Graphics g;
	Pen pen, pen2;
	private void button1_Click(object sender, EventArgs e)
	{
		if (cancelFalg)
		{
			this.button1.Text = "不画了";
			cancelFalg = false;
			startFlag = false;
			//points.Clear();
			if (points.Count > 0)
			{
				pointsArr.Add(points);
				points.Clear();
			}
		}
		else
		{
			this.button1.Text = "开始画";
			cancelFalg = true;
		}
	}
	private void Form1_MouseMove(object sender, MouseEventArgs e)
	{
		if (cancelFalg) return;
		if (!startFlag) return;
		g.DrawLine(pen2, point1, point2);
		point2.X = e.X;
		point2.Y = e.Y;
		g.DrawLine(pen, point1, point2);
		if (points.Count <= 1) //当前画的多边形只有一个点的情况下
		{
			//如果已经有画过多边形
			if (pointsArr.Count > 0)
			{
				for (int i = 0; i < pointsArr.Count; i++)
				{
					g.DrawLines(pen, pointsArr[i].ToArray());
				}
			}
			return;
		}
		g.DrawLines(pen, points.ToArray());
		//如果已经有画过多边形
		if (pointsArr.Count > 0)
		{
			for (int i = 0; i < pointsArr.Count; i++)
			{
				g.DrawLines(pen, pointsArr[i].ToArray());
			}
		}
	}
		
	private void Form1_MouseClick(object sender, MouseEventArgs e)
	{
		if (cancelFalg) return;
		if (e.Button == MouseButtons.Left)
		{
			if (!startFlag) //第一次按下鼠标
			{
				startFlag = true;
				point1.X = e.X;
				point1.Y = e.Y;
				points.Add(point1);
			}
			else //第二次按下鼠标
			{
				point2.X = e.X;
				point2.Y = e.Y;
				g.DrawLine(pen, point1, point2);
				points.Add(point2);
				point1.X = point2.X;
				point1.Y = point2.Y;
			}
		}
		else
		{
			if (points.Count == 0 ) return;
			int length = points.Count;
			g.DrawLine(pen2, points[length - 1], point2);
			startFlag = false;
			if (points.Count >= 2)
			{
				points_dc = new List<Point>();
				points_dc = Clone(points);
				pointsArr.Add(points_dc);
			}
			points.Clear();
			//右击之后再画一遍,要不然还是有涂掉一些
			if (pointsArr.Count > 0)
			{
				for (int i = 0; i < pointsArr.Count; i++)
				{
					g.DrawLines(pen, pointsArr[i].ToArray());
				}
			}
		}
	}
	public List<Point> Clone(List<Point> inputList)
	{
		BinaryFormatter bf = new BinaryFormatter();
		using(MemoryStream ms = new MemoryStream())
		{
			bf.Serialize(ms, inputList);
			ms.Position = 0;
			return bf.Deserialize(ms) as List<Point>;
		}
	}
	//public <T> Clone(<T> inputList)
	//{
	//	BinaryFormatter bf = new BinaryFormatter();
	//	using (MemoryStream ms = new MemoryStream())
	//	{
	//		bf.Serialize(ms, inputList);
	//		ms.Position = 0;
	//		return bf.Deserialize(ms) as List<Point>;
	//	}
	//}
	//public List<T> ListClone(List<T> inputList)
	//{
	//	BinaryFormatter Formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
	//	System.IO.MemoryStream stream = new System.IO.MemoryStream();
	//	Formatter.Serialize(stream, inputList);
	//	stream.Position = 0;
	//	List<T> outList = Formatter.Deserialize(stream) as List<T>;
	//	stream.Close();
	//	return outList;
	//}
}