From 2e0d5600ec72734b4468bddde55752216c75da33 Mon Sep 17 00:00:00 2001 From: "Pyatkin I.A" <4234.sunrise.234@gmail.com> Date: Sun, 15 Oct 2023 18:05:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D0=B0=D1=8F=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectExcavator/Directions.cs | 31 ++ .../ProjectExcavator/DrawingExcavator.cs | 301 ++++++++++++++++++ .../ProjectExcavator/EntityExcavator.cs | 59 ++++ .../ProjectExcavator/Form1.Designer.cs | 39 --- ProjectExcavator/ProjectExcavator/Form1.cs | 10 - .../FormExcavator.Designer.cs | 135 ++++++++ .../ProjectExcavator/FormExcavator.cs | 63 ++++ .../ProjectExcavator/FormExcavator.resx | 60 ++++ ProjectExcavator/ProjectExcavator/Program.cs | 2 +- .../ProjectExcavator/ProjectExcavator.csproj | 15 + .../Properties/Resources.Designer.cs | 103 ++++++ .../{Form1.resx => Properties/Resources.resx} | 13 + .../ProjectExcavator/Resources/down.png | Bin 0 -> 1015 bytes .../ProjectExcavator/Resources/up.png | Bin 0 -> 1981 bytes .../ProjectExcavator/Resources/влево.png | Bin 0 -> 1094 bytes .../ProjectExcavator/Resources/право.png | Bin 0 -> 1015 bytes 16 files changed, 781 insertions(+), 50 deletions(-) create mode 100644 ProjectExcavator/ProjectExcavator/Directions.cs create mode 100644 ProjectExcavator/ProjectExcavator/DrawingExcavator.cs create mode 100644 ProjectExcavator/ProjectExcavator/EntityExcavator.cs delete mode 100644 ProjectExcavator/ProjectExcavator/Form1.Designer.cs delete mode 100644 ProjectExcavator/ProjectExcavator/Form1.cs create mode 100644 ProjectExcavator/ProjectExcavator/FormExcavator.Designer.cs create mode 100644 ProjectExcavator/ProjectExcavator/FormExcavator.cs create mode 100644 ProjectExcavator/ProjectExcavator/FormExcavator.resx create mode 100644 ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs rename ProjectExcavator/ProjectExcavator/{Form1.resx => Properties/Resources.resx} (83%) create mode 100644 ProjectExcavator/ProjectExcavator/Resources/down.png create mode 100644 ProjectExcavator/ProjectExcavator/Resources/up.png create mode 100644 ProjectExcavator/ProjectExcavator/Resources/влево.png create mode 100644 ProjectExcavator/ProjectExcavator/Resources/право.png diff --git a/ProjectExcavator/ProjectExcavator/Directions.cs b/ProjectExcavator/ProjectExcavator/Directions.cs new file mode 100644 index 0000000..9095f8c --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/Directions.cs @@ -0,0 +1,31 @@ +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/DrawingExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawingExcavator.cs new file mode 100644 index 0000000..078186e --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/DrawingExcavator.cs @@ -0,0 +1,301 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectExcavator +{ + public class DrawingExcavator + { + /// + /// Класс-сущность + /// + public EntityExcavator? EntityExcavator { get; private set; } + /// + /// Ширина окна + /// + private int _pictureWidth; + /// + /// Высота окна + /// + private int _pictureHeight; + /// + /// /// Левая координата прорисовки автомобиля + /// + private int _startPosX; + /// + /// Верхняя кооридната прорисовки автомобиля + /// + private int _startPosY; + /// + /// Ширина прорисовки автомобиля + /// + private int _exWidth; + /// + /// Высота прорисовки автомобиля + /// + private int _exHeight; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Цвет кузова + /// Дополнительный цвет + /// Ширина картинки + /// Высота картинки + /// Ковш + /// Катки гусеничные + /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool kovsh, bool katki, int width, int height) + { + if (width < _pictureWidth || height < _pictureHeight) + { + return false; + } + + if (!kovsh) + { + _exWidth = 105; + _exHeight = 75; + } + else + { + _exWidth = 140; + _exHeight = 87; + } + _pictureWidth = width; + _pictureHeight = height; + EntityExcavator = new EntityExcavator(); + EntityExcavator.Init(speed, weight, bodyColor, additionalColor, kovsh, katki); + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + // TODO: Изменение x, y + if (x < 0) + { + x = 0; + } + else if (x > _pictureWidth - _exWidth) + { + x = _pictureWidth - _exWidth; + } + + if (y < 0) + { + y = 0; + } + else if (y > _pictureHeight - _exHeight) + { + y = _pictureHeight - _exHeight; + } + _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; + } + else + { + _startPosX = 0; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityExcavator.Step > 0) + { + _startPosY -= (int)EntityExcavator.Step; + } + else + { + _startPosY = 0; + } + break; + //вправо + case DirectionType.Right: + if (_startPosX + _exWidth + EntityExcavator.Step <= _pictureWidth) + { + _startPosX += (int)EntityExcavator.Step; + } + else + { + _startPosX = _pictureWidth - _exWidth; + } + break; + //вниз + case DirectionType.Down: + if (_startPosY + _exHeight + EntityExcavator.Step <= _pictureHeight) + { + _startPosY += (int)EntityExcavator.Step; + } + else + { + _startPosY = _pictureHeight - _exHeight; + } + break; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityExcavator == null) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityExcavator.AdditionalColor); + //цвета + Brush brBlue = new SolidBrush(Color.LightBlue); + Brush brYellow = new SolidBrush(Color.Yellow); + Brush brGray = new SolidBrush(Color.Gray); + Brush brBlack = new SolidBrush(Color.Black); + //отрисовка экскаватора без ковша + if (!EntityExcavator.Kovsh) + { + g.DrawRectangle(pen, _startPosX + 15, _startPosY + 25, 75, 25); + g.DrawRectangle(pen, _startPosX + 60, _startPosY, 30, 25); + g.DrawRectangle(pen, _startPosX + 30, _startPosY + 5, 10, 20); + g.DrawRectangle(pen, _startPosX + 10, _startPosY + 55, 86, 20); + g.DrawPie(pen, _startPosX, _startPosY + 55, 20, 20, 90, 180); + g.DrawPie(pen, _startPosX + 85, _startPosY + 55, 20, 20, 270, 180); + g.DrawEllipse(pen, _startPosX + 5, _startPosY + 58, 15, 15); + g.DrawEllipse(pen, _startPosX + 85, _startPosY + 58, 15, 15); + g.DrawEllipse(pen, _startPosX + 25, _startPosY + 65, 8, 8); + g.DrawEllipse(pen, _startPosX + 45, _startPosY + 65, 8, 8); + g.DrawEllipse(pen, _startPosX + 65, _startPosY + 65, 8, 8); + g.DrawEllipse(pen, _startPosX + 37, _startPosY + 58, 6, 6); + g.DrawEllipse(pen, _startPosX + 57, _startPosY + 58, 6, 6); + //кабина водителя + g.FillRectangle(brBlue, _startPosX + 61, _startPosY + 1, 29, 24); + // кузов + g.FillRectangle(brYellow, _startPosX + 16, _startPosY + 26, 74, 24); + // труба + g.FillRectangle(brYellow, _startPosX + 31, _startPosY + 6, 9, 19); + //гусеница + g.FillPie(brGray, _startPosX, _startPosY + 55, 20, 20, 90, 180); + g.FillPie(brGray, _startPosX + 85, _startPosY + 55, 20, 20, 270, 180); + g.FillRectangle(brGray, _startPosX + 10, _startPosY + 55, 86, 20); + g.FillEllipse(brBlack, _startPosX + 5, _startPosY + 58, 15, 15); + g.FillEllipse(brBlack, _startPosX + 85, _startPosY + 58, 15, 15); + g.FillEllipse(brBlack, _startPosX + 25, _startPosY + 65, 8, 8); + g.FillEllipse(brBlack, _startPosX + 45, _startPosY + 65, 8, 8); + g.FillEllipse(brBlack, _startPosX + 65, _startPosY + 65, 8, 8); + g.FillEllipse(brBlack, _startPosX + 37, _startPosY + 58, 6, 6); + g.FillEllipse(brBlack, _startPosX + 57, _startPosY + 58, 6, 6); + } + //отрисовка экскаватора с ковшом + if (EntityExcavator.Kovsh) + { + //экскаватор + g.DrawRectangle(pen, _startPosX + 50, _startPosY + 35, 75, 25); + g.DrawRectangle(pen, _startPosX + 95, _startPosY + 10, 30, 25); + g.DrawRectangle(pen, _startPosX + 60, _startPosY + 15, 10, 20); + g.DrawRectangle(pen, _startPosX + 44, _startPosY + 65, 86, 20); + g.DrawPie(pen, _startPosX + 34, _startPosY + 65, 20, 20, 90, 180); + g.DrawPie(pen, _startPosX + 120, _startPosY + 65, 20, 20, 270, 180); + g.DrawEllipse(pen, _startPosX + 40, _startPosY + 68, 15, 15); + g.DrawEllipse(pen, _startPosX + 120, _startPosY + 68, 15, 15); + g.DrawEllipse(pen, _startPosX + 60, _startPosY + 76, 8, 8); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 76, 8, 8); + g.DrawEllipse(pen, _startPosX + 100, _startPosY + 76, 8, 8); + g.DrawEllipse(pen, _startPosX + 72, _startPosY + 68, 6, 6); + g.DrawEllipse(pen, _startPosX + 92, _startPosY + 68, 6, 6); + //кабина водителя + g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 11, 29, 24); + // кузов + g.FillRectangle(brYellow, _startPosX + 51, _startPosY + 36, 74, 24); + // труба + g.FillRectangle(brYellow, _startPosX + 61, _startPosY + 16, 9, 19); + //гусеница + g.FillPie(brGray, _startPosX + 34, _startPosY + 65, 20, 20, 90, 180); + g.FillPie(brGray, _startPosX + 120, _startPosY + 65, 20, 20, 270, 180); + g.FillRectangle(brGray, _startPosX + 44, _startPosY + 65, 86, 20); + g.FillEllipse(brBlack, _startPosX + 40, _startPosY + 68, 15, 15); + g.FillEllipse(brBlack, _startPosX + 120, _startPosY + 68, 15, 15); + g.FillEllipse(brBlack, _startPosX + 60, _startPosY + 76, 8, 8); + g.FillEllipse(brBlack, _startPosX + 80, _startPosY + 76, 8, 8); + g.FillEllipse(brBlack, _startPosX + 100, _startPosY + 76, 8, 8); + g.FillEllipse(brBlack, _startPosX + 72, _startPosY + 68, 6, 6); + g.FillEllipse(brBlack, _startPosX + 92, _startPosY + 68, 6, 6); + //ковш + g.DrawLine(pen, _startPosX + 50, _startPosY + 35, _startPosX + 10, _startPosY + 10); + g.DrawLine(pen, _startPosX + 58, _startPosY + 35, _startPosX + 12, _startPosY + 5); + g.DrawEllipse(pen, _startPosX + 7, _startPosY + 4, 7, 7); + g.DrawLine(pen, _startPosX + 10, _startPosY + 10, _startPosX + 10, _startPosY + 45); + g.DrawLine(pen, _startPosX + 14, _startPosY + 5, _startPosX + 14, _startPosY + 45); + g.DrawPie(pen, _startPosX, _startPosY + 44, 28, 30, 90, 180); + g.DrawLine(pen, _startPosX + 14, _startPosY + 5, _startPosX + 14, _startPosY); + g.DrawLine(pen, _startPosX + 14, _startPosY, _startPosX + 7, _startPosY + 10); + g.DrawLine(pen, _startPosX + 14, _startPosY, _startPosX + 50, _startPosY + 12); + g.DrawLine(pen, _startPosX + 14, _startPosY, _startPosX + 50, _startPosY + 16); + g.DrawLine(pen, _startPosX + 50, _startPosY + 12, _startPosX + 50, _startPosY + 29); + + g.FillEllipse(additionalBrush, _startPosX + 7, _startPosY + 4, 7, 7); + g.FillPie(brBlack, _startPosX, _startPosY + 44, 28, 30, 90, 180); + Point point1 = new Point(_startPosX + 50, _startPosY + 35); + Point point2 = new Point(_startPosX + 10, _startPosY + 10); + Point point3 = new Point(_startPosX + 12, _startPosY + 5); + Point point4 = new Point(_startPosX + 58, _startPosY + 35); + Point[] truba_1 = { point1, point2, point3, point4, point1 }; + g.FillPolygon(additionalBrush, truba_1); + + Point point5 = new Point(_startPosX + 10, _startPosY + 10); + Point point6 = new Point(_startPosX + 10, _startPosY + 45); + Point point7 = new Point(_startPosX + 14, _startPosY + 45); + Point point8 = new Point(_startPosX + 14, _startPosY + 5); + Point[] truba_2 = { point5, point6, point7, point8, point5 }; + g.FillPolygon(additionalBrush, truba_2); + + Point point9 = new Point(_startPosX + 14, _startPosY + 5); + Point point10 = new Point(_startPosX + 14, _startPosY); + Point point11 = new Point(_startPosX + 7, _startPosY + 10); + Point[] triangle = { point9, point10, point11, point9 }; + g.FillPolygon(additionalBrush, triangle); + + Point point12 = new Point(_startPosX + 14, _startPosY); + Point point13 = new Point(_startPosX + 50, _startPosY + 12); + Point point14 = new Point(_startPosX + 50, _startPosY + 16); + Point point15 = new Point(_startPosX + 14, _startPosY); + Point[] krepl = { point12, point13, point14, point15, point12 }; + g.FillPolygon(additionalBrush, krepl); + } + //катки гусеничные + if (!EntityExcavator.Katki && EntityExcavator.Kovsh) + { + g.FillEllipse(additionalBrush, _startPosX + 40, _startPosY + 68, 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 120, _startPosY + 68, 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 60, _startPosY + 76, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 80, _startPosY + 76, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 100, _startPosY + 76, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 72, _startPosY + 68, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 92, _startPosY + 68, 6, 6); + } + } + } +} diff --git a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs new file mode 100644 index 0000000..0693af1 --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectExcavator +{ + public class EntityExcavator + { + /// + /// Скорость + /// + public int Speed { get; private set; } + /// + /// Вес + /// + public double Weight { get; private set; } + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + /// + /// Ковш + /// + public bool Kovsh { get; private set; } + /// + /// Катки гусеничные + /// + public bool Katki { get; private set; } + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } + /// + /// Шаг перемещения автомобиля + /// + public double Step => (double)Speed * 100 / Weight; + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Ковш + /// Катки гусеничные + public void Init(int speed, double weight, Color bodyColor, Color + additionalColor, bool kovsh, bool katki) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Kovsh = kovsh; + Katki = katki; + } + } +} diff --git a/ProjectExcavator/ProjectExcavator/Form1.Designer.cs b/ProjectExcavator/ProjectExcavator/Form1.Designer.cs deleted file mode 100644 index 451fd85..0000000 --- a/ProjectExcavator/ProjectExcavator/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectExcavator -{ - 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/ProjectExcavator/ProjectExcavator/Form1.cs b/ProjectExcavator/ProjectExcavator/Form1.cs deleted file mode 100644 index 1eb2162..0000000 --- a/ProjectExcavator/ProjectExcavator/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectExcavator -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/FormExcavator.Designer.cs b/ProjectExcavator/ProjectExcavator/FormExcavator.Designer.cs new file mode 100644 index 0000000..4dc3b95 --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/FormExcavator.Designer.cs @@ -0,0 +1,135 @@ +namespace ProjectExcavator +{ + partial class FormExcavator + { + /// + /// 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.pictureBoxExcavator = new System.Windows.Forms.PictureBox(); + this.buttonCreate = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxExcavator)).BeginInit(); + this.SuspendLayout(); + // + // pictureBoxExcavator + // + this.pictureBoxExcavator.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxExcavator.Location = new System.Drawing.Point(0, 0); + this.pictureBoxExcavator.Name = "pictureBoxExcavator"; + this.pictureBoxExcavator.Size = new System.Drawing.Size(884, 461); + this.pictureBoxExcavator.TabIndex = 0; + this.pictureBoxExcavator.TabStop = false; + // + // 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, 438); + this.buttonCreate.Name = "buttonCreate"; + this.buttonCreate.Size = new System.Drawing.Size(75, 23); + this.buttonCreate.TabIndex = 1; + this.buttonCreate.Text = "Создать"; + this.buttonCreate.UseVisualStyleBackColor = true; + this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click); + // + // buttonLeft + // + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonLeft.BackgroundImage = global::ProjectExcavator.Properties.Resources.влево; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonLeft.Location = new System.Drawing.Point(761, 431); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 2; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click); + // + // buttonUp + // + this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUp.BackgroundImage = global::ProjectExcavator.Properties.Resources.up; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonUp.Location = new System.Drawing.Point(797, 395); + 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); + // + // buttonRight + // + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.BackgroundImage = global::ProjectExcavator.Properties.Resources.право; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonRight.Location = new System.Drawing.Point(833, 431); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 4; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.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::ProjectExcavator.Properties.Resources.down; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonDown.Location = new System.Drawing.Point(797, 431); + 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); + // + // FormExcavator + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(884, 461); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonUp); + this.Controls.Add(this.buttonLeft); + this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.pictureBoxExcavator); + this.Name = "FormExcavator"; + this.Text = "FormExcavator"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxExcavator)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private PictureBox pictureBoxExcavator; + private Button buttonCreate; + private Button buttonLeft; + private Button buttonUp; + private Button buttonRight; + private Button buttonDown; + } +} \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/FormExcavator.cs b/ProjectExcavator/ProjectExcavator/FormExcavator.cs new file mode 100644 index 0000000..852ece9 --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/FormExcavator.cs @@ -0,0 +1,63 @@ +namespace ProjectExcavator +{ + public partial class FormExcavator : Form + { + + private DrawingExcavator? _drawingExcavator; + public FormExcavator() + { + InitializeComponent(); + } + + private void Draw() + { + if (_drawingExcavator == null) + { + return; + } + Bitmap bmp = new(pictureBoxExcavator.Width, pictureBoxExcavator.Height); + Graphics g = Graphics.FromImage(bmp); + _drawingExcavator.DrawTransport(g); + pictureBoxExcavator.Image = bmp; + } + + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawingExcavator = new DrawingExcavator(); + _drawingExcavator.Init(random.Next(300, 1000), random.Next(1000, 2000), + 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)), + pictureBoxExcavator.Width, pictureBoxExcavator.Height); + _drawingExcavator.SetPosition(random.Next(100, 300), random.Next(100, 300)); + Draw(); + } + + private void buttonMove_Click(object sender, EventArgs e) + { + if (_drawingExcavator == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawingExcavator.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawingExcavator.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawingExcavator.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawingExcavator.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } + } +} \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/FormExcavator.resx b/ProjectExcavator/ProjectExcavator/FormExcavator.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/FormExcavator.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 diff --git a/ProjectExcavator/ProjectExcavator/Program.cs b/ProjectExcavator/ProjectExcavator/Program.cs index c5b8144..59b8c54 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 FormExcavator()); } } } \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj b/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj index b57c89e..13ee123 100644 --- a/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj +++ b/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs b/ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs new file mode 100644 index 0000000..12dc887 --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectExcavator.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("ProjectExcavator.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 up { + get { + object obj = ResourceManager.GetObject("up", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap влево { + get { + object obj = ResourceManager.GetObject("влево", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap право { + get { + object obj = ResourceManager.GetObject("право", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectExcavator/ProjectExcavator/Form1.resx b/ProjectExcavator/ProjectExcavator/Properties/Resources.resx similarity index 83% rename from ProjectExcavator/ProjectExcavator/Form1.resx rename to ProjectExcavator/ProjectExcavator/Properties/Resources.resx index 1af7de1..17c3c79 100644 --- a/ProjectExcavator/ProjectExcavator/Form1.resx +++ b/ProjectExcavator/ProjectExcavator/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\право.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/Resources/down.png b/ProjectExcavator/ProjectExcavator/Resources/down.png new file mode 100644 index 0000000000000000000000000000000000000000..c6f6fa04c6ab601af8a2362d448d390208cc4ae0 GIT binary patch literal 1015 zcmeAS@N?(olHy`uVBq!ia0vp^4?&oN8Ax*GDtQ2@`~aU2*Z=?j1DW&Y&0Dx|;qv9n z&!0a(ckbNFmoNYR{d>uhCD*Q9yKv#cw{PEkeSOo@(?5LpASESLP*AXY_wE-jUYMGi ze*E|`G&I!3#pThXM<-973=0dJG-=Y|!-v% z9*MIyDHx#4$fN3eK}98dWwT=_b&O3?wpsa3ty{# zGf<2Y`>vbZFT7xrq7H~kbhhZR^=r^L((m+VP!s$SJ8a@l?ft*$-=V)dV{B~hKF%$> z-WeWzzqPjY>FckDE(R~FS#Z?d_VbP6RR4$RwNJI)g|p|sYx^efo3s9&o~>Q(t@_Mb z`>%H@GxZZ6?=##lyYr{-m3N_Ulyexmw=X|;XMJ(-3zcsI>!P>!RtV{@4UBQw`yu@I zy5-CH*R9Jr|Hz^{E0H}yhN)*=&V9*a`?{hYZY(~%USYHL@3rb$t+5Fo;wJp-|mtz!8tzIE`?q197qjl!8nVnn zi0Z`)vu2sE^4DN`oF6#3>xG~i@0Gc(+doWrCuXX7Zc%W>4=}yxjsB ztgBcPZ?pZmjZ-{ms2(fp4 zzgfWANpQw5G1HUMTXp9wT9+_&OV{+mV4fGW=*oo+r;!uY0=z+R$twY0{yBgD88a5LxDMTb;tJ^8P8Pf z`fVQ`uI%{Xa6a;gU2|z)=o#i03ePsU`cB(EyQX1U=$X{+Su9C@+7VY3pRv8MG5K_B z(XzmI2iOev>t@Y*&L_jO?0WsWnEa&kf}75k7zopr0P;ZZ?f?J) literal 0 HcmV?d00001 diff --git a/ProjectExcavator/ProjectExcavator/Resources/up.png b/ProjectExcavator/ProjectExcavator/Resources/up.png new file mode 100644 index 0000000000000000000000000000000000000000..aa3da338660803fa9149cdd91fc1e4f5340a16fe GIT binary patch literal 1981 zcmc(g`#%#31IEXexiq^qmWgdB&ArA7En{=bWpXd;P$&~ZG>d2(xt2~uL^kKR)KLjp zbWzfADVHod(ZSqrbIY}Z<9&a6|AY7Qd7kI{{0H9@x|0n=UPT@N06^?)sV8?h^q?|%WPDx3zx3^D7NbvRbotT)&&dyFxPahf@LL!kY7OS$dGCVvy zC@2Vn!IYMkYHMo~i9}6JO(i8I5{Z;7!PWOVTnSmJFlVoZ@c8 z2s`9ldhsVCU+qw~o`$*9?nGhA>BKcNL3t=w38w;XL^jZ0)_$NROFH%u?KX>VHF;PN zFup3H!awT6$^HOmjXDJ;1~v=-J`G)W0?sFgwmCv=4@;|cF3xn&Hs|rzu)WLNXhZeC zJsyZ!GuV4#4%b1ZFclF<6v$ztNef2>dTAG@5b@bX)^|9Hp&^>XXT`qZ3d@LTt;7f* z^CX^s`a@~`7?N{8E5Z;bN_K=2K+i-*tj@Zj(GS#W`3GlKiU<6aA5kx#K&M7=;mC$5 z_7usutSIoy?tTrE>TX-9N60*5VwIrvUR4+EnzA2|E3asQlc~L{{$QU%Y;?Yo8@=Nu z!8Eaaw3i=X$qeR`mFhpq6Kwl4=?>?j&aL0Nc`ve&`%PQf6D<8z-e;2v7M;66 zqwBcR;P1=#wt34*3E)irR&PkF9tNP3!!04;)u!SOM`SG4eJU$!F-lgtH;1M}js1$~ z${DwZ_k&O)_E_?T8OnwYn(x6$j?O*jz5Tlw1PgkAejh}+4C7puiSoHZ&)}}vhQKcB zyyhBS%EDNkiKHVf>UZrIBpGx!Vv|iDM?Pk^WyD4uWnIW?v(o!QVTe>7u?MAxi!k%^ zIeU3n7i!hUH;(*#>T{hvOT!dT8NNi>45CZI#;aE3H7?xjz>6sR1hH&PqbWz8`M5R% zt^!tIUD$fRSEK@?wC^*EyM}nA%DZk>);Q5hF-~CJ?n-zQHqvf|wqenqNCax-ANQI4 zV^iqVHjWhydrneksGgb*0C=Jp+}_SuVxfNF?xLJ^n8Fynm z`&)rymKM>u=LjQRKh}N*KvX37FRjbf^d}d$)yXc9>Vj~ET~ZOacObY6%Z~~!QX4cM z&bgEZFQL#vRQ>E00J5$&v6sLKNEyVHF08dOTL}H53VPLIRLFgX=1<*{Pz7smPNZbn}3I?2j?B{m<1%a)mnMY3^w9Nc|AodB{I^D&h zAlG}v@0X-b2k#*2%U^z=-5R7EsRi!U=6=t7tm(&afmC8gq3#KE^A?IT1rW*QjS%{@ zGuh_EHiO=;H(x*T3NE@KMSduKCBR*i2Z9ILxW7Y3cKX;iXLx^7d(DEeIqVCO`Knxe|jcyYVJS{c(Xa?FIaG{fh9mV06E#1 z0dnqG08-n2e(`-;H#e>pynUBs*&RNn#yt*jlx_$J-i(W1MFx{)W?>-oPPnRNvD4R literal 0 HcmV?d00001 diff --git a/ProjectExcavator/ProjectExcavator/Resources/влево.png b/ProjectExcavator/ProjectExcavator/Resources/влево.png new file mode 100644 index 0000000000000000000000000000000000000000..7869f000038cc4bbb62bc4467fc006255fd71d8c GIT binary patch literal 1094 zcmeAS@N?(olHy`uVBq!ia0vp^4?&oN8Ax*GDtQ2@iU6Mw*Z=?j1DW&Y&HM4=$A=Fe zR8>{Iyu6+~c@h{H_~ONjii!$fU*EH5&mKR1{NclgD^{$ydGlsNLxYx<)|4qzdU|@+ zty{;#!xJ7Jo}Zt;XV0E(+qS)V^TyH9(bUvbLP8=TAt5a-O-xM8$;nAxUcSA(-N3-0 zxVU)c%$Wgulnoddm^(dP978JRyq(+Y_sT(}Ww%HMD=X`gMG8ml@BQap|FCU=L2t{v zXH#zelxsNCa^Ra!dii7*4#gG$Ck*1q&YrZ&{V(oRoX+TT{BizDw1@MO${WTXu3h4I zX&_VaE$lMGORYagqWf&`-qUY>crAK@skuAb;lSIsXknoF*{lJ4;K;8Za9!%b@;eG9ZLTFhaLo@%qMLeFr4?H*%Jyr3p zsKJRT3T5gC5{?6T$7f#d+qhlJd6OkjG_vOg?;;PiJC&=ASX_-B-UG^OOj>9pk*Z>R zeov@mlhVxaWk;A?jkML8fv)U5snC-$Lx@}CIdcDP2YMB@eeg+N@axB0Cq5;$&%bx+{FC7OiK>70 zJOBHCNjsANwGY$1Tjv+8Ni=AB9%K^zBxEzI&#syGmZ?@8OV?VdZm~SEYW3f<;u}tc z?DZ&!I~6kD^TRC1soNiFWdc1a_T^ot){W!u`HPoLH?Da3{&RFpVWi7qk*kFQJN%tP z!w$?{!8_gcMs~6mZ)l0|%&vIRzd_4B#ksoA$n?)~JwH49O?zzZrj7D%w<}2hzBo@3 z$lThoLQAURz0}Pc{XxerMNiSy*t2le?uWhSLfESlyF<1H%iNpL`*+24^M_Ku11l~k zulf)!V}3eSFt6>Am)V0hvvnKg=LsJ*{dRcsz8yM;KHoZVtWM-!LGRyKFln$S(W+hH z;PdH|djD$dQPehB@S#oT<^uZ)j&}3xb&Y~kyMEtWl(X=@q0GU%9D;Z91rN%q3d&?j z9gKCf*t77~f7yd`V+HT*{+9c3$+SZy&u;Sl`pxe@+dM|{Ro~)gz1!!gdDOqV@We~} z`;zt#Z8nOD&LjnglEj7(8A5T-G@y GGywpxSO|px literal 0 HcmV?d00001 diff --git a/ProjectExcavator/ProjectExcavator/Resources/право.png b/ProjectExcavator/ProjectExcavator/Resources/право.png new file mode 100644 index 0000000000000000000000000000000000000000..0c61c755ce21d337cda95c021ece0be7db6a90e1 GIT binary patch literal 1015 zcmVnI5jy}RanW%$-KP0($dn3h>A%@NxfjLOaK4_B}qg=ig6C!taS000000000000000 z00000000000001Z0JUn_Be=I@6xofk2XR+!)2cV8&t(teo~F_Xym6=MmOYTWdF}>6 zdR8ym7@M(giIn5Z?rc!@SngvmaDq$1hHpRh@7&F`%*z#up}WpHW$> zzV_d9uf=cTSJhGDT~hWK|4sGH`7vTvS=U;B&$-d%H}N2l>%PVrlhKt)6#L3r*SM|I zQdbj-?0YV5Z8gofsh@qi6=zh|`0`HqsrtB*?hgybcb-3v?Bcf0#(H44P2p$8Ff6XD z_Ki=124o<+{qqf$K?(PjRV_~2Iz}Z-Nfo!+4U-doRMvUTH8`QjD(mXl)-f`nke;vB z?Sa7wMOJm3;WB$zjZL_JA?sU%6H4W+=83s;==jdzEWpTwp5I$+8phVr^z|FgYv!)_ zP7t3QRT-5~dR82r_8INEBOlk_dHYe zp?c;dxr-(;h+9*$;#G3@yk%BBHQgHh{d(x-9!=CfyqK zBD?I7+{;#`TZgx0&8XEO&s|&bWNTdY%t?GB|B}h68Cg9600000000000000000000 l0000000000008jc`2!)IK>H-U4q^ZR002ovPDHLkV1iyA>?;5O literal 0 HcmV?d00001 -- 2.25.1