using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.DoubleBuffered = true;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Random rand = new Random();
for (int i = 0; i < 50; ++i)
{
int w = rand.Next(10, 100);
int h = rand.Next(10, 100);
int x = rand.Next(this.ClientSize.Width - w);
int y = rand.Next(this.ClientSize.Height - h);
using (SolidBrush brush = new SolidBrush(Color.FromArgb(rand.Next(256), rand.Next(256), rand.Next(256))))
e.Graphics.FillRectangle(brush, x, y, w, h);
using (Pen pen = new Pen(Color.Black, 1))
e.Graphics.DrawRectangle(pen, x, y, w, h);
}
}
private void Form1_Resize(object sender, EventArgs e)
{
Invalidate();
}
}
}