12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace WindowsFormsApp39
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- // Размеры формы
- int formWidth = this.ClientSize.Width;
- int formHeight = this.ClientSize.Height;
- // Рисуем круг по середине формы
- int circleSize = Math.Min(formWidth, formHeight) / 2;
- int circleX = (formWidth - circleSize) / 2;
- int circleY = (formHeight - circleSize) / 2;
- Rectangle circleRect = new Rectangle(circleX, circleY, circleSize, circleSize);
- g.FillEllipse(Brushes.Green, circleRect);
- // Рисуем черные полоски сверху, снизу, слева и справа
- int stripeHeight = 7;
- g.FillRectangle(Brushes.Black, 0, 0, formWidth, stripeHeight); // Полоска сверху
- g.FillRectangle(Brushes.Black, 0, formHeight - stripeHeight, formWidth, stripeHeight); // Полоска снизу
- g.FillRectangle(Brushes.Black, 0, 0, stripeHeight, formHeight); // Полоска слева
- g.FillRectangle(Brushes.Black, formWidth - stripeHeight, 0, stripeHeight, formHeight); // Полоска справа
- }
- }
- }
|