Form1(ПР8).cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace WindowsFormsApp39
  5. {
  6. public partial class Form1 : Form
  7. {
  8. public Form1()
  9. {
  10. InitializeComponent();
  11. }
  12. private void Form1_Paint(object sender, PaintEventArgs e)
  13. {
  14. Graphics g = e.Graphics;
  15. // Размеры формы
  16. int formWidth = this.ClientSize.Width;
  17. int formHeight = this.ClientSize.Height;
  18. // Рисуем круг по середине формы
  19. int circleSize = Math.Min(formWidth, formHeight) / 2;
  20. int circleX = (formWidth - circleSize) / 2;
  21. int circleY = (formHeight - circleSize) / 2;
  22. Rectangle circleRect = new Rectangle(circleX, circleY, circleSize, circleSize);
  23. g.FillEllipse(Brushes.Green, circleRect);
  24. // Рисуем черные полоски сверху, снизу, слева и справа
  25. int stripeHeight = 7;
  26. g.FillRectangle(Brushes.Black, 0, 0, formWidth, stripeHeight); // Полоска сверху
  27. g.FillRectangle(Brushes.Black, 0, formHeight - stripeHeight, formWidth, stripeHeight); // Полоска снизу
  28. g.FillRectangle(Brushes.Black, 0, 0, stripeHeight, formHeight); // Полоска слева
  29. g.FillRectangle(Brushes.Black, formWidth - stripeHeight, 0, stripeHeight, formHeight); // Полоска справа
  30. }
  31. }
  32. }