📄 10.2.txt
字号:
Listing 10.2 Drawing Rectangles with a HatchBrush
private void Form1_Click(object sender, System.EventArgs e)
{
Random randNum = new Random( DateTime.Now.Millisecond );
int width = randNum.Next( this.Width-mouseHit.X );
int height = randNum.Next( this.Height-mouseHit.Y );
int fr = randNum.Next(255);
int fg = randNum.Next(255);
int fb = randNum.Next(255);
int br = randNum.Next(255);
int bg = randNum.Next(255);
int bb = randNum.Next(255);
Graphics surface = Graphics.FromHwnd(this.Handle);
surface.FillRectangle( new HatchBrush((HatchStyle)Enum.Parse(
typeof(HatchStyle), comboBox1.SelectedItem.ToString()),
Color.FromArgb(fr,fg,fb), Color.FromArgb(br,bg,bb)),
mouseHit.X, mouseHit.Y, width, height );
}
private void Form1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
mouseHit = new Point( e.X, e.Y );
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -