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 0000000..e29e148 Binary files /dev/null and b/ProjectAirFighter/ProjectAirFighter/Resources/down.jpg differ diff --git a/ProjectAirFighter/ProjectAirFighter/Resources/left.jpg b/ProjectAirFighter/ProjectAirFighter/Resources/left.jpg new file mode 100644 index 0000000..abc6a6a Binary files /dev/null and b/ProjectAirFighter/ProjectAirFighter/Resources/left.jpg differ diff --git a/ProjectAirFighter/ProjectAirFighter/Resources/right.jpg b/ProjectAirFighter/ProjectAirFighter/Resources/right.jpg new file mode 100644 index 0000000..065e43e Binary files /dev/null and b/ProjectAirFighter/ProjectAirFighter/Resources/right.jpg differ diff --git a/ProjectAirFighter/ProjectAirFighter/Resources/up.jpg b/ProjectAirFighter/ProjectAirFighter/Resources/up.jpg new file mode 100644 index 0000000..f707693 Binary files /dev/null and b/ProjectAirFighter/ProjectAirFighter/Resources/up.jpg differ