日期:2014-05-17 浏览次数:21439 次
List<Point> m_lsPoints;
public Form1()
{
m_lsPoints = new List<Point>();
}
// 处理鼠标点击事件
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Graphics g = ((PictureBox)sender).CreateGraphics();
g.FillEllipse(Brushes.Black, e.X, e.Y, 4, 4);
Point pt = new Point(e.X, e.Y);
m_lsPoints.Add(pt);
g.Dispose();
}
// 处理Paint事件
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
foreach( Point pt in m_lsPoints )
{
g.FillEllipse(Brushes.Black, pt.X, pt.Y, 4, 4);
}
p.Dispose();
}