📄 doublebuffer.cs
字号:
using System;
using System.Drawing;
namespace UtilityLibrary.WinControls
{
/// <summary>
/// Summary description for BitmapDoubleBuffer.
/// </summary>
public class DoubleBuffer
{
int bufferWidth;
int bufferHeight;
Bitmap surface;
Graphics buffer;
private void Cleanup()
{
if (buffer != null)
{
buffer.Dispose();
buffer = null;
}
if (surface != null)
{
surface.Dispose();
surface = null;
}
}
public Graphics RequestBuffer(int width, int height)
{
if (width == bufferWidth && height == bufferHeight && buffer != null)
{
return buffer;
}
Cleanup();
surface = new Bitmap(width, height);
buffer = Graphics.FromImage(surface);
bufferWidth = width;
bufferHeight = height;
return buffer;
}
public void PaintBuffer(Graphics dest, int x, int y)
{
dest.DrawImage(surface, x, y);
}
public void Dispose()
{
Cleanup();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -