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 zxc
{
public partial class Form1 : Form
{
private Random rand = new Random();
public Form1()
{
InitializeComponent();
this.ResizeRedraw = true;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
int maxWidth = this.ClientSize.Width;
int maxHeight = this.ClientSize.Height;
for (int i = 0; i < 50; i++)
{
int x = rand.Next(0, maxWidth);
int y = rand.Next(0, maxHeight);
// Случайный размер (ширина и высота от 10 до 200 пикселей)
int width = rand.Next(10, 201);
int height = rand.Next(10, 201);
// Случайный цвет
Color randomColor = Color.FromArgb(
rand.Next(256), // R
rand.Next(256), // G
rand.Next(256) // B
);
// Рисуем закрашенный прямоугольник
using (SolidBrush brush = new SolidBrush(randomColor))
{
g.FillRectangle(brush, x, y, width, height);
}
}
}
}
}