📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DoubleBuffer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Random r = new Random();
g.FillRectangle(Brushes.White, ClientRectangle);
for(int x = 0; x < ClientRectangle.Width; x++)
{
for(int y = 0; y < ClientRectangle.Height; y += 10)
{
Color c = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255));
using (Pen p = new Pen(c,1))
{
g.DrawLine(p,new Point(0,0), new Point(x,y));
}
}
}
/*
// 使用双缓冲
Graphics displayGraphics = e.Graphics;
Random r = new Random();
Image i = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
Graphics g = Graphics.FromImage(i);
g.FillRectangle(Brushes.White, ClientRectangle);
for(int x = 0; x < ClientRectangle.Width; x++)
{
for(int y = 0; y < ClientRectangle.Height; y += 10)
{
Color c = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255));
using (Pen p = new Pen(c,1))
{
g.DrawLine(p,new Point(0,0), new Point(x,y));
}
//Pen p = new Pen(c,1);
//g.DrawLine(p,new Point(0,0), new Point(x,y));
//p.Dispose();
}
}
displayGraphics.DrawImage(i, ClientRectangle);
i.Dispose();
*/
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -