From 07acb49eef8e0b66a49f010fa9fabb98453d8d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=B8=D1=8F=20=D0=9A=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Sun, 7 Apr 2024 20:49:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExcavatorDifficult/DirectionType.cs | 23 ++ .../ExcavatorDifficult/DrawingExcavator.cs | 256 ++++++++++++++++++ .../ExcavatorDifficult/DrawingRink.cs | 64 +++++ .../ExcavatorDifficult/EntityExcavator.cs | 68 +++++ .../ExcavatorDifficult.csproj | 19 ++ .../ExcavatorDifficult/Form1.Designer.cs | 39 --- .../ExcavatorDifficult/Form1.cs | 10 - .../FormExcavator.Designer.cs | 142 ++++++++++ .../ExcavatorDifficult/FormExcavator.cs | 87 ++++++ .../{Form1.resx => FormExcavator.resx} | 50 ++-- .../ExcavatorDifficult/NumberOfRink.cs | 22 ++ .../ExcavatorDifficult/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 103 +++++++ .../Properties/Resources.resx | 133 +++++++++ .../ExcavatorDifficult/Resources/Down.bmp | Bin 0 -> 989 bytes .../ExcavatorDifficult/Resources/Left.png | Bin 0 -> 1012 bytes .../ExcavatorDifficult/Resources/Right.bmp | Bin 0 -> 988 bytes .../ExcavatorDifficult/Resources/Up.png | Bin 0 -> 1424 bytes 18 files changed, 943 insertions(+), 75 deletions(-) create mode 100644 ExcavatorDifficult/ExcavatorDifficult/DirectionType.cs create mode 100644 ExcavatorDifficult/ExcavatorDifficult/DrawingExcavator.cs create mode 100644 ExcavatorDifficult/ExcavatorDifficult/DrawingRink.cs create mode 100644 ExcavatorDifficult/ExcavatorDifficult/EntityExcavator.cs delete mode 100644 ExcavatorDifficult/ExcavatorDifficult/Form1.Designer.cs delete mode 100644 ExcavatorDifficult/ExcavatorDifficult/Form1.cs create mode 100644 ExcavatorDifficult/ExcavatorDifficult/FormExcavator.Designer.cs create mode 100644 ExcavatorDifficult/ExcavatorDifficult/FormExcavator.cs rename ExcavatorDifficult/ExcavatorDifficult/{Form1.resx => FormExcavator.resx} (93%) create mode 100644 ExcavatorDifficult/ExcavatorDifficult/NumberOfRink.cs create mode 100644 ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.Designer.cs create mode 100644 ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.resx create mode 100644 ExcavatorDifficult/ExcavatorDifficult/Resources/Down.bmp create mode 100644 ExcavatorDifficult/ExcavatorDifficult/Resources/Left.png create mode 100644 ExcavatorDifficult/ExcavatorDifficult/Resources/Right.bmp create mode 100644 ExcavatorDifficult/ExcavatorDifficult/Resources/Up.png diff --git a/ExcavatorDifficult/ExcavatorDifficult/DirectionType.cs b/ExcavatorDifficult/ExcavatorDifficult/DirectionType.cs new file mode 100644 index 0000000..90ce149 --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/DirectionType.cs @@ -0,0 +1,23 @@ +namespace ExcavatorDifficult; +/// +/// Направление перемещения +/// +public enum DirectionType +{ + /// + /// Вверх + /// + Up=1, + /// + /// Вниз + /// + Down=2, + /// + /// Влево + /// + Left=3, + /// + /// Вправо + /// + Right=4, +} diff --git a/ExcavatorDifficult/ExcavatorDifficult/DrawingExcavator.cs b/ExcavatorDifficult/ExcavatorDifficult/DrawingExcavator.cs new file mode 100644 index 0000000..827197b --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/DrawingExcavator.cs @@ -0,0 +1,256 @@ +namespace ExcavatorDifficult; + +public class DrawingExcavator +{ + /// + /// Класс-сущность + /// + public EntityExcavator? EntityExcavator { get; private set; } + public DrawingRink Rink; + + /// + /// Ширина окна + /// + private int? _pictureWidth; + + /// + /// Высота окна + /// + private int? _pictureHeight; + + /// + /// Левая координата прорисовки экскаватора + /// + private int? _startPosX; + + /// + /// Верхняя кооридната прорисовки экскаватора + /// + private int? _startPosY; + + /// + /// Ширина прорисовки экскаватора + /// + private int _drawningExcavatorWidth; + + /// + /// Высота прорисовки экскаватора + /// + private int _drawningExcavatorHeight; + + + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool support, bool bulldozerDump, int width, int height) + { + + if (weight < _pictureWidth || height < _pictureHeight) + { + return false; + } + + _drawningExcavatorWidth = 174; + + + _drawningExcavatorHeight = 80; + + _pictureWidth = width; + _pictureHeight = height; + EntityExcavator = new EntityExcavator(); + EntityExcavator.Init(speed, weight, bodyColor, additionalColor, bucket, support, bulldozerDump); + Rink = new DrawingRink(); + return true; + + } + + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + + + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (x < 0) + { + x = 0; + } + else if (x > _pictureWidth.Value - _drawningExcavatorWidth) + { + x = (_pictureWidth.Value - _drawningExcavatorWidth); + + } + + if (y < 0) + { + y = 0; + } + else if (y > _pictureHeight.Value - _drawningExcavatorWidth) + { + y = _pictureHeight.Value - _drawningExcavatorHeight; + //return; + } + _startPosX = x; + _startPosY = y; + + } + + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещение выполнено, false - перемещение невозможно + public bool MoveTransport(DirectionType direction) + { + if (EntityExcavator == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return false; + } + + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntityExcavator.Step > 0) + { + _startPosX -= (int)EntityExcavator.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntityExcavator.Step > 0) + { + _startPosY -= (int)EntityExcavator.Step; + } + return true; + // вправо + case DirectionType.Right: + if (_startPosX.Value + _drawningExcavatorWidth + EntityExcavator.Step < _pictureWidth) + { + _startPosX += (int)EntityExcavator.Step; + } + return true; + //вниз + case DirectionType.Down: + if (_startPosY.Value + _drawningExcavatorHeight + EntityExcavator.Step < _pictureHeight) + { + _startPosY += (int)EntityExcavator.Step; + } + return true; + default: + return false; + } + } + + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityExcavator == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black); + Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); + Brush bodybrush = new SolidBrush(EntityExcavator.BodyColor); + + + //границы экскаватора + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 20, 100, 30); + g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value, 10, 20); + g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value, 20, 20); + g.DrawArc(pen, _startPosX.Value, _startPosY.Value + 45, 30, 40, 130, 100); + g.DrawArc(pen, _startPosX.Value + 80, _startPosY.Value + 50, 30, 40, 285, 110); + g.DrawLine(pen, _startPosX.Value + 5, _startPosY.Value + 80, _startPosX.Value + 109, _startPosY.Value + 80); + //g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 53, 25, 25); + //g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 53, 25, 25); + //g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 69, 10, 10); + //g.DrawEllipse(pen, _startPosX.Value + 48, _startPosY.Value + 69, 10, 10); + //g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 69, 10, 10); + //g.DrawEllipse(pen, _startPosX.Value + 40, _startPosY.Value + 53, 7, 7); + //g.DrawEllipse(pen, _startPosX.Value + 60, _startPosY.Value + 53, 7, 7); + + //заливка кабины и основного железа + Brush br = new SolidBrush(Color.Black); + g.FillRectangle(bodybrush, _startPosX.Value, _startPosY.Value + 20, 100, 30); + g.FillRectangle(bodybrush, _startPosX.Value + 30, _startPosY.Value, 10, 20); + g.FillRectangle(bodybrush, _startPosX.Value + 80, _startPosY.Value, 20, 20); + //g.FillEllipse(br, _startPosX.Value + 5, _startPosY.Value + 53, 25, 25); + //g.FillEllipse(br, _startPosX.Value + 80, _startPosY.Value + 53, 25, 25); + //g.FillEllipse(br, _startPosX.Value + 30, _startPosY.Value + 69, 10, 10); + //g.FillEllipse(br, _startPosX.Value + 48, _startPosY.Value + 69, 10, 10); + //g.FillEllipse(br, _startPosX.Value + 65, _startPosY.Value + 69, 10, 10); + //g.FillEllipse(br, _startPosX.Value + 40, _startPosY.Value + 53, 7, 7); + //g.FillEllipse(br, _startPosX.Value + 60, _startPosY.Value + 53, 7, 7); + + Rink.DrawRinks(g, _startPosX.Value + 5, _startPosY.Value + 10); + + //фары + Brush brfara = new SolidBrush(Color.Blue); + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 27, 10, 10); + g.FillRectangle(brfara, _startPosX.Value, _startPosY.Value + 27, 10, 10); + //окно + g.FillRectangle(brfara, _startPosX.Value + 85, _startPosY.Value + 10, 10, 10); + + + if (EntityExcavator.Bucket) + { + Point point1 = new Point(_startPosX.Value + 100, _startPosY.Value); + Point point2 = new Point(_startPosX.Value + 180, _startPosY.Value); + Point point4 = new Point(_startPosX.Value + 180, _startPosY.Value + 40); + Point point5 = new Point(_startPosX.Value + 170, _startPosY.Value + 60); + Point point6 = new Point(_startPosX.Value + 150, _startPosY.Value + 60); + Point point7 = new Point(_startPosX.Value + 140, _startPosY.Value + 40); + Point point8 = new Point(_startPosX.Value + 172, _startPosY.Value + 40); + Point point9 = new Point(_startPosX.Value + 172, _startPosY.Value + 10); + Point point10 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); + + Point[] Bucket = { point1, point2, point4, point5, point6, point7, point8, point9, point10 }; + g.FillPolygon(additionalBrush, Bucket); + } + + if (EntityExcavator.Support) + { + Point point1 = new Point(_startPosX.Value + 2, _startPosY.Value + 50); + Point point2 = new Point(_startPosX.Value + 12, _startPosY.Value + 80); + Point point3 = new Point(_startPosX.Value + 22, _startPosY.Value + 80); + Point point4 = new Point(_startPosX.Value + 12, _startPosY.Value + 50); + Point[] Support = { point1, point2, point3, point4 }; + g.FillPolygon(additionalBrush, Support); + + } + + if (EntityExcavator.BulldozerDump) + { + Point point11 = new Point(_startPosX.Value + 100, _startPosY.Value + 40); + Point point12 = new Point(_startPosX.Value + 160, _startPosY.Value + 80); + Point point13 = new Point(_startPosX.Value + 130, _startPosY.Value + 80); + Point point14 = new Point(_startPosX.Value + 100, _startPosY.Value + 50); + Point[] Dump = { point11, point12, point13, point14 }; + g.FillPolygon(additionalBrush, Dump); + } + + + + + } +} diff --git a/ExcavatorDifficult/ExcavatorDifficult/DrawingRink.cs b/ExcavatorDifficult/ExcavatorDifficult/DrawingRink.cs new file mode 100644 index 0000000..689b4aa --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/DrawingRink.cs @@ -0,0 +1,64 @@ +namespace ExcavatorDifficult; + +public class DrawingRink +{ + public EntityExcavator? EntityExcavator { get; private set; } + + private NumberOfRink numberOfRink; + + public int KatNum + { + set + { + if (value <= 4 || value > 6) + { + numberOfRink = NumberOfRink.FourRink; + } + else if (value == 5) + { + numberOfRink = NumberOfRink.FiveRink; + } + else if (value == 6) + { + numberOfRink = NumberOfRink.SixRink; + } + } + } + + + + + public void DrawRinks(Graphics g, int _startPosX, int _startPosY) + { + + Brush bodybrush = new SolidBrush(Color.Black); + + + switch (numberOfRink) + { + case NumberOfRink.FourRink: + g.FillEllipse(bodybrush, _startPosX, _startPosY + 48, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 25, _startPosY + 48, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 50, _startPosY + 48, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 75, _startPosY + 48, 15, 15); + break; + case NumberOfRink.FiveRink: + g.FillEllipse(bodybrush, _startPosX + 5, _startPosY + 48, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 25, _startPosY + 48, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 45, _startPosY + 48, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 65, _startPosY + 48, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 85, _startPosY + 48, 15, 15); + break; + case NumberOfRink.SixRink: + g.FillEllipse(bodybrush, _startPosX, _startPosY + 52, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 25, _startPosY + 52, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 50, _startPosY + 52, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 75, _startPosY + 52, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 15, _startPosY + 40, 15, 15); + g.FillEllipse(bodybrush, _startPosX + 60, _startPosY + 40, 15, 15); + break; + + } + + } +} diff --git a/ExcavatorDifficult/ExcavatorDifficult/EntityExcavator.cs b/ExcavatorDifficult/ExcavatorDifficult/EntityExcavator.cs new file mode 100644 index 0000000..cd2b6c9 --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/EntityExcavator.cs @@ -0,0 +1,68 @@ +namespace ExcavatorDifficult; + +public 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 Bucket { get; private set; } + + /// + /// Признак (опция) наличие опоры + /// + public bool Support { get; private set; } + + /// + /// Признак (опция) наличие бульдозерного отвала + /// + public bool BulldozerDump { get; private set; } + + /// + /// Шаг перемещения автомобиля + /// + public double Step => Speed * 100 / Weight; + + /// + /// Инициализация полей объекта-класса экскаватора + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия ковша + /// Признак наличия опоры + /// Признак наличия бульдозерного обвеса + + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool support, bool bulldozerDump) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Bucket = bucket; + Support = support; + BulldozerDump = bulldozerDump; + + } +} diff --git a/ExcavatorDifficult/ExcavatorDifficult/ExcavatorDifficult.csproj b/ExcavatorDifficult/ExcavatorDifficult/ExcavatorDifficult.csproj index 663fdb8..f46417f 100644 --- a/ExcavatorDifficult/ExcavatorDifficult/ExcavatorDifficult.csproj +++ b/ExcavatorDifficult/ExcavatorDifficult/ExcavatorDifficult.csproj @@ -8,4 +8,23 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + \ No newline at end of file diff --git a/ExcavatorDifficult/ExcavatorDifficult/Form1.Designer.cs b/ExcavatorDifficult/ExcavatorDifficult/Form1.Designer.cs deleted file mode 100644 index 62d6e38..0000000 --- a/ExcavatorDifficult/ExcavatorDifficult/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ExcavatorDifficult -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/ExcavatorDifficult/ExcavatorDifficult/Form1.cs b/ExcavatorDifficult/ExcavatorDifficult/Form1.cs deleted file mode 100644 index 0f16e60..0000000 --- a/ExcavatorDifficult/ExcavatorDifficult/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ExcavatorDifficult -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.Designer.cs b/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.Designer.cs new file mode 100644 index 0000000..670c9e5 --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.Designer.cs @@ -0,0 +1,142 @@ +namespace ExcavatorDifficult +{ + 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() + { + pictureBoxExcavator = new PictureBox(); + buttonCreate = new Button(); + buttonUp = new Button(); + buttonRight = new Button(); + buttonDown = new Button(); + buttonLeft = new Button(); + numericUpDownrinkExcavator = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownrinkExcavator).BeginInit(); + SuspendLayout(); + // + // pictureBoxExcavator + // + pictureBoxExcavator.Dock = DockStyle.Fill; + pictureBoxExcavator.Location = new Point(0, 0); + pictureBoxExcavator.Name = "pictureBoxExcavator"; + pictureBoxExcavator.Size = new Size(800, 450); + pictureBoxExcavator.TabIndex = 0; + pictureBoxExcavator.TabStop = false; + // + // buttonCreate + // + buttonCreate.Location = new Point(26, 409); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(94, 29); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += ButtonCreat_Click; + // + // buttonUp + // + buttonUp.BackgroundImage = Properties.Resources.Up; + buttonUp.BackgroundImageLayout = ImageLayout.Stretch; + buttonUp.Location = new Point(690, 355); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(41, 36); + buttonUp.TabIndex = 2; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; + // + // buttonRight + // + buttonRight.BackgroundImage = Properties.Resources.Right; + buttonRight.BackgroundImageLayout = ImageLayout.Stretch; + buttonRight.Location = new Point(737, 397); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(41, 36); + buttonRight.TabIndex = 3; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; + // + // buttonDown + // + buttonDown.BackgroundImage = Properties.Resources.Down; + buttonDown.BackgroundImageLayout = ImageLayout.Stretch; + buttonDown.Location = new Point(690, 397); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(41, 36); + buttonDown.TabIndex = 4; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; + // + // buttonLeft + // + buttonLeft.BackgroundImage = Properties.Resources.Left; + buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; + buttonLeft.Location = new Point(643, 397); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(41, 36); + buttonLeft.TabIndex = 5; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; + // + // numericUpDownrinkExcavator + // + numericUpDownrinkExcavator.Location = new Point(126, 411); + numericUpDownrinkExcavator.Margin = new Padding(3, 4, 3, 4); + numericUpDownrinkExcavator.Name = "numericUpDownrinkExcavator"; + numericUpDownrinkExcavator.Size = new Size(150, 27); + numericUpDownrinkExcavator.TabIndex = 6; + // + // FormExcavator + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(numericUpDownrinkExcavator); + Controls.Add(buttonLeft); + Controls.Add(buttonDown); + Controls.Add(buttonRight); + Controls.Add(buttonUp); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxExcavator); + Name = "FormExcavator"; + Text = "FormExcavator"; + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownrinkExcavator).EndInit(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxExcavator; + private Button buttonCreate; + private Button buttonUp; + private Button buttonRight; + private Button buttonDown; + private Button buttonLeft; + private NumericUpDown numericUpDownrinkExcavator; + } +} \ No newline at end of file diff --git a/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.cs b/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.cs new file mode 100644 index 0000000..4fe02db --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.cs @@ -0,0 +1,87 @@ +namespace ExcavatorDifficult +{ + 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 gr = Graphics.FromImage(bmp); + _drawingExcavator.DrawTransport(gr); + pictureBoxExcavator.Image = bmp; + } + + /// + /// обработка кнопки создать + /// + /// + /// + private void ButtonCreat_Click(object sender, EventArgs e) + { + Random random = new(); + _drawingExcavator = new DrawingExcavator(); + _drawingExcavator.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)), Convert.ToBoolean(random.Next(0, 2)), + pictureBoxExcavator.Width, pictureBoxExcavator.Height); + _drawingExcavator.SetPosition(random.Next(10, 100), random.Next(10, 100)); + _drawingExcavator.Rink.KatNum=(int)numericUpDownrinkExcavator.Value; + + 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(); + } + } +} + diff --git a/ExcavatorDifficult/ExcavatorDifficult/Form1.resx b/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.resx similarity index 93% rename from ExcavatorDifficult/ExcavatorDifficult/Form1.resx rename to ExcavatorDifficult/ExcavatorDifficult/FormExcavator.resx index 1af7de1..af32865 100644 --- a/ExcavatorDifficult/ExcavatorDifficult/Form1.resx +++ b/ExcavatorDifficult/ExcavatorDifficult/FormExcavator.resx @@ -1,17 +1,17 @@  - diff --git a/ExcavatorDifficult/ExcavatorDifficult/NumberOfRink.cs b/ExcavatorDifficult/ExcavatorDifficult/NumberOfRink.cs new file mode 100644 index 0000000..2003a3b --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/NumberOfRink.cs @@ -0,0 +1,22 @@ +namespace ExcavatorDifficult; +/// +/// Количество катков +/// +public enum NumberOfRink +{ + /// + /// 4 катка + /// + FourRink, + /// + /// 5 катков + /// + FiveRink, + /// + /// 6 катков + /// + SixRink + +} + + \ No newline at end of file diff --git a/ExcavatorDifficult/ExcavatorDifficult/Program.cs b/ExcavatorDifficult/ExcavatorDifficult/Program.cs index dbca9b6..29ad8ca 100644 --- a/ExcavatorDifficult/ExcavatorDifficult/Program.cs +++ b/ExcavatorDifficult/ExcavatorDifficult/Program.cs @@ -11,7 +11,7 @@ namespace ExcavatorDifficult // 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/ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.Designer.cs b/ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f25c4bb --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ExcavatorDifficult.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("ExcavatorDifficult.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Down { + get { + object obj = ResourceManager.GetObject("Down", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Left { + get { + object obj = ResourceManager.GetObject("Left", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Right { + get { + object obj = ResourceManager.GetObject("Right", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Up { + get { + object obj = ResourceManager.GetObject("Up", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.resx b/ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.resx new file mode 100644 index 0000000..929184e --- /dev/null +++ b/ExcavatorDifficult/ExcavatorDifficult/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\Up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Down.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Right.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ExcavatorDifficult/ExcavatorDifficult/Resources/Down.bmp b/ExcavatorDifficult/ExcavatorDifficult/Resources/Down.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9a978c364226100001bb4f9bc0faffad18150427 GIT binary patch literal 989 zcmeAS@N?(olHy`uVBq!ia0vp^zkql*2OE&|dC~j@NHG=%xjQkeJ16rJ$YDu$^mSxl z*x1kgCy^D%=PdAuEM{O3Dgj}}duj3&3=GUgo-U3d6>)Fxoc6opAm9)<=l}n7rzM_E z0_zjslx=@+DZOWD=ytE18}s6A7^i=G{Y`j>!9wST3yKae1Qbd*1guy%WSLs{7@gV~ zunGVBcqHNWw!8bTrNmr&vWS06)sy;|hvgbV1hnBWZSV;vRM!>$el|7tc3yl>0#EcrSlotMPxbgn^ z*>kETeCnS*bN+4T(bpFI#eC$SX}$?NC=TSGB-Ng|ea88PjMI~1!C!nlrkjO-`5pN; zfBTI73pb~pc&_qARw8l8w*Zivqg(72&UdltQ7N%YRg7)E;BQjxqO_lH;d~#T z9)*&7sf@AR7t{@+LzMQ*fjppYcv`gd?0U}^!h(|Sf>!?{Os=bbIXOpk_KEerFNB3; ztA(w^yn)J0wd^LEgOZ=!#>MN`X5Ul%aA5LLhyH`NU(3!`W>-sc1v832Uj!5)G7F$2+8ukAFTdY=Q$1HIc^xn-GB9|$`njxg HN@xNAym5m- literal 0 HcmV?d00001 diff --git a/ExcavatorDifficult/ExcavatorDifficult/Resources/Left.png b/ExcavatorDifficult/ExcavatorDifficult/Resources/Left.png new file mode 100644 index 0000000000000000000000000000000000000000..f20b33ff1dc8275bb4a5f5d06fea1378b4aeacd8 GIT binary patch literal 1012 zcmeAS@N?(olHy`uVBq!ia0vp^zkql*2OE&|dC~j@NHG=%xjQkeJ16rJ$YDu$^mSxl z*x1kgCy^D%=PdAuEM{O3Dgj}}duj3&3=GVjo-U3d6>)FxM&~Vd5OKYD;q&}rsVNsW zS{-5hyec|f_oUE%u^jo^@& zuqv=AjeDW^<}HstNG}vuDu`44!nDSsnsaX=({l}{{3!=4CtZ+EK5E%~L0YNcoYEJz zh{AJfU!*zbtmgQu#`N6FY5xq-=X_54Cmh(>eL+9r=+4;}{8b8~6u(U7m@|#zZ$j7{ zG0wjZOv^)^>>EUvmpa{dd=O%|r{Avsro#hM)wp+$w^~Jf>0MKiyYji;3u%ryt6KIo zi7vNVXs=jMrT9gjW6nH|zxH8s$z1wlvJ^a>^&Y0W$8DI&V- zfTyV7E>ZQ^>kGMM>`J6}9eC(nzA(D*$GX)QSou!x;<(#&xOl0vxW$@avy#TcRZpF^ zKiUwx5-7J`6R5Afb{2o^gAMUF?H@OM1;*Sg{=3496ZQ*r+a1-bsEA#;{#{c0^(nu5 z^X?|@-c*0AQ}&v+^sghk4qGjCp3f;a@3qpGnKu$6!x#Fmv97ru`@;C(;putK^E+jk zoaRTAUvh1+6Si5o$Z3A(T$70)HJ(X8$+;{aLF~Q4znBkR)?TPDV7*uH7ylY-TftxY zEdKm0`zGC3>GMK5;`^_l^Y;z*6^6g-j;ihI2|l&>qm``AFTSQlTnpcu0Nod*{-wEN z?lfQ+Uz;1o`In_>xv7)=#2cBd7yQ%iW;R~XSE_iY@};|Tt~JMBwrg`&bN+Q}damV^ z-*Cfn_66z0yOxtLNGq3}Q~1IbS>C7irHymmVvfBG8#hnC(7oZ^8^te4Ea$ab;-=iV z>GYyickOO|hG{#vbxO{~CMdRCP;8(%Vq{=gz?z?5&)BW>sq#?uuD!sV%HZkh=d#Wz Gp$Pyt)Dba~4S(3a~i-`+s@Mn#0>x zDDI7U*XWq;_J!SG#c9zQ^DZbh3;?Pu-x>3-=jRTs`%3@I&m1<@RQ@kjT;O@?K)!pv zo`>YOy%#5+4rKeA@#S&W6hnQ<+8tu4N6z_t>OPsP0d$EIcL9FLC_ittoF4=Zr^y-a$ z7uG(l01{s#++JL(`!oMS?yN!}vFqdH3%RF0&b^TP>Z9Wev%dnnSaoM!(9P>?$(!h{ zT+$uKwQ%;{+%hNg-*?Wmd)DPen)&RB7tY$58$%4={$i=X zuA_RL5PJ>1)k?Y}tQOwB^0@gz?yZm0p{@kGx9j5!s2|F7)Jw9>=K%@hYr?y>O04g! zJoxJKjUUO>bFqC*{k-s40T>Qh#?yrJlL^;`CRI#rtIU?o>#<5uePb=PCK)y&?bgCvy)xf3`}% i;l-du276zB6@R&)cbe&BwjN-PWbkzLb6Mw<&;$TaVbG%h literal 0 HcmV?d00001 diff --git a/ExcavatorDifficult/ExcavatorDifficult/Resources/Up.png b/ExcavatorDifficult/ExcavatorDifficult/Resources/Up.png new file mode 100644 index 0000000000000000000000000000000000000000..14c6eab429ac45af9a43b58c67150f3e6ffe8340 GIT binary patch literal 1424 zcmeAS@N?(olHy`uVBq!ia0vp^zkql*2OE&|dC~j@NHG=%xjQkeJ16rJ$YDu$^mSxl z*x1kgCy^D%=PdAuEM{O3Dgj}}duj3&3=FKQo-U3d6>)Db2ji^Z>WXZ29>IzVXQNCA=tLaBgRou#!1&;UPmCAG<+`MZ?0wj98_EGVJrfYmVb(X-{V`J=;V1U*3)R)66Hb{kglrUN>K%_xsfi=DhsV-F{!*p#PR{Iva$Z zcI;Q)jmc^3-p+fK-ng%JUfLKZ`fc&m#!D9K`Km9zaLAky-o7`ZWQNJ9&_wxLGHSd< zsW+O{*gc(NWWOyqsd$OwJ=f>V!VZ%I)`xSXWE6PczcZN4c6#YWThV8i;&z(sSbiwx zmiDw`-%4h979YKILF$lAl=f7%YeLU1MlCd1x6PpY7}wH7(>BX3p=!LVOwTM_Ym^yq zHj&L&)YCbO-#BBHi`2y_7yP|dFEyyO=1FNyXfxI=xg5}FGN*Il^fI|=Y{r%)m(Da_ z3Ru?eH>)y0>J;C?{xG>oY@57aES}1~r0|W{u8b#)nG)7*a<_IwN*!6Zu-zPyJ^JgDD*9gQPm}xiy%@YVHF^Xc~m`r`2_w%h;keJ}dRdMWwz|HHL0zmr}rRBivgiYl(;9q&VByuogY{)JwEk1QTF;?hpMPb+cl4O z<$LjK+w*7dcq4sj@u})W-s!c@RUwu3G3P_;HEdVJh_8FP$bQPa;C0;Bi!RE0^lM&k zf4$>b_a*03y9#)x*92C%MT)O`I7#25U*q-R-!UIqUvj3_R?OGlr(nBq4gdS%qvA{5 zr<6XF(u-8E{c+@iw>9gf47IknTbdKxj19kB@@q7i1qxcOB^P~o_HGGQ=uJy{v2-p| zrirk#{#y}`#WN+UGM76@ogLLWjDl&3$KjbGyD~XQE3EL8V