diff --git a/WinFormsApp1/Direction.cs b/WinFormsApp1/Direction.cs
new file mode 100644
index 0000000..5275f08
--- /dev/null
+++ b/WinFormsApp1/Direction.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WinFormsApp1
+{
+ internal enum Direction
+ {
+ Up = 1,
+ Down = 2,
+ Left = 3,
+ Right = 4,
+ DRDiagonal = 5,
+ DLDiagonal = 6,
+ ULDiagonal = 7,
+ URDiagonal = 8
+ }
+}
diff --git a/WinFormsApp1/EntityTractor.cs b/WinFormsApp1/EntityTractor.cs
new file mode 100644
index 0000000..dcb191f
--- /dev/null
+++ b/WinFormsApp1/EntityTractor.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Drawing;
+
+namespace WinFormsApp1
+{
+ class EntityTractor
+ {
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+ ///
+ /// Вес
+ ///
+ public float Weight { get; private set; }
+ ///
+ /// Цвет кузова
+ ///
+ public Color BodyColor { get; private set; }
+ ///
+ /// Шаг перемещения автомобиля
+ ///
+ public float Step => Speed * 100 / Weight;
+ ///
+ /// Инициализация полей объекта-класса автомобиля
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void Init(int speed, float weight, Color bodyColor)
+ {
+ Random rnd = new Random();
+ Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
+ Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
+ BodyColor = bodyColor;
+ }
+ }
+}
diff --git a/WinFormsApp1/FormTractor.Designer.cs b/WinFormsApp1/FormTractor.Designer.cs
new file mode 100644
index 0000000..d891929
--- /dev/null
+++ b/WinFormsApp1/FormTractor.Designer.cs
@@ -0,0 +1,184 @@
+
+namespace WinFormsApp1
+{
+ partial class FormTractor
+ {
+ ///
+ /// 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.pictureBoxTractor = new System.Windows.Forms.PictureBox();
+ this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).BeginInit();
+ this.statusStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // pictureBoxTractor
+ //
+ this.pictureBoxTractor.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxTractor.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxTractor.Name = "pictureBoxTractor";
+ this.pictureBoxTractor.Size = new System.Drawing.Size(800, 424);
+ this.pictureBoxTractor.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBoxTractor.TabIndex = 0;
+ this.pictureBoxTractor.TabStop = false;
+ this.pictureBoxTractor.Resize += new System.EventHandler(this.pictureBoxTractor_Resize);
+ //
+ // statusStrip1
+ //
+ this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusLabelSpeed,
+ this.toolStripStatusLabelWeight,
+ this.toolStripStatusLabelBodyColor});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 424);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Size = new System.Drawing.Size(800, 26);
+ this.statusStrip1.TabIndex = 1;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // toolStripStatusLabelSpeed
+ //
+ this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
+ this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(73, 20);
+ this.toolStripStatusLabelSpeed.Text = "Скорость";
+ //
+ // toolStripStatusLabelWeight
+ //
+ this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
+ this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(32, 20);
+ this.toolStripStatusLabelWeight.Text = "вес";
+ //
+ // toolStripStatusLabelBodyColor
+ //
+ this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
+ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(42, 20);
+ this.toolStripStatusLabelBodyColor.Text = "Цвет";
+ this.toolStripStatusLabelBodyColor.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreate.Location = new System.Drawing.Point(0, 378);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(94, 29);
+ this.buttonCreate.TabIndex = 2;
+ this.buttonCreate.Text = "создать";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::Tractors.Properties.Resources._2EdzyM4iEKw;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(682, 296);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 3;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.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::Tractors.Properties.Resources.Hhxt4dLqV5g;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(649, 332);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+ 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::Tractors.Properties.Resources.MbV2DYU_nPM;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(682, 332);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 5;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.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::Tractors.Properties.Resources.RkYIe2_6DuQ;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(718, 332);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 6;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // FormTractor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonRight);
+ this.Controls.Add(this.buttonDown);
+ this.Controls.Add(this.buttonLeft);
+ this.Controls.Add(this.buttonUp);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.pictureBoxTractor);
+ this.Controls.Add(this.statusStrip1);
+ this.Name = "FormTractor";
+ this.Text = "Трактор";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).EndInit();
+ this.statusStrip1.ResumeLayout(false);
+ this.statusStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PictureBox pictureBoxTractor;
+ private System.Windows.Forms.StatusStrip statusStrip1;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpeed;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelWeight;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelBodyColor;
+ private System.Windows.Forms.Button buttonCreate;
+ private System.Windows.Forms.Button buttonUp;
+ private System.Windows.Forms.Button buttonLeft;
+ private System.Windows.Forms.Button buttonDown;
+ private System.Windows.Forms.Button buttonRight;
+ }
+}
+
diff --git a/WinFormsApp1/FormTractor.cs b/WinFormsApp1/FormTractor.cs
new file mode 100644
index 0000000..7e4ca4b
--- /dev/null
+++ b/WinFormsApp1/FormTractor.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace WinFormsApp1
+{
+ public partial class FormTractor : Form
+ {
+ private TractorDraw _Tractor;
+
+ public FormTractor()
+ {
+ InitializeComponent();
+ }
+
+ private void Draw()
+ {
+ Bitmap bmp = new Bitmap(pictureBoxTractor.Width, pictureBoxTractor.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _Tractor?.DrawEntity(gr);
+ pictureBoxTractor.Image = bmp;
+ }
+
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ Random random = new Random();
+ _Tractor = new TractorDraw();
+ _Tractor.Init(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
+ _Tractor.SetPosition(random.Next(10, 50), random.Next(10, 50), pictureBoxTractor.Width, pictureBoxTractor.Height);
+ toolStripStatusLabelSpeed.Text = $"Скорость: {_Tractor.Tractor.Speed}";
+ toolStripStatusLabelWeight.Text = $"Вес: {_Tractor.Tractor.Weight}";
+ toolStripStatusLabelBodyColor.Text = $"Цвет: {_Tractor.Tractor.BodyColor.Name}";
+ Draw();
+ }
+
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ switch (name)
+ {
+ case "buttonUp":
+ _Tractor?.MoveTransport(Direction.Up);
+ break;
+ case "buttonDown":
+ _Tractor?.MoveTransport(Direction.Down);
+ break;
+ case "buttonLeft":
+ _Tractor?.MoveTransport(Direction.Left);
+ break;
+ case "buttonRight":
+ _Tractor?.MoveTransport(Direction.Right);
+ break;
+ }
+ Draw();
+ }
+
+
+
+
+
+ private void pictureBoxTractor_Resize(object sender, EventArgs e)
+ {
+ _Tractor?.ChangeBorders(pictureBoxTractor.Width, pictureBoxTractor.Height);
+ Draw();
+ }
+ }
+}
diff --git a/WinFormsApp1/FormTractor.resx b/WinFormsApp1/FormTractor.resx
new file mode 100644
index 0000000..5cb320f
--- /dev/null
+++ b/WinFormsApp1/FormTractor.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/WinFormsApp1/Program.cs b/WinFormsApp1/Program.cs
new file mode 100644
index 0000000..ab6b2a6
--- /dev/null
+++ b/WinFormsApp1/Program.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace WinFormsApp1
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.SetHighDpiMode(HighDpiMode.SystemAware);
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new FormTractor());
+ }
+ }
+}
diff --git a/WinFormsApp1/Properties/Resources.Designer.cs b/WinFormsApp1/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..8a5d1ee
--- /dev/null
+++ b/WinFormsApp1/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace Tractors.Properties {
+ using System;
+
+
+ ///
+ /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
+ ///
+ // Этот класс создан автоматически классом StronglyTypedResourceBuilder
+ // с помощью такого средства, как ResGen или Visual Studio.
+ // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
+ // с параметром /str или перестройте свой проект VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.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("Tractors.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 _2EdzyM4iEKw {
+ get {
+ object obj = ResourceManager.GetObject("2EdzyM4iEKw", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Hhxt4dLqV5g {
+ get {
+ object obj = ResourceManager.GetObject("Hhxt4dLqV5g", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap MbV2DYU_nPM {
+ get {
+ object obj = ResourceManager.GetObject("MbV2DYU_nPM", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap RkYIe2_6DuQ {
+ get {
+ object obj = ResourceManager.GetObject("RkYIe2_6DuQ", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/WinFormsApp1/Properties/Resources.resx b/WinFormsApp1/Properties/Resources.resx
new file mode 100644
index 0000000..c7554e4
--- /dev/null
+++ b/WinFormsApp1/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\2EdzyM4iEKw.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\RkYIe2_6DuQ.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\MbV2DYU_nPM.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\Hhxt4dLqV5g.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/WinFormsApp1/Resources/2EdzyM4iEKw.jpg b/WinFormsApp1/Resources/2EdzyM4iEKw.jpg
new file mode 100644
index 0000000..4ef24e3
Binary files /dev/null and b/WinFormsApp1/Resources/2EdzyM4iEKw.jpg differ
diff --git a/WinFormsApp1/Resources/Hhxt4dLqV5g.jpg b/WinFormsApp1/Resources/Hhxt4dLqV5g.jpg
new file mode 100644
index 0000000..37e77d7
Binary files /dev/null and b/WinFormsApp1/Resources/Hhxt4dLqV5g.jpg differ
diff --git a/WinFormsApp1/Resources/MbV2DYU_nPM.jpg b/WinFormsApp1/Resources/MbV2DYU_nPM.jpg
new file mode 100644
index 0000000..2ffbfc1
Binary files /dev/null and b/WinFormsApp1/Resources/MbV2DYU_nPM.jpg differ
diff --git a/WinFormsApp1/Resources/RkYIe2_6DuQ.jpg b/WinFormsApp1/Resources/RkYIe2_6DuQ.jpg
new file mode 100644
index 0000000..f097522
Binary files /dev/null and b/WinFormsApp1/Resources/RkYIe2_6DuQ.jpg differ
diff --git a/WinFormsApp1/Tractor.sln b/WinFormsApp1/Tractor.sln
new file mode 100644
index 0000000..28b34e8
--- /dev/null
+++ b/WinFormsApp1/Tractor.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31624.102
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tractors", "Tractors.csproj", "{735086BF-1E22-40C3-B173-CBAE6E9F5A81}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {735086BF-1E22-40C3-B173-CBAE6E9F5A81}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {773D5658-5E81-42A9-AD57-BBD613BEBDC0}
+ EndGlobalSection
+EndGlobal
diff --git a/WinFormsApp1/TractorDraw.cs b/WinFormsApp1/TractorDraw.cs
new file mode 100644
index 0000000..41341d8
--- /dev/null
+++ b/WinFormsApp1/TractorDraw.cs
@@ -0,0 +1,175 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Drawing;
+
+namespace WinFormsApp1
+{
+ class TractorDraw
+
+ {
+ //Сущность
+ public EntityTractor Tractor { get; private set; }
+ /// Левая координата отрисовки сущности
+ private float startPosX;
+ /// Верхняя кооридната отрисовки сущности
+ private float startPosY;
+ /// Ширина окна отрисовки
+ private int? pictureWidth = null;
+ /// Высота окна отрисовки
+ private int? pictureHeight = null;
+ /// Ширина отрисовки сущности
+ private readonly int entWidth = 130;
+ /// Высота отрисовки сущности
+ private readonly int entHeight = 100;
+
+ public void Init(int speed, float weight, Color bodycolor)
+ {
+ Tractor = new EntityTractor();
+ Tractor.Init(speed, weight, bodycolor);
+ }
+
+ //Установка позиции сущности
+ public void SetPosition(int x, int y, int width, int height)
+ {
+ if (x < 0 || y < 0 || width < x + entWidth || height < y + entHeight)
+ {
+ pictureHeight = null;
+ pictureWidth = null;
+ return;
+ }
+ startPosX = x;
+ startPosY = y;
+ pictureHeight = height;
+ pictureWidth = width;
+ }
+
+ //Изменение направления перемещения
+ public void MoveTransport(Direction direction)
+ {
+ if (!pictureWidth.HasValue || !pictureHeight.HasValue)
+ {
+ return;
+ }
+ switch (direction)
+ {
+ case Direction.Right:
+ if (startPosX + entWidth + Tractor.Step < pictureWidth)
+ {
+ startPosX += Tractor.Step;
+ }
+ break;
+ case Direction.Left:
+ if (startPosX - 10 - Tractor.Step > 0)
+ {
+ startPosX -= Tractor.Step;
+ }
+ break;
+ case Direction.Down:
+ if (startPosY + entHeight + Tractor.Step < pictureHeight)
+ {
+ startPosY += Tractor.Step;
+ }
+ break;
+ case Direction.Up:
+ if (startPosY - Tractor.Step > 0)
+ {
+ startPosY -= Tractor.Step;
+ }
+ break;
+ case Direction.DRDiagonal:
+ if (startPosX + entWidth + Tractor.Step < pictureWidth && startPosY + entHeight + Tractor.Step < pictureHeight)
+ {
+ startPosX += Tractor.Step;
+ startPosY += Tractor.Step;
+ }
+ break;
+ case Direction.DLDiagonal:
+ if (startPosY + entHeight + Tractor.Step < pictureHeight && startPosX - 10 - Tractor.Step > 0)
+ {
+ startPosY += Tractor.Step;
+ startPosX -= Tractor.Step;
+ }
+ break;
+ case Direction.URDiagonal:
+ if (startPosY - Tractor.Step > 0 && startPosX + entWidth + Tractor.Step < pictureWidth)
+ {
+ startPosY -= Tractor.Step;
+ startPosX += Tractor.Step;
+ }
+ break;
+ case Direction.ULDiagonal:
+ if (startPosY - Tractor.Step > 0 && startPosX - 10 - Tractor.Step > 0)
+ {
+ startPosY -= Tractor.Step;
+ startPosX -= Tractor.Step;
+ }
+ break;
+
+ }
+ }
+
+ //Отрисовка сущности
+ public void DrawEntity(Graphics g)
+ {
+ if (startPosX < 0 || startPosY < 0 || !pictureHeight.HasValue || !pictureWidth.HasValue)
+ {
+ return;
+ }
+
+ Pen pen_Black_1pxl = new Pen(Color.Black, 1);
+ Pen pen_Black_2pxl = new Pen(Color.Black, 2);
+
+ g.DrawRectangle(pen_Black_1pxl, startPosX, startPosY, 40, 30);
+ g.DrawRectangle(pen_Black_1pxl, startPosX, startPosY + 30, 100, 35);
+ g.DrawRectangle(pen_Black_1pxl, startPosX + 72, startPosY + 10, 5, 20);
+ g.DrawEllipse(pen_Black_1pxl, startPosX - 15, startPosY + 67, 30, 30);
+ g.DrawEllipse(pen_Black_1pxl, startPosX + 85, startPosY + 67, 30, 30);
+ g.DrawEllipse(pen_Black_1pxl, startPosX + 20, startPosY + 82, 15, 15);
+ g.DrawEllipse(pen_Black_1pxl, startPosX + 40, startPosY + 82, 15, 15);
+ g.DrawEllipse(pen_Black_1pxl, startPosX + 60, startPosY + 82, 15, 15);
+ g.DrawEllipse(pen_Black_1pxl, startPosX + 35, startPosY + 68, 10, 10);
+ g.DrawEllipse(pen_Black_1pxl, startPosX + 55, startPosY + 68, 10, 10);
+
+ g.DrawLine(pen_Black_2pxl, startPosX, startPosY + 67, startPosX + 100, startPosY + 67);
+ g.DrawLine(pen_Black_2pxl, startPosX, startPosY + 97, startPosX + 100, startPosY + 97);
+
+ Brush br = new SolidBrush(Tractor?.BodyColor ?? Color.Black);
+ g.FillRectangle(br, startPosX, startPosY, 40, 30);
+ g.FillRectangle(br, startPosX, startPosY + 30, 100, 35);
+
+ Brush brBlack = new SolidBrush(Color.Black);
+ g.FillRectangle(brBlack, startPosX + 72, startPosY + 10, 5, 20);
+ g.FillEllipse(brBlack, startPosX - 15, startPosY + 67, 30, 30);
+ g.FillEllipse(brBlack, startPosX + 85, startPosY + 67, 30, 30);
+ g.FillEllipse(brBlack, startPosX + 20, startPosY + 82, 15, 15);
+ g.FillEllipse(brBlack, startPosX + 40, startPosY + 82, 15, 15);
+ g.FillEllipse(brBlack, startPosX + 60, startPosY + 82, 15, 15);
+ g.FillEllipse(brBlack, startPosX + 35, startPosY + 68, 10, 10);
+ g.FillEllipse(brBlack, startPosX + 55, startPosY + 68, 10, 10);
+ }
+
+ //Смена границ формы
+ public void ChangeBorders(int width, int height)
+ {
+ pictureWidth = width;
+ pictureHeight = height;
+ if (pictureWidth <= entWidth || pictureHeight <= entHeight)
+ {
+ pictureWidth = null;
+ pictureHeight = null;
+ return;
+ }
+ if (startPosX + entWidth > pictureWidth)
+ {
+ startPosX = pictureWidth.Value - entWidth;
+ }
+ if (startPosY + entHeight > pictureHeight)
+ {
+ startPosY = pictureHeight.Value - entHeight;
+ }
+ }
+ }
+}
diff --git a/WinFormsApp1/Tractors.csproj b/WinFormsApp1/Tractors.csproj
new file mode 100644
index 0000000..ef04a4f
--- /dev/null
+++ b/WinFormsApp1/Tractors.csproj
@@ -0,0 +1,24 @@
+
+
+
+ WinExe
+ netcoreapp3.1
+ true
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
\ No newline at end of file