本帖最后由 rundestiny 于 2010-09-19 11:12:26 编辑

解决方案 »

  1.   

    // 不要每次Paint事件,都重新初始化一个Bitmap
    Bitmap bp = new Bitmap(drawPanel.Width, drawPanel.Height); 
            void drawPanel_Paint(object sender, PaintEventArgs e)
            {
                using(Graphics g = Graphics.FromImage(bp))
                {
               //画之前把前一次的内容清空
                  g.Clear(Color.Empty);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; 
                Pen p = new Pen(Color.Black, 4);
                p.DashStyle = DashStyle.Custom;
                p.EndCap = LineCap.ArrowAnchor;
                foreach (Line line in lines)
                {
                    g.DrawLine(p, line.pointStart, line.pointEnd);
                }
                
                }
                e.Graphics.DrawImage(bp, Point.Empty);
            }