From 779ea324f89c5c2a6c06cadbddff5c3e6abaa8f1 Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Thu, 15 Feb 2024 19:27:37 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=20=E2=84=961?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProjectAirFighter/DirectionType.cs | 27 ++
.../ProjectAirFighter/DrawningAirFighter.cs | 341 ++++++++++++++++++
.../ProjectAirFighter/EntityAirFighter.cs | 61 ++++
.../ProjectAirFighter/Form1.Designer.cs | 39 --
ProjectAirFighter/ProjectAirFighter/Form1.cs | 10 -
.../FormAirFighter.Designer.cs | 135 +++++++
.../ProjectAirFighter/FormAirFighter.cs | 90 +++++
.../{Form1.resx => FormAirFighter.resx} | 50 +--
.../ProjectAirFighter/Program.cs | 2 +-
.../ProjectAirFighter.csproj | 15 +
.../Properties/Resources.Designer.cs | 103 ++++++
.../Properties/Resources.resx | 133 +++++++
.../ProjectAirFighter/Resources/down.jpg | Bin 0 -> 1712 bytes
.../ProjectAirFighter/Resources/left.jpg | Bin 0 -> 1490 bytes
.../ProjectAirFighter/Resources/right.jpg | Bin 0 -> 1544 bytes
.../ProjectAirFighter/Resources/up.jpg | Bin 0 -> 1502 bytes
16 files changed, 931 insertions(+), 75 deletions(-)
create mode 100644 ProjectAirFighter/ProjectAirFighter/DirectionType.cs
create mode 100644 ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs
create mode 100644 ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs
delete mode 100644 ProjectAirFighter/ProjectAirFighter/Form1.Designer.cs
delete mode 100644 ProjectAirFighter/ProjectAirFighter/Form1.cs
create mode 100644 ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs
create mode 100644 ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs
rename ProjectAirFighter/ProjectAirFighter/{Form1.resx => FormAirFighter.resx} (93%)
create mode 100644 ProjectAirFighter/ProjectAirFighter/Properties/Resources.Designer.cs
create mode 100644 ProjectAirFighter/ProjectAirFighter/Properties/Resources.resx
create mode 100644 ProjectAirFighter/ProjectAirFighter/Resources/down.jpg
create mode 100644 ProjectAirFighter/ProjectAirFighter/Resources/left.jpg
create mode 100644 ProjectAirFighter/ProjectAirFighter/Resources/right.jpg
create mode 100644 ProjectAirFighter/ProjectAirFighter/Resources/up.jpg
diff --git a/ProjectAirFighter/ProjectAirFighter/DirectionType.cs b/ProjectAirFighter/ProjectAirFighter/DirectionType.cs
new file mode 100644
index 0000000..66b140b
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/DirectionType.cs
@@ -0,0 +1,27 @@
+namespace ProjectAirFighter;
+
+///
+/// Направление перемещения
+///
+public enum DirectionType
+{
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+
+ ///
+ /// Влево
+ ///
+ Left = 3,
+
+ ///
+ /// Вправо
+ ///
+ Right = 4
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs
new file mode 100644
index 0000000..2c2e742
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs
@@ -0,0 +1,341 @@
+namespace ProjectAirFighter;
+
+///
+/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+///
+public class DrawningAirFighter
+{
+ ///
+ /// Класс-сущность
+ ///
+ public EntityAirFighter? EntityAirFighter { get; private set; }
+
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+
+ ///
+ /// Левая координата прорисовки истребителя
+ ///
+ private int? _startPosX;
+
+ ///
+ /// Верхняя кооридната прорисовки истребителя
+ ///
+ private int? _startPosY;
+
+ ///
+ /// Ширина прорисовки истребителя
+ ///
+ private readonly int _drawningAirFighterWidth = 76;
+
+ ///
+ /// Высота прорисовки истребителя
+ ///
+ private readonly int _drawningAirFighterHeight = 80;
+
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия ПГО
+ /// Признак наличия ракет
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pgo, bool rockets)
+ {
+ EntityAirFighter = new EntityAirFighter();
+ EntityAirFighter.Init(speed, weight, bodyColor, additionalColor, pgo, rockets);
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+ public bool SetPictureSize(int width, int height)
+ {
+
+ if (_drawningAirFighterWidth > width || _drawningAirFighterHeight > height)
+ {
+ return false;
+ }
+
+ _pictureWidth = width;
+ _pictureHeight = height;
+
+ if (_startPosX.HasValue && _startPosY.HasValue)
+ {
+ SetPosition(_startPosX.Value, _startPosY.Value);
+ }
+
+ return true;
+ }
+
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ ///
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+
+ return;
+ }
+
+ if (x < 0)
+ {
+ x = 0;
+ }
+ else if (x > _pictureWidth - _drawningAirFighterWidth)
+ {
+ x = _pictureWidth.Value - _drawningAirFighterWidth;
+ }
+
+ if (y < 0)
+ {
+ y = 0;
+ }
+ else if (y > _pictureHeight - _drawningAirFighterHeight)
+ {
+ y = _pictureHeight.Value - _drawningAirFighterHeight;
+ }
+
+ _startPosX = x;
+ _startPosY = y;
+ }
+
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ /// true - перемещене выполнено, false - перемещение невозможно
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntityAirFighter == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return false;
+ }
+
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityAirFighter.Step > 0)
+ {
+ _startPosX -= (int)EntityAirFighter.Step;
+ }
+ return true;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityAirFighter.Step > 0)
+ {
+ _startPosY -= (int)EntityAirFighter.Step;
+ }
+ return true;
+ // вправо
+ case DirectionType.Right:
+ if (_startPosX.Value + EntityAirFighter.Step < _pictureWidth - _drawningAirFighterWidth)
+ {
+ _startPosX += (int)EntityAirFighter.Step;
+ }
+ return true;
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY.Value + EntityAirFighter.Step < _pictureHeight - _drawningAirFighterHeight)
+ {
+ _startPosY += (int)EntityAirFighter.Step;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public void DrawTransport(Graphics g)
+ {
+ if (EntityAirFighter == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+ Brush additionalBrush = new SolidBrush(EntityAirFighter.AdditionalColor);
+
+ //ПГО
+ if (EntityAirFighter.Pgo)
+ {
+ Point[] pgo1 = new Point[] {
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 25},
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 15},
+ new Point { X = _startPosX.Value + 55, Y = _startPosY.Value + 25}
+ };
+
+ g.DrawPolygon(pen, pgo1);
+ g.FillPolygon(additionalBrush, pgo1);
+
+ Point[] pgo2 = new Point[] {
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 49},
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 59},
+ new Point { X = _startPosX.Value + 55, Y = _startPosY.Value + 49}
+ };
+
+ g.DrawPolygon(pen, pgo2);
+ g.FillPolygon(additionalBrush, pgo2);
+ }
+
+ //фюзеляж
+ Brush br = new SolidBrush(EntityAirFighter.BodyColor);
+
+ g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 25, 50, 24);
+ g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value + 25, 50, 24);
+
+ Point[] nose = new Point[] {
+ new Point { X = _startPosX.Value + 60, Y = _startPosY.Value + 25},
+ new Point { X = _startPosX.Value + 76, Y = _startPosY.Value + 37},
+ new Point { X = _startPosX.Value + 60, Y = _startPosY.Value + 49}
+ };
+
+ g.DrawPolygon(pen, nose);
+ Brush brgray = new SolidBrush(Color.Gray);
+ g.FillPolygon(brgray, nose);
+
+ //левое крыло
+ Point[] wingl = new Point[] {
+ new Point { X = _startPosX.Value + 45, Y = _startPosY.Value + 25},
+ new Point { X = _startPosX.Value + 45, Y = _startPosY.Value},
+ new Point { X = _startPosX.Value + 37, Y = _startPosY.Value},
+ new Point { X = _startPosX.Value + 30, Y = _startPosY.Value + 25}
+ };
+
+ g.DrawPolygon(pen, wingl);
+ g.FillPolygon(br, wingl);
+
+ //правое крыло
+ Point[] wingr = new Point[] {
+ new Point { X = _startPosX.Value + 45, Y = _startPosY.Value + 49},
+ new Point { X = _startPosX.Value + 45, Y = _startPosY.Value + 74},
+ new Point { X = _startPosX.Value + 37, Y = _startPosY.Value + 74},
+ new Point { X = _startPosX.Value + 30, Y = _startPosY.Value + 49}
+ };
+
+ g.DrawPolygon(pen, wingr);
+ g.FillPolygon(br, wingr);
+
+ //левый хвост
+ Point[] ltail = new Point[] {
+ new Point { X = _startPosX.Value + 10, Y = _startPosY.Value + 49},
+ new Point { X = _startPosX.Value + 10, Y = _startPosY.Value + 66},
+ new Point { X = _startPosX.Value + 20, Y = _startPosY.Value + 57},
+ new Point { X = _startPosX.Value + 20, Y = _startPosY.Value + 49}
+ };
+
+ g.DrawPolygon(pen, ltail);
+ g.FillPolygon(br, ltail);
+
+ //правый хвост
+ Point[] rtail = new Point[] {
+ new Point { X = _startPosX.Value + 10, Y = _startPosY.Value + 25},
+ new Point { X = _startPosX.Value + 10, Y = _startPosY.Value + 8},
+ new Point { X = _startPosX.Value + 20, Y = _startPosY.Value + 17},
+ new Point { X = _startPosX.Value + 20, Y = _startPosY.Value + 25}
+ };
+
+ g.DrawPolygon(pen, rtail);
+ g.FillPolygon(br, rtail);
+
+ // ракеты
+ if (EntityAirFighter.Rockets)
+ {
+ Point[] rocket1 = new Point[] {
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 71},
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 74},
+ new Point { X = _startPosX.Value + 55, Y = _startPosY.Value + 69},
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 64}
+ };
+
+ g.DrawPolygon(pen, rocket1);
+ g.FillPolygon(additionalBrush, rocket1);
+
+ g.DrawRectangle(pen, _startPosX.Value + 45, _startPosY.Value + 67, 5, 4);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 45, _startPosY.Value + 67, 5, 4);
+
+ Point[] rocket2 = new Point[] {
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value +7},
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value + 10},
+ new Point { X = _startPosX.Value + 55, Y = _startPosY.Value + 5},
+ new Point { X = _startPosX.Value + 50, Y = _startPosY.Value}
+ };
+
+ g.DrawPolygon(pen, rocket2);
+ g.FillPolygon(additionalBrush, rocket2);
+
+ g.DrawRectangle(pen, _startPosX.Value + 45, _startPosY.Value + 3, 5, 4);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 45, _startPosY.Value + 3, 5, 4);
+ }
+
+ //обводка
+ g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 25, 50, 24);
+ g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 25, _startPosX.Value + 76, _startPosY.Value + 37);
+ g.DrawLine(pen, _startPosX.Value + 76, _startPosY.Value + 37, _startPosX.Value + 60, _startPosY.Value + 49);
+
+ g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 25, _startPosX.Value + 45, _startPosY.Value);
+ g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value, _startPosX.Value + 37, _startPosY.Value);
+ g.DrawLine(pen, _startPosX.Value + 37, _startPosY.Value, _startPosX.Value + 30, _startPosY.Value + 25);
+
+ g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 49, _startPosX.Value + 45, _startPosY.Value + 74);
+ g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 74, _startPosX.Value + 37, _startPosY.Value + 74);
+ g.DrawLine(pen, _startPosX.Value + 37, _startPosY.Value + 74, _startPosX.Value + 30, _startPosY.Value + 49);
+
+ g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 49, _startPosX.Value + 10, _startPosY.Value + 66);
+ g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 66, _startPosX.Value + 20, _startPosY.Value + 57);
+ g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 57, _startPosX.Value + 20, _startPosY.Value + 49);
+
+ g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 25, _startPosX.Value + 10, _startPosY.Value + 8);
+ g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 8, _startPosX.Value + 20, _startPosY.Value + 17);
+ g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 17, _startPosX.Value + 20, _startPosY.Value + 25);
+
+ if (EntityAirFighter.Rockets)
+ {
+ g.DrawRectangle(pen, _startPosX.Value + 45, _startPosY.Value + 67, 5, 4);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 71, _startPosX.Value + 50, _startPosY.Value + 74);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 74, _startPosX.Value + 55, _startPosY.Value + 69);
+ g.DrawLine(pen, _startPosX.Value + 55, _startPosY.Value + 69, _startPosX.Value + 50, _startPosY.Value + 64);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 64, _startPosX.Value + 50, _startPosY.Value + 71);
+
+
+ g.DrawRectangle(pen, _startPosX.Value + 45, _startPosY.Value + 3, 5, 4);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 7, _startPosX.Value + 50, _startPosY.Value + 10);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 10, _startPosX.Value + 55, _startPosY.Value + 5);
+ g.DrawLine(pen, _startPosX.Value + 55, _startPosY.Value + 5, _startPosX.Value + 50, _startPosY.Value);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value, _startPosX.Value + 50, _startPosY.Value + 7);
+ }
+
+ if (EntityAirFighter.Pgo)
+ {
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 25, _startPosX.Value + 50, _startPosY.Value + 15);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 15, _startPosX.Value + 55, _startPosY.Value + 25);
+
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 49, _startPosX.Value + 50, _startPosY.Value + 59);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 59, _startPosX.Value + 55, _startPosY.Value + 49);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs
new file mode 100644
index 0000000..f5c614e
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs
@@ -0,0 +1,61 @@
+namespace ProjectAirFighter;
+
+///
+/// Класс-сущность "Истребитель"
+///
+public class EntityAirFighter
+{
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+
+ ///
+ /// Дополнительный цвет (для опциональных элементов)
+ ///
+ public Color AdditionalColor { get; private set; }
+
+ ///
+ /// Признак (опция) наличия Переднего Горизонтального Оперения(ПГО)
+ ///
+ public bool Pgo { get; private set; }
+
+ ///
+ /// Признак (опция) наличия ракет
+ ///
+ public bool Rockets { get; private set; }
+
+ ///
+ /// Шаг перемещения истребителя
+ ///
+ public double Step => Speed * 100 / Weight;
+
+ ///
+ /// Инициализация полей объекта-класса истребителя
+ ///
+ /// Скорость
+ /// Вес истребителя
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия ПГО
+ /// Признак наличия ракет"
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pgo , bool rockets)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ Pgo = pgo;
+ Rockets = rockets;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/Form1.Designer.cs b/ProjectAirFighter/ProjectAirFighter/Form1.Designer.cs
deleted file mode 100644
index dfdcb34..0000000
--- a/ProjectAirFighter/ProjectAirFighter/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ProjectAirFighter
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
diff --git a/ProjectAirFighter/ProjectAirFighter/Form1.cs b/ProjectAirFighter/ProjectAirFighter/Form1.cs
deleted file mode 100644
index 10853c8..0000000
--- a/ProjectAirFighter/ProjectAirFighter/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ProjectAirFighter
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs
new file mode 100644
index 0000000..a7b6b81
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs
@@ -0,0 +1,135 @@
+namespace ProjectAirFighter
+{
+ partial class FormAirFighter
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ pictureBoxAirFighter = new PictureBox();
+ buttonCreateAirFighter = new Button();
+ buttonLeft = new Button();
+ buttonUp = new Button();
+ buttonRight = new Button();
+ buttonDown = new Button();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).BeginInit();
+ SuspendLayout();
+ //
+ // pictureBoxAirFighter
+ //
+ pictureBoxAirFighter.Dock = DockStyle.Fill;
+ pictureBoxAirFighter.Location = new Point(0, 0);
+ pictureBoxAirFighter.Name = "pictureBoxAirFighter";
+ pictureBoxAirFighter.Size = new Size(800, 521);
+ pictureBoxAirFighter.TabIndex = 0;
+ pictureBoxAirFighter.TabStop = false;
+ //
+ // buttonCreateAirFighter
+ //
+ buttonCreateAirFighter.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreateAirFighter.Location = new Point(31, 470);
+ buttonCreateAirFighter.Name = "buttonCreateAirFighter";
+ buttonCreateAirFighter.Size = new Size(94, 39);
+ buttonCreateAirFighter.TabIndex = 1;
+ buttonCreateAirFighter.Text = "Создать";
+ buttonCreateAirFighter.UseVisualStyleBackColor = true;
+ buttonCreateAirFighter.Click += ButtonCreateAirFighter_Click;
+ //
+ // buttonLeft
+ //
+ buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonLeft.BackgroundImage = Properties.Resources.left;
+ buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonLeft.Location = new Point(602, 459);
+ buttonLeft.Name = "buttonLeft";
+ buttonLeft.Size = new Size(50, 50);
+ buttonLeft.TabIndex = 2;
+ buttonLeft.UseVisualStyleBackColor = true;
+ buttonLeft.Click += ButtonMove_Click;
+ //
+ // buttonUp
+ //
+ buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonUp.BackgroundImage = Properties.Resources.up;
+ buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUp.Location = new Point(657, 403);
+ buttonUp.Name = "buttonUp";
+ buttonUp.Size = new Size(50, 50);
+ buttonUp.TabIndex = 3;
+ buttonUp.UseVisualStyleBackColor = true;
+ buttonUp.Click += ButtonMove_Click;
+ //
+ // buttonRight
+ //
+ buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonRight.BackgroundImage = Properties.Resources.right;
+ buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRight.Location = new Point(712, 459);
+ buttonRight.Name = "buttonRight";
+ buttonRight.Size = new Size(50, 50);
+ buttonRight.TabIndex = 4;
+ buttonRight.UseVisualStyleBackColor = true;
+ buttonRight.Click += ButtonMove_Click;
+ //
+ // buttonDown
+ //
+ buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonDown.BackgroundImage = Properties.Resources.down;
+ buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDown.Location = new Point(657, 459);
+ buttonDown.Name = "buttonDown";
+ buttonDown.Size = new Size(50, 50);
+ buttonDown.TabIndex = 5;
+ buttonDown.UseVisualStyleBackColor = true;
+ buttonDown.Click += ButtonMove_Click;
+ //
+ // FormAirFighter
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 521);
+ Controls.Add(buttonDown);
+ Controls.Add(buttonRight);
+ Controls.Add(buttonUp);
+ Controls.Add(buttonLeft);
+ Controls.Add(buttonCreateAirFighter);
+ Controls.Add(pictureBoxAirFighter);
+ Name = "FormAirFighter";
+ Text = "Истребитель";
+ Click += ButtonMove_Click;
+ ((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxAirFighter;
+ private Button buttonCreateAirFighter;
+ private Button buttonLeft;
+ private Button buttonUp;
+ private Button buttonRight;
+ private Button buttonDown;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs
new file mode 100644
index 0000000..df8addd
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs
@@ -0,0 +1,90 @@
+namespace ProjectAirFighter;
+
+///
+/// Форма работы с объектом "Истребитель"
+///
+public partial class FormAirFighter : Form
+{
+ ///
+ /// Поле-объект для прорисовки объекта
+ ///
+ private DrawningAirFighter? _drawningAirFighter;
+
+ ///
+ /// Конструктор формы
+ ///
+ public FormAirFighter()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Метод прорисовки истребителя
+ ///
+ private void Draw()
+ {
+ if (_drawningAirFighter == null)
+ {
+ return;
+ }
+
+ Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _drawningAirFighter.DrawTransport(gr);
+ pictureBoxAirFighter.Image = bmp;
+ }
+
+ ///
+ /// Обработка нажатия кнопки "Создать"
+ ///
+ ///
+ ///
+ private void ButtonCreateAirFighter_Click(object sender, EventArgs e)
+ {
+ Random random = new();
+ _drawningAirFighter = new DrawningAirFighter();
+ _drawningAirFighter.Init(random.Next(100, 300), random.Next(1000, 3000),
+ Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
+ Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ _drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
+ _drawningAirFighter.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ Draw();
+ }
+
+ ///
+ /// Перемещение объекта по форме (нажатие кнопок навигации)
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_drawningAirFighter == null)
+ {
+ return;
+ }
+
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ bool result = false;
+ switch (name)
+ {
+ case "buttonUp":
+ result = _drawningAirFighter.MoveTransport(DirectionType.Up);
+ break;
+ case "buttonDown":
+ result = _drawningAirFighter.MoveTransport(DirectionType.Down);
+ break;
+ case "buttonLeft":
+ result = _drawningAirFighter.MoveTransport(DirectionType.Left);
+ break;
+ case "buttonRight":
+ result = _drawningAirFighter.MoveTransport(DirectionType.Right);
+ break;
+ }
+
+ if (result)
+ {
+ Draw();
+ }
+ }
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/Form1.resx b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.resx
similarity index 93%
rename from ProjectAirFighter/ProjectAirFighter/Form1.resx
rename to ProjectAirFighter/ProjectAirFighter/FormAirFighter.resx
index 1af7de1..af32865 100644
--- a/ProjectAirFighter/ProjectAirFighter/Form1.resx
+++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.resx
@@ -1,17 +1,17 @@
-
diff --git a/ProjectAirFighter/ProjectAirFighter/Program.cs b/ProjectAirFighter/ProjectAirFighter/Program.cs
index da2d7dd..fc87305 100644
--- a/ProjectAirFighter/ProjectAirFighter/Program.cs
+++ b/ProjectAirFighter/ProjectAirFighter/Program.cs
@@ -11,7 +11,7 @@ namespace ProjectAirFighter
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(new FormAirFighter());
}
}
}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj b/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj
index e1a0735..244387d 100644
--- a/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj
+++ b/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj
@@ -8,4 +8,19 @@
enable
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/Properties/Resources.Designer.cs b/ProjectAirFighter/ProjectAirFighter/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..f6fa97e
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectAirFighter.Properties {
+ using System;
+
+
+ ///
+ /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
+ ///
+ // Этот класс создан автоматически классом StronglyTypedResourceBuilder
+ // с помощью такого средства, как ResGen или Visual Studio.
+ // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
+ // с параметром /str или перестройте свой проект VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectAirFighter.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Перезаписывает свойство CurrentUICulture текущего потока для всех
+ /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap down {
+ get {
+ object obj = ResourceManager.GetObject("down", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap left {
+ get {
+ object obj = ResourceManager.GetObject("left", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap right {
+ get {
+ object obj = ResourceManager.GetObject("right", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap up {
+ get {
+ object obj = ResourceManager.GetObject("up", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/Properties/Resources.resx b/ProjectAirFighter/ProjectAirFighter/Properties/Resources.resx
new file mode 100644
index 0000000..799a689
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/Properties/Resources.resx
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Resources\up.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\right.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\left.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\down.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/Resources/down.jpg b/ProjectAirFighter/ProjectAirFighter/Resources/down.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..e29e148368ea47e481b4d11c5ce4ef55f6345608
GIT binary patch
literal 1712
zcmbW0dogh6xs+AvLOr-+BT!zEH#;t%V@^$x4)@9?e2fO`@HY_ob#Ob`#k6Kycetw8wA?!
zE^aP>KmdS%4}d)dPI&Y;BN9nOjX@+5kpx393_}nElPP2vrjQ|sOe0gM8iUC+I*m%#
z1ezk63Ysi@Qt_G)ehwOUVA8uBXv0m8HH3c$D3k3Z;9O8
zYHw5`jlMwNz|d&Prxxs`pINW5v9(*f&S`_Qi|a-=_bpquZTH#X>$fj3Xn*k6A)$xA
zi9T|a7ZZCtDfz_7Q>RnTWuDK_f^5fv562wf+!kn0`VxmNK6P`
zw3@8r;6>RJIe#%HfvW46QFv2KGqduR>+Ow_&=;6nOP44#$qb4djJ3Q0`B1t_|d;qK?u70+!HqV(w-VSFxiG!)na}3D0vu51&)w)~IRwT7?Xye`XlA(E_ND^xD_RUyuNO4|x=_N}uoi@i(
zL1rg?*8WCIopRBzy2t{h^}%$=CX@Y08Txu_AhzmXPI2%R>nKrAmUXw
z+EnW6+pP26d9^z9C~dy=k)hz3eH^>3zx=%Nbv}#~j0rF>I59S0Rc~UcuuV`0VE}q2
zcTKYQzdSmBB)2%Tgg1mPyT=(dqXYFXREilmfx5#
z!7DkVy#crDWMb7EwZ*KE8=985+gQm|P?}am#|cMbJ=#}P%rkDofK!jooRcw^e7jd(
zd()I|9xuyU-&9yotn1}$svYkD1^Os_F+kaX0Wo!Gwy4HzC_u?>ew{HW%$rK=JiwPI
zSPij3wSkJtOo)d{s#0A7yed;yjdGr7n?49k-o9Dpoh}d*=MJlRW{@0>CGM
z-x45tE>7#Kn?jVqDr+^6U-^=u^q1~hyWCoJ;6$!eyQ6OmCh2Jg++JTaSGa
zb4Ay*6ivgMZW^TL?~{=tJ0`;v7O30wS?+5_90sn8`;0%v067+ESzBv|f&S1Zbra`W
Va{CysR;IA8P_Ql()qFs#{|~NZ@J#>!
literal 0
HcmV?d00001
diff --git a/ProjectAirFighter/ProjectAirFighter/Resources/left.jpg b/ProjectAirFighter/ProjectAirFighter/Resources/left.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..abc6a6aa2a0dc5d378fd19b1fc8f996eb196a906
GIT binary patch
literal 1490
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
P$1~3-vAox_(Pw`Hii3br
literal 0
HcmV?d00001
--
2.25.1