程序代码: private Point LastPoint { get; set; }
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
label2.Text = "x:" + e.X;
label3.Text = "y:" + e.Y;
if (drawing == true)
{
Graphics graphics = CreateGraphics();
SolidBrush brush = new SolidBrush(color);
if (LastPoint == null)
graphics.FillEllipse(brush, e.X, e.Y, size, size);
else
graphics.DrawLine(new Pen(brush, size), LastPoint, new Point(e.X, e.Y));
}
LastPoint = new Point(e.X, e.Y);
}