日期:2014-05-18 浏览次数:20711 次
Point srcPoint; private void panel1_MouseMove(object sender, MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { if (srcPoint.IsEmpty) { srcPoint = e.Location; } Point desPoint = e.Location; Control ctl = sender as Control; if (ctl != null) { Pen pen = new Pen(Brushes.Black, 2.0F); using (Graphics g = ctl.CreateGraphics()) { g.DrawLine(pen, srcPoint, desPoint); } } srcPoint = desPoint; } }