Загрузка данных


using System;
using System.Drawing;
using System.Windows.Forms;

namespace laba5
{
    public partial class Form1 : Form
    {
        private Button btnRed, btnBlue, btnRandColor, btnPalette, btnExit, btnOK;
        private Panel panel1;
        private RadioButton rbYellow, rbWhite, rbRandom;
        private ColorDialog colorDialog1;
        private Random rnd = new Random();

        public Form1()
        {
            this.Text = "Заголовок";
            this.Size = new Size(400, 320);

            btnRed = new Button { Text = "Цвет красный", Location = new Point(20, 20), Width = 130 };
            btnRed.Click += (s, e) => 
            {
                if (btnRed.BackColor == Color.Red) 
                    btnRed.BackColor = SystemColors.Control;
                else 
                    btnRed.BackColor = Color.Red;
            };

            btnBlue = new Button { Text = "Цвет окна", Location = new Point(20, 60), Width = 130 };
            btnBlue.Click += (s, e) => this.BackColor = Color.LightBlue;

            btnRandColor = new Button { Text = "Цвет из окна", Location = new Point(20, 100), Width = 130 };
            btnRandColor.Click += (s, e) => this.BackColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));

            btnPalette = new Button { Text = "Цвет из палитры", Location = new Point(20, 140), Width = 130 };
            btnPalette.Click += (s, e) => { if (colorDialog1.ShowDialog() == DialogResult.OK) this.BackColor = colorDialog1.Color; };

            btnExit = new Button { Text = "Выход", Location = new Point(20, 220), Width = 130 };
            btnExit.Click += (s, e) => Application.Exit();

            panel1 = new Panel { Location = new Point(180, 20), Size = new Size(150, 130), BorderStyle = BorderStyle.FixedSingle };
            
            rbYellow = new RadioButton { Text = "Желтый", Location = new Point(10, 10), Checked = true };
            rbWhite = new RadioButton { Text = "Белый", Location = new Point(10, 40) };
            rbRandom = new RadioButton { Text = "Случайный", Location = new Point(10, 70) };
            
            panel1.Controls.AddRange(new Control[] { rbYellow, rbWhite, rbRandom });

            btnOK = new Button { Text = "OK", Location = new Point(210, 170), Width = 80 };
            btnOK.Click += (s, e) => 
            {
                if (rbYellow.Checked) this.BackColor = Color.Yellow;
                else if (rbWhite.Checked) this.BackColor = Color.White;
                else this.BackColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
            };

            colorDialog1 = new ColorDialog();

            this.Controls.AddRange(new Control[] { btnRed, btnBlue, btnRandColor, btnPalette, btnExit, panel1, btnOK });
        }
    }
}