日期:2014-05-17  浏览次数:20792 次

关于双缓冲的一个问题

Rectangle rect = e.ClipRectangle;

            BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
            BufferedGraphics myBuffer = currentContext.Allocate(e.Graphics, e.ClipRectangle);
            Graphics g = myBuffer.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
            g.Clear(this.BackColor);
            
            foreach (IShape drawobject in doc.drawObjectList)
            {
                if (rect.IntersectsWith(drawobject.Rect))
                {
                    drawobject.Draw(g);
                    if (drawobject.TrackerState == config.Module.Core.TrackerState.Selected
                        && this.CurrentOperator == Enum.Operator.Transfrom)//仅当编辑节点操作时显示图元热点
                    {
                        drawobject.DrawTracker(g);
                    }
                }
            }

            myBuffer.Render(e.Graphics);
            g.Dispose();
            myBuffer.Dispose();//释放资源

谁能告诉我在哪个foreach中的doc是什么变量,怎么来的 ,,,求解释
双缓冲 c#

------解决方案--------------------
双缓冲,加下面的代码
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
------解决方案--------------------
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
方式可以,用过后基本不闪烁了,原来很闪
------解决方案--------------------
引用:
引用:要是猜得不错的话,这些代码可能是需要画一个图形之类的,doc应该在上文有定义,楼主这只是其中一部分代码
这个是用来解决图形界