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


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

namespace FlagsForms
{
    public partial class Form1 : Form
    {
        int mode = 0;

        public Form1()
        {
            InitializeComponent();

            this.Paint += Form1_Paint;

            pictureBox1.Visible = false;
        }

        // Японский флаг
        private void btnJapan_Click(object sender, EventArgs e)
        {
            mode = 1;
            pictureBox1.Visible = false;
            this.Invalidate();
        }

        // Российский флаг
        private void btnRussia_Click(object sender, EventArgs e)
        {
            mode = 2;
            pictureBox1.Visible = false;
            this.Invalidate();
        }

        // Чехия
        private void btnCzech_Click(object sender, EventArgs e)
        {
            mode = 3;
            pictureBox1.Visible = false;
            this.Invalidate();
        }

        // Олимпийский
        private void btnOlympic_Click(object sender, EventArgs e)
        {
            mode = 4;
            pictureBox1.Visible = false;
            this.Invalidate();
        }

        // Зимний пейзаж
        private void btnWinter_Click(object sender, EventArgs e)
        {
            mode = 5;

            pictureBox1.Visible = true;

            // Укажи путь к картинке
            pictureBox1.Image = Image.FromFile(@"C:\winter.jpg");

            this.Invalidate();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            // очищение
            g.Clear(Color.White);

            // =========================
            // Японский флаг
            // =========================
            if (mode == 1)
            {
                g.FillRectangle(Brushes.White, 250, 120, 300, 180);
                g.DrawRectangle(Pens.Black, 250, 120, 300, 180);

                g.FillEllipse(Brushes.Red, 350, 160, 100, 100);
            }

            // =========================
            // Российский флаг
            // =========================
            if (mode == 2)
            {
                g.FillRectangle(Brushes.White, 250, 120, 300, 60);
                g.FillRectangle(Brushes.Blue, 250, 180, 300, 60);
                g.FillRectangle(Brushes.Red, 250, 240, 300, 60);

                g.DrawRectangle(Pens.Black, 250, 120, 300, 180);
            }

            // =========================
            // Флаг Чехии
            // =========================
            if (mode == 3)
            {
                g.FillRectangle(Brushes.White, 250, 120, 300, 90);
                g.FillRectangle(Brushes.Red, 250, 210, 300, 90);

                Point[] triangle =
                {
                    new Point(250,210),
                    new Point(380,120),
                    new Point(380,300)
                };

                g.FillPolygon(Brushes.Blue, triangle);

                g.DrawRectangle(Pens.Black, 250, 120, 300, 180);
            }

            // =========================
            // Олимпийский флаг
            // =========================
            if (mode == 4)
            {
                Pen blue = new Pen(Color.Blue, 5);
                Pen black = new Pen(Color.Black, 5);
                Pen red = new Pen(Color.Red, 5);
                Pen yellow = new Pen(Color.Gold, 5);
                Pen green = new Pen(Color.Green, 5);

                g.DrawEllipse(blue, 220, 170, 80, 80);
                g.DrawEllipse(black, 320, 170, 80, 80);
                g.DrawEllipse(red, 420, 170, 80, 80);

                g.DrawEllipse(yellow, 270, 230, 80, 80);
                g.DrawEllipse(green, 370, 230, 80, 80);
            }
        }
    }
}