diff --git a/.gitignore b/.gitignore
index ca1c7a3..77e6200 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+#mac file
+.DS_Store
+
# User-specific files
*.rsuser
*.suo
diff --git a/ProjectTank/ProjectTank/Direction.cs b/ProjectTank/ProjectTank/Direction.cs
new file mode 100644
index 0000000..7e6a2b7
--- /dev/null
+++ b/ProjectTank/ProjectTank/Direction.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectTank
+{
+ public enum DirectionType
+ {
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+ ///
+ /// Влево
+ ///
+ Left = 3,
+ ///
+ /// Вправо
+ ///
+ Right = 4
+ }
+}
diff --git a/ProjectTank/ProjectTank/DrawningTank.cs b/ProjectTank/ProjectTank/DrawningTank.cs
new file mode 100644
index 0000000..e9a7bb7
--- /dev/null
+++ b/ProjectTank/ProjectTank/DrawningTank.cs
@@ -0,0 +1,200 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ProjectTank
+{
+ public class DrawningTank
+ {
+ ///
+ /// Класс-сущность
+ ///
+ public EntityTank? _EntityTank { get; private set; }
+ ///
+ /// Ширина окна
+ ///
+ private int _pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ private int _pictureHeight;
+ ///
+ /// Левая координата прорисовки танка
+ ///
+ private int _startPosX;
+ ///
+ /// Верхняя кооридната прорисовки танка
+ ///
+ private int _startPosY;
+ ///
+ /// Ширина прорисовки танка
+ ///
+ private readonly int _tankWidth = 200;
+ ///
+ /// Высота прорисовки танка
+ ///
+ private readonly int _tankHeight = 80;
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Ширина картинки
+ /// Высота картинки
+ /// true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах
+ public bool Init(int speed, double weight, Color bodyColor, Color additionalColor,
+ bool gun, bool machineGun, int width, int height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+
+ if ((_pictureHeight < _tankHeight) || (_pictureWidth < _tankWidth))
+ {
+ return false;
+ }
+ _EntityTank = new EntityTank();
+ _EntityTank.Init(speed, weight, gun, machineGun, bodyColor, additionalColor);
+ return true;
+ }
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ if ((x < 0 || y < 0) || (x + _tankWidth > _pictureWidth || y + _tankHeight > _pictureHeight))
+ {
+ _startPosX = 0;
+ _startPosY = 0;
+ }
+ else
+ {
+ _startPosX = x;
+ _startPosY = y;
+ }
+ }
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ public void MoveTransport(DirectionType direction)
+ {
+ if (_EntityTank == null)
+ {
+ return;
+ }
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX - _EntityTank.Step > 0)
+ {
+ _startPosX -= (int)_EntityTank.Step;
+ }
+ break;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY - _EntityTank.Step > 0)
+ {
+ _startPosY -= (int)_EntityTank.Step;
+ }
+ break;
+ //вправо
+ case DirectionType.Right:
+ if (_startPosX + _tankWidth + _EntityTank.Step < _pictureWidth)
+ {
+ _startPosX += (int)_EntityTank.Step;
+ }
+ break;
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY + _tankHeight + _EntityTank.Step < _pictureHeight)
+ {
+ _startPosY += (int)_EntityTank.Step;
+ }
+ break;
+ }
+ }
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public void DrawTransport(Graphics g)
+ {
+ if (_EntityTank == null)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black, 3);
+ Pen penGray = new(Color.Gray, 4);
+ Brush grayColorBrush = new SolidBrush(Color.Gray);
+ Brush blackColorBrush = new SolidBrush(Color.Black);
+ Brush additionalBrush = new SolidBrush(_EntityTank.AdditionalColor);
+ Brush bodyBrush = new SolidBrush(_EntityTank.BodyColor);
+
+ // Границы автомобиля
+ // гусеницы
+ g.DrawEllipse(pen, _startPosX+14, _startPosY+44, 151, 31);
+ g.FillEllipse(blackColorBrush, _startPosX + 15, _startPosY + 45, 150, 30);
+ g.DrawEllipse(penGray, _startPosX + 24, _startPosY + 54, 10, 10);
+ g.DrawEllipse(penGray, _startPosX + 144, _startPosY + 54, 10, 10);
+ g.DrawEllipse(penGray, _startPosX + 44, _startPosY + 59, 10, 10);
+ g.DrawEllipse(penGray, _startPosX + 124, _startPosY + 59, 10, 10);
+ g.DrawEllipse(penGray, _startPosX + 64, _startPosY + 61, 10, 10);
+ g.DrawEllipse(penGray, _startPosX + 104, _startPosY + 61, 10, 10);
+ g.DrawEllipse(penGray, _startPosX + 84, _startPosY + 62, 10, 10);
+ // Кузов
+ g.DrawRectangle(pen, _startPosX + 19, _startPosY + 34, 141, 21);
+ g.FillRectangle(bodyBrush, _startPosX+20, _startPosY+35, 140, 20);
+
+ // Башня
+ g.FillRectangle(blackColorBrush, _startPosX + 75, _startPosY + 10, 25, 5);
+ g.DrawRectangle(pen, _startPosX + 64, _startPosY + 14, 66, 21);
+ g.FillRectangle(additionalBrush, _startPosX + 65, _startPosY + 15, 65, 20);
+
+ //Точки для отрисовки передней и задней части
+ Point pointFirstBackSide = new Point(_startPosX + 18, _startPosY + 35);
+ Point pointSecondBackSide = new Point(_startPosX + 18, _startPosY + 55);
+ Point pointThirdBackSide = new Point(_startPosX+0, _startPosY+55);
+ Point pointFirstFrontSide = new Point(_startPosX + 162, _startPosY + 35);
+ Point pointSecondFrontSide = new Point(_startPosX + 185, _startPosY + 55);
+ Point pointThirdFrontSide = new Point(_startPosX + 162, _startPosY + 55);
+
+ // Задняя часть
+ Point[] backSide = { pointFirstBackSide, pointSecondBackSide, pointThirdBackSide };
+ g.DrawPolygon(pen, backSide);
+ g.FillPolygon(bodyBrush, backSide);
+ // Передняя часть
+ Point[] frontSide ={ pointFirstFrontSide, pointSecondFrontSide, pointThirdFrontSide };
+ g.DrawPolygon(pen, frontSide);
+ g.FillPolygon(bodyBrush, frontSide);
+
+ // пушка
+ if (_EntityTank.Gun)
+ {
+ g.DrawRectangle(pen, _startPosX + 129, _startPosY + 19, 56, 6);
+ g.FillRectangle(additionalBrush, _startPosX + 130, _startPosY + 20, 55, 5);
+ g.DrawRectangle(pen, _startPosX + 184, _startPosY + 17, 16, 11);
+ g.FillRectangle(blackColorBrush, _startPosX + 185, _startPosY + 18, 15, 10);
+ }
+ // пулемет
+ if (_EntityTank.MachineGun)
+ {
+ g.DrawRectangle(pen, _startPosX + 104, _startPosY + 9, 16, 6);
+ g.FillRectangle(additionalBrush, _startPosX + 105, _startPosY + 10, 15, 5);
+ g.DrawRectangle(pen, _startPosX + 111, _startPosY, 4, 6);
+ g.FillRectangle(additionalBrush, _startPosX + 112, _startPosY + 1, 4, 7);
+ g.FillRectangle(blackColorBrush, _startPosX + 98, _startPosY, 7, 7);
+ g.DrawRectangle(pen, _startPosX + 104, _startPosY + 2, 30, 3);
+ g.FillRectangle(additionalBrush, _startPosX + 105, _startPosY + 3, 29, 3);
+ g.FillRectangle(blackColorBrush, _startPosX + 135, _startPosY, 15, 8);
+ }
+ }
+ }
+}
diff --git a/ProjectTank/ProjectTank/EntityTank.cs b/ProjectTank/ProjectTank/EntityTank.cs
new file mode 100644
index 0000000..910b1b3
--- /dev/null
+++ b/ProjectTank/ProjectTank/EntityTank.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectTank
+{
+ public class EntityTank
+ {
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+
+ ///
+ /// Пушка
+ ///
+ public bool Gun { get; private set; }
+
+ ///
+ /// Пулемет
+ ///
+ public bool MachineGun { get; private set; }
+
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+
+ ///
+ /// Дополнительный цвет (для опциональных элементов)
+ ///
+ public Color AdditionalColor { get; private set; }
+
+ ///
+ /// Расчет шага по карте
+ ///
+ public double Step => (double)Speed * 100 / Weight;
+
+ ///
+ /// Инициализация полей объекта-класса спортивного автомобиля
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия пушки
+ /// Признак наличия пулемета
+ ///
+ public void Init(int speed, double weight, bool gun,
+ bool machineGun, Color bodyColor, Color additionalColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ Gun = gun;
+ MachineGun = machineGun;
+ }
+ }
+}
diff --git a/ProjectTank/ProjectTank/Form1.Designer.cs b/ProjectTank/ProjectTank/Form1.Designer.cs
deleted file mode 100644
index 6b0ceb0..0000000
--- a/ProjectTank/ProjectTank/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ProjectTank
-{
- 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
- }
-}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/Form1.cs b/ProjectTank/ProjectTank/Form1.cs
deleted file mode 100644
index 5ad885c..0000000
--- a/ProjectTank/ProjectTank/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ProjectTank
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/Program.cs b/ProjectTank/ProjectTank/Program.cs
index e967a59..443fffe 100644
--- a/ProjectTank/ProjectTank/Program.cs
+++ b/ProjectTank/ProjectTank/Program.cs
@@ -1,17 +1,17 @@
+using System.Drawing;
+
namespace ProjectTank
{
internal static class Program
{
///
- /// The main entry point for the application.
+ /// The main entry point for the application.
///
[STAThread]
static void Main()
{
- // 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 TankForm());
}
}
}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/ProjectTank.csproj b/ProjectTank/ProjectTank/ProjectTank.csproj
index b57c89e..13ee123 100644
--- a/ProjectTank/ProjectTank/ProjectTank.csproj
+++ b/ProjectTank/ProjectTank/ProjectTank.csproj
@@ -8,4 +8,19 @@
enable
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/Properties/Resources.Designer.cs b/ProjectTank/ProjectTank/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..c600bc6
--- /dev/null
+++ b/ProjectTank/ProjectTank/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectTank.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("ProjectTank.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 btnDown {
+ get {
+ object obj = ResourceManager.GetObject("btnDown", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap btnLeft {
+ get {
+ object obj = ResourceManager.GetObject("btnLeft", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap btnRight {
+ get {
+ object obj = ResourceManager.GetObject("btnRight", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap btnUp {
+ get {
+ object obj = ResourceManager.GetObject("btnUp", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/ProjectTank/ProjectTank/Form1.resx b/ProjectTank/ProjectTank/Properties/Resources.resx
similarity index 83%
rename from ProjectTank/ProjectTank/Form1.resx
rename to ProjectTank/ProjectTank/Properties/Resources.resx
index 1af7de1..4be9f4a 100644
--- a/ProjectTank/ProjectTank/Form1.resx
+++ b/ProjectTank/ProjectTank/Properties/Resources.resx
@@ -117,4 +117,17 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Resources\btnDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\btnLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\btnRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\btnUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/Resources/btnDown.png b/ProjectTank/ProjectTank/Resources/btnDown.png
new file mode 100644
index 0000000..51559f1
Binary files /dev/null and b/ProjectTank/ProjectTank/Resources/btnDown.png differ
diff --git a/ProjectTank/ProjectTank/Resources/btnLeft.png b/ProjectTank/ProjectTank/Resources/btnLeft.png
new file mode 100644
index 0000000..e5550c7
Binary files /dev/null and b/ProjectTank/ProjectTank/Resources/btnLeft.png differ
diff --git a/ProjectTank/ProjectTank/Resources/btnRight.png b/ProjectTank/ProjectTank/Resources/btnRight.png
new file mode 100644
index 0000000..5d43457
Binary files /dev/null and b/ProjectTank/ProjectTank/Resources/btnRight.png differ
diff --git a/ProjectTank/ProjectTank/Resources/btnUp.png b/ProjectTank/ProjectTank/Resources/btnUp.png
new file mode 100644
index 0000000..d721468
Binary files /dev/null and b/ProjectTank/ProjectTank/Resources/btnUp.png differ
diff --git a/ProjectTank/ProjectTank/TankForm.Designer.cs b/ProjectTank/ProjectTank/TankForm.Designer.cs
new file mode 100644
index 0000000..bab6505
--- /dev/null
+++ b/ProjectTank/ProjectTank/TankForm.Designer.cs
@@ -0,0 +1,155 @@
+namespace ProjectTank
+{
+ partial class TankForm
+ {
+ ///
+ /// 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.pictureBoxTanks = new System.Windows.Forms.PictureBox();
+ this.ButtonCreateTank = new System.Windows.Forms.Button();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTanks)).BeginInit();
+ this.SuspendLayout();
+ //
+ // pictureBoxTanks
+ //
+ this.pictureBoxTanks.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxTanks.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxTanks.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+ this.pictureBoxTanks.Name = "pictureBoxTanks";
+ this.pictureBoxTanks.Size = new System.Drawing.Size(1445, 881);
+ this.pictureBoxTanks.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBoxTanks.TabIndex = 0;
+ this.pictureBoxTanks.TabStop = false;
+ //
+ // ButtonCreateTank
+ //
+ this.ButtonCreateTank.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.ButtonCreateTank.Location = new System.Drawing.Point(22, 806);
+ this.ButtonCreateTank.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+ this.ButtonCreateTank.Name = "ButtonCreateTank";
+ this.ButtonCreateTank.Size = new System.Drawing.Size(139, 49);
+ this.ButtonCreateTank.TabIndex = 1;
+ this.ButtonCreateTank.Text = "Создать";
+ this.ButtonCreateTank.UseVisualStyleBackColor = true;
+ this.ButtonCreateTank.Click += new System.EventHandler(this.ButtonCreateTank_Click);
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::ProjectTank.Properties.Resources.btnUp;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonUp.Location = new System.Drawing.Point(1300, 730);
+ this.buttonUp.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(56, 64);
+ this.buttonUp.TabIndex = 2;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonRight
+ //
+ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRight.BackgroundImage = global::ProjectTank.Properties.Resources.btnRight;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonRight.Location = new System.Drawing.Point(1367, 806);
+ this.buttonRight.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(56, 64);
+ this.buttonRight.TabIndex = 3;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonLeft.BackgroundImage = global::ProjectTank.Properties.Resources.btnLeft;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonLeft.Location = new System.Drawing.Point(1233, 806);
+ this.buttonLeft.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(56, 64);
+ this.buttonLeft.TabIndex = 4;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::ProjectTank.Properties.Resources.btnDown;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonDown.Location = new System.Drawing.Point(1300, 806);
+ this.buttonDown.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(56, 64);
+ this.buttonDown.TabIndex = 5;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(1172, 0);
+ this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(0, 32);
+ this.label1.TabIndex = 6;
+ //
+ // TankForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1445, 881);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.buttonDown);
+ this.Controls.Add(this.buttonLeft);
+ this.Controls.Add(this.buttonRight);
+ this.Controls.Add(this.buttonUp);
+ this.Controls.Add(this.ButtonCreateTank);
+ this.Controls.Add(this.pictureBoxTanks);
+ this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+ this.Name = "TankForm";
+ this.Text = "Tank";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTanks)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ private Button ButtonCreateTank;
+ private Button buttonUp;
+ private Button buttonRight;
+ private Button buttonLeft;
+ private Button buttonDown;
+ public PictureBox pictureBoxTanks;
+ private Label label1;
+ }
+}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/TankForm.cs b/ProjectTank/ProjectTank/TankForm.cs
new file mode 100644
index 0000000..44712a2
--- /dev/null
+++ b/ProjectTank/ProjectTank/TankForm.cs
@@ -0,0 +1,81 @@
+using System.Reflection.Emit;
+
+namespace ProjectTank
+{
+ ///
+ /// ""
+ ///
+ public partial class TankForm : Form
+ {
+ ///
+ /// -
+ ///
+ private DrawningTank? _drawningTank;
+ ///
+ ///
+ ///
+ public TankForm()
+ {
+ InitializeComponent();
+ }
+ ///
+ ///
+ ///
+ private void Draw()
+ {
+ if (_drawningTank == null)
+ {
+ return;
+ }
+ Bitmap bmp = new(pictureBoxTanks.Width, pictureBoxTanks.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _drawningTank.DrawTransport(gr);
+ pictureBoxTanks.Image = bmp;
+ }
+ ///
+ /// ""
+ ///
+ ///
+ ///
+ private void ButtonCreateTank_Click(object sender, EventArgs e)
+ {
+ Random random = new();
+ _drawningTank = new DrawningTank();
+ _drawningTank.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)),
+ pictureBoxTanks.Width, pictureBoxTanks.Height);
+ _drawningTank.SetPosition(random.Next(0, 100), random.Next(0, 100));
+ Draw();
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_drawningTank == null)
+ {
+ return;
+ }
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ switch (name)
+ {
+ case "buttonUp":
+ _drawningTank.MoveTransport(DirectionType.Up);
+ break;
+ case "buttonDown":
+ _drawningTank.MoveTransport(DirectionType.Down);
+ break;
+ case "buttonLeft":
+ _drawningTank.MoveTransport(DirectionType.Left);
+ break;
+ case "buttonRight":
+ _drawningTank.MoveTransport(DirectionType.Right);
+ break;
+ }
+ Draw();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/TankForm.resx b/ProjectTank/ProjectTank/TankForm.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/ProjectTank/ProjectTank/TankForm.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file