winform.controls
winform.controls copied to clipboard
采用双缓冲,解决自定控件闪烁问题
优化BaseForm的OnPaint函数 protected override void OnPaint(PaintEventArgs e) { //Graphics g = e.Graphics; //GDIHelper.InitializeGraphics(g); //this.DrawFormBackGround(g); //this.DrawCaption(g); //this.DrawFormBorder(g);
//缓冲
BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
BufferedGraphics myBuffer = currentContext.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = myBuffer.Graphics;
GDIHelper.InitializeGraphics(g);
this.DrawFormBackGround(g);
this.DrawCaption(g);
this.DrawFormBorder(g);
g.SmoothingMode = SmoothingMode.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
myBuffer.Render(e.Graphics);
g.Dispose();
myBuffer.Dispose();//释放资源
}