Point p;
private void Form2_MouseDown(object sender, MouseEventArgs e)
{            p = e.Location;

private void Form2_MouseMove(object sender, MouseEventArgs e)
{
                Graphics g = this.CreateGraphics();
                Pen myPen = new Pen(Color.Black);
                g.DrawLine(myPen, p, e.Location);
                p = e.Location;
         
}
以上代码可以在窗体上画出鼠标轨迹
问题是:如何将窗体上画的鼠标轨迹保存成图像文件存在硬盘上?

解决方案 »

  1.   

    可以把轨迹中的点储存下来,在保存到文件时根据这些点再重画出来。ArrayList<Point> points = new ArrayList<Point>();
    Point p;
    private void Form2_MouseDown(object sender, MouseEventArgs e)
    {
                p = e.Location;
                points.Add(p);
    } private void Form2_MouseMove(object sender, MouseEventArgs e)
    {
                    Graphics g = this.CreateGraphics();
                    Pen myPen = new Pen(Color.Black);
                    g.DrawLine(myPen, p, e.Location);
                    p = e.Location;
                    points.Add(p);
             
      

  2.   

    1. 换用别的存储方法. 比如说int类型的数组
    2. 降低采样的频率以节省空间
      

  3.   

    no way to solute the problem. Only up 2.
      

  4.   


    错误 1 非泛型 类型“System.Collections.ArrayList”不能与类型参数一起使用
    2楼的朋友这个错误怎么解决呀?