diff --git a/ProjectExcavator/ProjectExcavator/DirectionType.cs b/ProjectExcavator/ProjectExcavator/DirectionType.cs
new file mode 100644
index 0000000..3495f44
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/DirectionType.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectExcavator
+{
+ public enum DirectionType
+ {
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+ ///
+ /// Влево
+ ///
+ Left = 3,
+ ///
+ /// Вправо
+ ///
+ Right = 4
+ }
+}
diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
new file mode 100644
index 0000000..6a25801
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
@@ -0,0 +1,172 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectExcavator
+{
+ internal class DrawningExcavator
+ {
+ ///
+ /// Класс-сущность
+ ///
+ public EntityExcavator? EntityExcavator { get; private set; }
+ ///
+ /// Ширина окна
+ ///
+ private int _pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ private int _pictureHeight;
+ ///
+ /// Левая координата прорисовки автомобиля
+ ///
+ private int _startPosX;
+ ///
+ /// Верхняя кооридната прорисовки автомобиля
+ ///
+ private int _startPosY;
+ ///
+ /// Ширина прорисовки автомобиля
+ ///
+ private readonly int _excavatorWidth = 190;
+ ///
+ /// Высота прорисовки автомобиля
+ ///
+ private readonly int _excavatorHeight = 170;
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия вспомогательных опор
+ /// Признак наличия ковша
+ /// Ширина картинки
+ /// Высота картинки
+ /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах
+ public bool Init(int speed, double weight, Color bodyColor, Color
+ additionalColor, bool bodyKit, bool backet, int width, int height)
+ {
+ // TODO: Продумать проверки
+ _pictureWidth = width;
+ _pictureHeight = height;
+ EntityExcavator = new EntityExcavator();
+ EntityExcavator.Init(speed, weight, bodyColor, additionalColor, bodyKit, backet);
+ return true;
+ }
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ // TODO: Изменение x, y
+ _startPosX = x;
+ _startPosY = y;
+
+
+ }
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ public void MoveTransport(DirectionType direction)
+ {
+ if (EntityExcavator == null)
+ {
+ return;
+ }
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX - EntityExcavator.Step > 0)
+ {
+ _startPosX -= (int)EntityExcavator.Step;
+ }
+ break;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY - EntityExcavator.Step > -50)
+ {
+ _startPosY -= (int)EntityExcavator.Step;
+ }
+ break;
+ // вправо
+ case DirectionType.Right:
+ if (_startPosX + EntityExcavator.Step < _pictureWidth - _excavatorWidth)
+ {
+ _startPosX += (int)EntityExcavator.Step;
+ }
+ break;
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY + EntityExcavator.Step < _pictureHeight - _excavatorHeight)
+ {
+ _startPosY += (int)EntityExcavator.Step;
+ }
+ break;
+ }
+ }
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public void DrawTransport(Graphics g)
+ {
+ if (EntityExcavator == null)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+
+ Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor);
+ if (EntityExcavator.BodyKit)
+ {
+ g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 120, 130, 10);
+ g.DrawLine(pen, _startPosX + 20, _startPosY + 120, _startPosX + 150, _startPosY + 120);
+ }
+ //корпус
+ Brush bodyBrush = new SolidBrush(Color.Red);
+ g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 110, 130, 20);
+ g.FillRectangle(bodyBrush, _startPosX + 100, _startPosY + 70, 30, 40);
+ g.FillRectangle(bodyBrush, _startPosX + 30, _startPosY + 90, 10, 20);
+ g.DrawRectangle(pen, _startPosX + 20, _startPosY + 110, 130, 20);
+ g.DrawRectangle(pen, _startPosX + 100, _startPosY + 70, 30, 40);
+ g.DrawRectangle(pen, _startPosX + 30, _startPosY + 90, 10, 20);
+ //гусеница
+ Point[] points = {
+ new Point(_startPosX + 20, _startPosY + 130),
+ new Point(_startPosX + 15, _startPosY+ 135),
+ new Point(_startPosX + 15, _startPosY + 145),
+ new Point(_startPosX + 20, _startPosY + 150),
+ new Point(_startPosX + 145, _startPosY + 150),
+ new Point(_startPosX + 150, _startPosY + 145),
+ new Point(_startPosX + 150, _startPosY + 135),
+ new Point(_startPosX + 145, _startPosY + 130)};
+ g.DrawPolygon(pen, points);
+ g.DrawEllipse(pen, _startPosX + 20, _startPosY + 130, 20, 20);
+ g.DrawEllipse(pen, _startPosX + 40, _startPosY + 130, 20, 20);
+ g.DrawEllipse(pen, _startPosX + 60, _startPosY + 130, 20, 20);
+ g.DrawEllipse(pen, _startPosX + 80, _startPosY + 130, 20, 20);
+ g.DrawEllipse(pen, _startPosX + 100, _startPosY + 130, 20, 20);
+ g.DrawEllipse(pen, _startPosX + 120, _startPosY + 130, 20, 20);
+ //ковш
+ if (EntityExcavator.Backet)
+ {
+ Point[] pointsBacket = {
+ new Point(_startPosX + 150, _startPosY + 75),
+ new Point(_startPosX + 150, _startPosY + 135),
+ new Point(_startPosX + 195, _startPosY + 135),
+ };
+ g.FillPolygon(additionalBrush, pointsBacket);
+ g.DrawPolygon(pen, pointsBacket);
+ }
+ }
+ }
+}
diff --git a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs
new file mode 100644
index 0000000..6189140
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectExcavator
+{
+ internal class EntityExcavator
+ {
+ //
+ /// Скорость
+ ///
+ 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 BodyKit { get; private set; }
+ ///
+ /// Признак (опция) наличия ковша
+ ///
+ public bool Backet { get; private set; }
+
+ ///
+ /// Шаг перемещения автомобиля
+ ///
+ public double Step => (double)Speed * 100 / Weight;
+ ///
+ /// Инициализация полей объекта-класса спортивного автомобиля
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+
+ public void Init(int speed, double weight, Color bodyColor, Color
+ additionalColor, bool bodyKit, bool backet)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ BodyKit = bodyKit;
+ Backet = backet;
+ }
+ }
+}
diff --git a/ProjectExcavator/ProjectExcavator/Form1.Designer.cs b/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs
similarity index 72%
rename from ProjectExcavator/ProjectExcavator/Form1.Designer.cs
rename to ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs
index 451fd85..81929e4 100644
--- a/ProjectExcavator/ProjectExcavator/Form1.Designer.cs
+++ b/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs
@@ -1,6 +1,6 @@
namespace ProjectExcavator
{
- partial class Form1
+ partial class ExcavatorForm
{
///
/// Required designer variable.
@@ -28,10 +28,16 @@
///
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";
+ SuspendLayout();
+ //
+ // Form1
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Name = "Form1";
+ Text = "Excavator";
+ ResumeLayout(false);
}
#endregion
diff --git a/ProjectExcavator/ProjectExcavator/Form1.cs b/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs
similarity index 55%
rename from ProjectExcavator/ProjectExcavator/Form1.cs
rename to ProjectExcavator/ProjectExcavator/ExcavatorForm.cs
index 1eb2162..84a8ad1 100644
--- a/ProjectExcavator/ProjectExcavator/Form1.cs
+++ b/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs
@@ -1,8 +1,8 @@
namespace ProjectExcavator
{
- public partial class Form1 : Form
+ public partial class ExcavatorForm : Form
{
- public Form1()
+ public ExcavatorForm()
{
InitializeComponent();
}
diff --git a/ProjectExcavator/ProjectExcavator/Form1.resx b/ProjectExcavator/ProjectExcavator/ExcavatorForm.resx
similarity index 93%
rename from ProjectExcavator/ProjectExcavator/Form1.resx
rename to ProjectExcavator/ProjectExcavator/ExcavatorForm.resx
index 1af7de1..af32865 100644
--- a/ProjectExcavator/ProjectExcavator/Form1.resx
+++ b/ProjectExcavator/ProjectExcavator/ExcavatorForm.resx
@@ -1,17 +1,17 @@
-
diff --git a/ProjectExcavator/ProjectExcavator/Program.cs b/ProjectExcavator/ProjectExcavator/Program.cs
index c5b8144..dc8b98b 100644
--- a/ProjectExcavator/ProjectExcavator/Program.cs
+++ b/ProjectExcavator/ProjectExcavator/Program.cs
@@ -11,7 +11,7 @@ namespace ProjectExcavator
// 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 ExcavatorForm());
}
}
}
\ No newline at end of file
diff --git a/lab_1_pojectExcavator/lab_1_pojectExcavator/DirectionType.cs b/lab_1_pojectExcavator/lab_1_pojectExcavator/DirectionType.cs
index 756e729..ed5781a 100644
--- a/lab_1_pojectExcavator/lab_1_pojectExcavator/DirectionType.cs
+++ b/lab_1_pojectExcavator/lab_1_pojectExcavator/DirectionType.cs
@@ -18,6 +18,5 @@
/// Вправо
///
Right = 4
-
}
}