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


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

namespace WindowsFormsApp7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Paint += new PaintEventHandler(Form1_Paint);
            this.ClientSize = new Size(800, 600);
            this.Text = "Домик";
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            int cellSize = 20;
            int houseWidthCells = 10;
            int houseHeightCells = 7;
            int roofHeightCells = 4;

            int houseWidthPx = houseWidthCells * cellSize;
            int houseHeightPx = houseHeightCells * cellSize;
            int roofHeightPx = roofHeightCells * cellSize;

            int startX = 10 * cellSize;
            int startY = 5 * cellSize;

            Pen gridPen = new Pen(Color.LightGray, 1);
            for (int x = 0; x < 50; x++)
            {
                g.DrawLine(gridPen, x * cellSize, 0, x * cellSize, this.ClientSize.Height);
            }
            for (int y = 0; y < 40; y++)
            {
                g.DrawLine(gridPen, 0, y * cellSize, this.ClientSize.Width, y * cellSize);
            }

            Rectangle wallsRect = new Rectangle(startX, startY + roofHeightPx, houseWidthPx, houseHeightPx);
            g.DrawRectangle(Pens.Black, wallsRect);

            Point[] roofPoints = new Point[]
            {
                new Point(startX, startY + roofHeightPx),
                new Point(startX + houseWidthPx / 2, startY),
                new Point(startX + houseWidthPx, startY + roofHeightPx)
            };
            g.DrawPolygon(Pens.Black, roofPoints);

            int windowRoofSize = cellSize * 2;
            int windowRoofX = startX + (houseWidthPx - windowRoofSize) / 2;
            int windowRoofY = startY + roofHeightPx / 2 - windowRoofSize / 2;
            Rectangle roofWindowRect = new Rectangle(windowRoofX, windowRoofY, windowRoofSize, windowRoofSize);
            g.DrawEllipse(Pens.Black, roofWindowRect);

            int leftWindowSize = cellSize * 3;
            int leftWindowX = startX + cellSize;
            int leftWindowY = startY + roofHeightPx + cellSize;
            Rectangle leftWindowRect = new Rectangle(leftWindowX, leftWindowY, leftWindowSize, leftWindowSize);
            g.DrawRectangle(Pens.Black, leftWindowRect);

            int doorWidth = cellSize * 3;
            int doorHeight = cellSize * 6;
            int doorX = startX + (houseWidthCells - 4) * cellSize;
            int doorY = startY + roofHeightPx + cellSize;
            Rectangle doorRect = new Rectangle(doorX, doorY, doorWidth, doorHeight);
            g.DrawRectangle(Pens.Black, doorRect);
        }
    }
}