⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 10.1.txt

📁 《Microsoft Visual C# .NET 2003开发技巧大全》源代码
💻 TXT
字号:
Listing 10.1 Drawing Randomly Sized Rectangles with Random Colors
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 r = randNum.Next(255);
int g = randNum.Next(255);
int b = randNum.Next(255);
Graphics surface = this.CreateGraphics();
if( randNum.Next(2) == 0 )
{
surface.FillRectangle( new SolidBrush(Color.FromArgb(r,g,b)),
mouseHit.X, mouseHit.Y, width, height );
}
else
{
surface.DrawRectangle( new Pen( new SolidBrush(Color.FromArgb(r,g,b))),
mouseHit.X, mouseHit.Y, width, height );
}
surface.Dispose();
}
private void Form1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
mouseHit = new Point( e.X, e.Y );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -