From 17c57e7c37e9e264ea20abb7528f4a9115449f23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= <Илья@WIN-RANNDDD>
Date: Mon, 25 Sep 2023 16:43:21 +0400
Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=201?=
=?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?=
=?UTF-8?q?=D0=B0=D1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProjectMonorail/DirectionType.cs | 28 +++
.../ProjectMonorail/DrawingMonorail.cs | 236 ++++++++++++++++++
.../ProjectMonorail/EntityMonorail.cs | 60 +++++
.../ProjectMonorail/Form1.Designer.cs | 39 ---
ProjectMonorail/ProjectMonorail/Form1.cs | 10 -
.../ProjectMonorail/FormMonorail.Designer.cs | 138 ++++++++++
.../ProjectMonorail/FormMonorail.cs | 82 ++++++
.../{Form1.resx => FormMonorail.resx} | 50 ++--
ProjectMonorail/ProjectMonorail/Program.cs | 2 +-
.../ProjectMonorail/ProjectMonorail.csproj | 15 ++
.../Properties/Resources.Designer.cs | 103 ++++++++
.../ProjectMonorail/Properties/Resources.resx | 133 ++++++++++
.../ProjectMonorail/Resources/arrowDown.png | Bin 0 -> 415 bytes
.../ProjectMonorail/Resources/arrowLeft.png | Bin 0 -> 411 bytes
.../ProjectMonorail/Resources/arrowRight.png | Bin 0 -> 352 bytes
.../ProjectMonorail/Resources/arrowUp.png | Bin 0 -> 412 bytes
16 files changed, 821 insertions(+), 75 deletions(-)
create mode 100644 ProjectMonorail/ProjectMonorail/DirectionType.cs
create mode 100644 ProjectMonorail/ProjectMonorail/DrawingMonorail.cs
create mode 100644 ProjectMonorail/ProjectMonorail/EntityMonorail.cs
delete mode 100644 ProjectMonorail/ProjectMonorail/Form1.Designer.cs
delete mode 100644 ProjectMonorail/ProjectMonorail/Form1.cs
create mode 100644 ProjectMonorail/ProjectMonorail/FormMonorail.Designer.cs
create mode 100644 ProjectMonorail/ProjectMonorail/FormMonorail.cs
rename ProjectMonorail/ProjectMonorail/{Form1.resx => FormMonorail.resx} (93%)
create mode 100644 ProjectMonorail/ProjectMonorail/Properties/Resources.Designer.cs
create mode 100644 ProjectMonorail/ProjectMonorail/Properties/Resources.resx
create mode 100644 ProjectMonorail/ProjectMonorail/Resources/arrowDown.png
create mode 100644 ProjectMonorail/ProjectMonorail/Resources/arrowLeft.png
create mode 100644 ProjectMonorail/ProjectMonorail/Resources/arrowRight.png
create mode 100644 ProjectMonorail/ProjectMonorail/Resources/arrowUp.png
diff --git a/ProjectMonorail/ProjectMonorail/DirectionType.cs b/ProjectMonorail/ProjectMonorail/DirectionType.cs
new file mode 100644
index 0000000..9973183
--- /dev/null
+++ b/ProjectMonorail/ProjectMonorail/DirectionType.cs
@@ -0,0 +1,28 @@
+namespace ProjectMonorail
+{
+ ///
+ /// Направление перемещения
+ ///
+ public enum DirectionType
+ {
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+
+ ///
+ /// Влево
+ ///
+ Left = 3,
+
+ ///
+ /// Вправо
+ ///
+ Right = 4
+ }
+}
diff --git a/ProjectMonorail/ProjectMonorail/DrawingMonorail.cs b/ProjectMonorail/ProjectMonorail/DrawingMonorail.cs
new file mode 100644
index 0000000..4910ccc
--- /dev/null
+++ b/ProjectMonorail/ProjectMonorail/DrawingMonorail.cs
@@ -0,0 +1,236 @@
+namespace ProjectMonorail
+{
+ ///
+ /// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+ ///
+ public class DrawingMonorail
+ {
+ ///
+ /// Класс-сущность
+ ///
+ public EntityMonorail? EntityMonorail { get; private set; }
+
+ ///
+ /// Ширина окна
+ ///
+ private int _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ private int _pictureHeight;
+
+ ///
+ /// Левая координата прорисовки монорельса
+ ///
+ private int _startPosX;
+
+ ///
+ /// Верхняя координата прорисовки монорельса
+ ///
+ private int _startPosY;
+
+ ///
+ /// Ширина прорисовки монорельса
+ ///
+ private int _monorailWidth = 117;
+
+ ///
+ /// Высота прорисовки монорельса
+ ///
+ private int _monorailHeight = 56;
+
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия магнитной рельсы
+ /// Признак наличия дополнительной кабины
+ /// Ширина картинки
+ /// Высота картинки
+ /// true - объект создан, false - проверка не пройдена,
+ ///нельзя создать объект в этих размерах
+ public bool Init(int speed, double weight, Color mainColor, Color
+ additionalColor, bool magneticRail, bool extraCabin, int width, int height)
+ {
+ if (extraCabin)
+ {
+ _monorailWidth = 183;
+ }
+ if (magneticRail)
+ {
+ _monorailWidth = 186;
+ _monorailHeight = 92;
+ }
+ if (width < _monorailWidth || height < _monorailHeight) { return false; }
+ _pictureWidth = width;
+ _pictureHeight = height;
+ EntityMonorail = new EntityMonorail();
+ EntityMonorail.Init(speed, weight, mainColor, additionalColor,
+ magneticRail, extraCabin);
+ return true;
+ }
+
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ if (x < 0 || x + _monorailWidth > _pictureWidth) { x = 0; }
+ if (y < 0 || y + _monorailHeight > _pictureHeight) { y = 0; }
+
+ _startPosX = x;
+ _startPosY = y;
+ }
+
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ public void MoveTransport(DirectionType direction)
+ {
+ if (EntityMonorail == null)
+ {
+ return;
+ }
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX - EntityMonorail.Step > 0)
+ {
+ _startPosX -= (int)EntityMonorail.Step;
+ }
+ break;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY - EntityMonorail.Step > 0)
+ {
+ _startPosY -= (int)EntityMonorail.Step;
+ }
+ break;
+ //вправо
+ case DirectionType.Right:
+ if (_startPosX + _monorailWidth + EntityMonorail.Step < _pictureWidth)
+ {
+ _startPosX += (int)EntityMonorail.Step;
+ }
+ break;
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY + _monorailHeight + EntityMonorail.Step < _pictureHeight)
+ {
+ _startPosY += (int)EntityMonorail.Step;
+ }
+ break;
+ }
+ }
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public void DrawTransport(Graphics g)
+ {
+ if (EntityMonorail == null)
+ {
+ return;
+ }
+ Pen mainPen = new Pen(Color.Black, 2);
+ Pen additionalPen = new(Color.Blue);
+ Brush mainBrush = new SolidBrush(EntityMonorail.MainColor);
+ Brush additionalBrush = new SolidBrush(EntityMonorail.AdditionalColor);
+ Brush brBlue = new SolidBrush(Color.Blue);
+ Brush brBlack = new SolidBrush(Color.Black);
+ Brush brWhite = new SolidBrush(Color.White);
+ Brush brGray = new SolidBrush(Color.Gray);
+
+ //корпус локомотива
+ Point[] locoPoints = { new Point(_startPosX + 29, _startPosY + 15), new Point(_startPosX + 112, _startPosY + 15),
+ new Point(_startPosX + 112, _startPosY + 46), new Point(_startPosX + 25, _startPosY + 46), new Point(_startPosX + 25, _startPosY + 31) };
+ g.FillPolygon(mainBrush, locoPoints);
+ g.DrawPolygon(mainPen, locoPoints);
+ g.DrawLine(additionalPen, _startPosX + 25, _startPosY + 31, _startPosX + 112, _startPosY + 31);
+
+ //дверь локомотива
+ g.FillRectangle(brGray, _startPosX + 54, _startPosY + 21, 7, 20);
+ g.DrawRectangle(mainPen, _startPosX + 54, _startPosY + 21, 7, 20);
+
+ //окна локомотива
+ g.FillRectangle(brBlue, _startPosX + 32, _startPosY + 18, 6, 9);
+ g.DrawRectangle(mainPen, _startPosX + 32, _startPosY + 18, 6, 9);
+ g.FillRectangle(brBlue, _startPosX + 44, _startPosY + 18, 6, 9);
+ g.DrawRectangle(mainPen, _startPosX + 44, _startPosY + 18, 6, 9);
+ g.FillRectangle(brBlue, _startPosX + 103, _startPosY + 18, 6, 9);
+ g.DrawRectangle(mainPen, _startPosX + 103, _startPosY + 18, 6, 9);
+
+ //колеса и тележка локомотива
+ g.FillRectangle(brBlack, _startPosX + 23, _startPosY + 47, 33, 6);
+ g.DrawRectangle(mainPen, _startPosX + 23, _startPosY + 47, 33, 6);
+ g.FillRectangle(brBlack, _startPosX + 76, _startPosY + 47, 30, 6);
+ g.DrawRectangle(mainPen, _startPosX + 76, _startPosY + 47, 30, 6);
+ g.FillEllipse(brWhite, _startPosX + 25, _startPosY + 47, 10, 9);
+ g.DrawEllipse(mainPen, _startPosX + 25, _startPosY + 47, 10, 9);
+ g.FillEllipse(brWhite, _startPosX + 45, _startPosY + 47, 10, 9);
+ g.DrawEllipse(mainPen, _startPosX + 45, _startPosY + 47, 10, 9);
+ g.FillEllipse(brWhite, _startPosX + 75, _startPosY + 47, 10, 9);
+ g.DrawEllipse(mainPen, _startPosX + 75, _startPosY + 47, 10, 9);
+ g.FillEllipse(brWhite, _startPosX + 95, _startPosY + 47, 10, 9);
+ g.DrawEllipse(mainPen, _startPosX + 95, _startPosY + 47, 10, 9);
+ Point[] bogiePoints = { new Point(_startPosX + 26, _startPosY + 46), new Point(_startPosX + 24, _startPosY + 54),
+ new Point(_startPosX + 12, _startPosY + 54), new Point(_startPosX + 8, _startPosY + 51), new Point(_startPosX + 12, _startPosY + 48),
+ new Point(_startPosX + 18, _startPosY + 46) };
+ g.FillPolygon(brBlack, bogiePoints);
+
+ //соединение между кабинами
+ g.DrawRectangle(mainPen, _startPosX + 112, _startPosY + 18, 5, 28);
+ g.FillRectangle(brBlack, _startPosX + 112, _startPosY + 18, 5, 28);
+
+ //магнитная рельса
+ if (EntityMonorail.MagneticRail)
+ {
+ g.DrawRectangle(mainPen, _startPosX + 2, _startPosY + 58, 184, 18);
+ g.FillRectangle(brGray, _startPosX + 2, _startPosY + 58, 184, 18);
+ for (int i = 0; i < 4; i++)
+ {
+ g.DrawRectangle(mainPen, _startPosX + 35 + 35 * i, _startPosY + 77, 8, 15);
+ g.FillRectangle(brGray, _startPosX + 35 + 35 * i, _startPosY + 77, 8, 15);
+ }
+ }
+
+ //дополнительная кабина
+ if (EntityMonorail.ExtraCabin)
+ {
+ //корпус дополнительной кабины
+ g.FillRectangle(mainBrush, _startPosX + 118, _startPosY + 15, 65, 31);
+ g.DrawRectangle(mainPen, _startPosX + 118, _startPosY + 15, 65, 31);
+ g.DrawLine(additionalPen, _startPosX + 118, _startPosY + 31, _startPosX + 183, _startPosY + 31);
+
+ //дверь дополнительной кабины
+ g.FillRectangle(additionalBrush, _startPosX + 146, _startPosY + 21, 7, 20);
+ g.DrawRectangle(mainPen, _startPosX + 146, _startPosY + 21, 7, 20);
+
+ //окна дополнительной кабины
+ g.FillRectangle(brBlue, _startPosX + 130, _startPosY + 18, 6, 9);
+ g.DrawRectangle(mainPen, _startPosX + 130, _startPosY + 18, 6, 9);
+ g.FillRectangle(brBlue, _startPosX + 169, _startPosY + 18, 6, 9);
+ g.DrawRectangle(mainPen, _startPosX + 169, _startPosY + 18, 6, 9);
+
+ //колеса и тележка дополнительной кабины
+ g.FillRectangle(brBlack, _startPosX + 126, _startPosY + 47, 15, 6);
+ g.DrawRectangle(mainPen, _startPosX + 126, _startPosY + 47, 15, 6);
+ g.FillRectangle(brBlack, _startPosX + 159, _startPosY + 47, 15, 6);
+ g.DrawRectangle(mainPen, _startPosX + 159, _startPosY + 47, 15, 6);
+ g.FillEllipse(brWhite, _startPosX + 128, _startPosY + 47, 10, 9);
+ g.DrawEllipse(mainPen, _startPosX + 128, _startPosY + 47, 10, 9);
+ g.FillEllipse(brWhite, _startPosX + 161, _startPosY + 47, 10, 9);
+ g.DrawEllipse(mainPen, _startPosX + 161, _startPosY + 47, 10, 9);
+ }
+ }
+ }
+}
diff --git a/ProjectMonorail/ProjectMonorail/EntityMonorail.cs b/ProjectMonorail/ProjectMonorail/EntityMonorail.cs
new file mode 100644
index 0000000..4b99444
--- /dev/null
+++ b/ProjectMonorail/ProjectMonorail/EntityMonorail.cs
@@ -0,0 +1,60 @@
+namespace ProjectMonorail
+{
+ public class EntityMonorail
+ {
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+
+ ///
+ /// Основной цвет
+ ///
+ public Color MainColor { get; private set; }
+
+ ///
+ /// Дополнительный цвет (для опциональных элементов)
+ ///
+ public Color AdditionalColor { get; private set; }
+
+ ///
+ /// Признак (опция) наличия магнитной рельсы
+ ///
+ public bool MagneticRail { get; private set; }
+
+ ///
+ /// Признак (опция) наличия дополнительной кабины
+ ///
+ public bool ExtraCabin { get; private set; }
+
+ ///
+ /// Шаг перемещения монорельса
+ ///
+ public double Step => (double)Speed * 100 / Weight;
+
+ ///
+ /// Инициализация полей объекта-класса монорельса
+ ///
+ /// Скорость
+ /// Вес монорельса
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия магнитной рельсы
+ /// Признак наличия дополнительной кабины
+ public void Init(int speed, double weight, Color mainColor, Color
+ additionalColor, bool magneticRail, bool extraCabin)
+ {
+ Speed = speed;
+ Weight = weight;
+ MainColor = mainColor;
+ AdditionalColor = additionalColor;
+ MagneticRail = magneticRail;
+ ExtraCabin = extraCabin;
+ }
+ }
+}
diff --git a/ProjectMonorail/ProjectMonorail/Form1.Designer.cs b/ProjectMonorail/ProjectMonorail/Form1.Designer.cs
deleted file mode 100644
index 3199998..0000000
--- a/ProjectMonorail/ProjectMonorail/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ProjectMonorail
-{
- 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/ProjectMonorail/ProjectMonorail/Form1.cs b/ProjectMonorail/ProjectMonorail/Form1.cs
deleted file mode 100644
index c9435ac..0000000
--- a/ProjectMonorail/ProjectMonorail/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ProjectMonorail
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/ProjectMonorail/ProjectMonorail/FormMonorail.Designer.cs b/ProjectMonorail/ProjectMonorail/FormMonorail.Designer.cs
new file mode 100644
index 0000000..382f7fa
--- /dev/null
+++ b/ProjectMonorail/ProjectMonorail/FormMonorail.Designer.cs
@@ -0,0 +1,138 @@
+namespace ProjectMonorail
+{
+ partial class FormMonorail
+ {
+ ///
+ /// 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.pictureBoxMonorail = new System.Windows.Forms.PictureBox();
+ this.buttonCreateMonorail = 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();
+ this.buttonUp = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxMonorail)).BeginInit();
+ this.SuspendLayout();
+ //
+ // pictureBoxMonorail
+ //
+ this.pictureBoxMonorail.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxMonorail.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxMonorail.Name = "pictureBoxMonorail";
+ this.pictureBoxMonorail.Size = new System.Drawing.Size(884, 461);
+ this.pictureBoxMonorail.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBoxMonorail.TabIndex = 0;
+ this.pictureBoxMonorail.TabStop = false;
+ //
+ // buttonCreateMonorail
+ //
+ this.buttonCreateMonorail.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreateMonorail.Location = new System.Drawing.Point(12, 419);
+ this.buttonCreateMonorail.Name = "buttonCreateMonorail";
+ this.buttonCreateMonorail.Size = new System.Drawing.Size(75, 23);
+ this.buttonCreateMonorail.TabIndex = 1;
+ this.buttonCreateMonorail.Text = "Create";
+ this.buttonCreateMonorail.UseVisualStyleBackColor = true;
+ this.buttonCreateMonorail.Click += new System.EventHandler(this.buttonCreateMonorail_Click);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonLeft.BackgroundImage = global::ProjectMonorail.Properties.Resources.arrowLeft;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonLeft.Location = new System.Drawing.Point(770, 419);
+ 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);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::ProjectMonorail.Properties.Resources.arrowDown;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonDown.Location = new System.Drawing.Point(806, 419);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 3;
+ 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::ProjectMonorail.Properties.Resources.arrowRight;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonRight.Location = new System.Drawing.Point(842, 419);
+ 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);
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::ProjectMonorail.Properties.Resources.arrowUp;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonUp.Location = new System.Drawing.Point(806, 383);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 5;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
+ //
+ // FormMonorail
+ //
+ 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.buttonUp);
+ this.Controls.Add(this.buttonRight);
+ this.Controls.Add(this.buttonDown);
+ this.Controls.Add(this.buttonLeft);
+ this.Controls.Add(this.buttonCreateMonorail);
+ this.Controls.Add(this.pictureBoxMonorail);
+ this.Name = "FormMonorail";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Monorail";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxMonorail)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxMonorail;
+ private Button buttonCreateMonorail;
+ private Button buttonLeft;
+ private Button buttonDown;
+ private Button buttonRight;
+ private Button buttonUp;
+ }
+}
\ No newline at end of file
diff --git a/ProjectMonorail/ProjectMonorail/FormMonorail.cs b/ProjectMonorail/ProjectMonorail/FormMonorail.cs
new file mode 100644
index 0000000..a723ad3
--- /dev/null
+++ b/ProjectMonorail/ProjectMonorail/FormMonorail.cs
@@ -0,0 +1,82 @@
+namespace ProjectMonorail
+{
+ ///
+ /// Форма работы с объектом "Монорельс"
+ ///
+ public partial class FormMonorail : Form
+ {
+ ///
+ /// Поле-объект для прорисовки объекта
+ ///
+ private DrawingMonorail? _drawingMonorail;
+
+ ///
+ /// Инициализация формы
+ ///
+ public FormMonorail()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Метод прорисовки транспорта
+ ///
+ private void Draw()
+ {
+ if (_drawingMonorail == null)
+ {
+ return;
+ }
+ Bitmap bmp = new(pictureBoxMonorail.Width, pictureBoxMonorail.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _drawingMonorail.DrawTransport(gr);
+ pictureBoxMonorail.Image = bmp;
+ }
+
+ ///
+ /// Обработка нажатия кнопки "Создать"
+ ///
+ ///
+ ///
+ private void buttonCreateMonorail_Click(object sender, EventArgs e)
+ {
+ Random random = new();
+ _drawingMonorail = new DrawingMonorail();
+ _drawingMonorail.Init(random.Next(300, 500), 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)),
+ pictureBoxMonorail.Width, pictureBoxMonorail.Height);
+ _drawingMonorail.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ Draw();
+ }
+
+ ///
+ /// Обработка нажатия кнопок управления движением
+ ///
+ ///
+ ///
+ private void buttonMove_Click(object sender, EventArgs e)
+ {
+ if (_drawingMonorail == null)
+ {
+ return;
+ }
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ switch (name)
+ {
+ case "buttonUp":
+ _drawingMonorail.MoveTransport(DirectionType.Up);
+ break;
+ case "buttonDown":
+ _drawingMonorail.MoveTransport(DirectionType.Down);
+ break;
+ case "buttonLeft":
+ _drawingMonorail.MoveTransport(DirectionType.Left);
+ break;
+ case "buttonRight":
+ _drawingMonorail.MoveTransport(DirectionType.Right);
+ break;
+ }
+ Draw();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectMonorail/ProjectMonorail/Form1.resx b/ProjectMonorail/ProjectMonorail/FormMonorail.resx
similarity index 93%
rename from ProjectMonorail/ProjectMonorail/Form1.resx
rename to ProjectMonorail/ProjectMonorail/FormMonorail.resx
index 1af7de1..af32865 100644
--- a/ProjectMonorail/ProjectMonorail/Form1.resx
+++ b/ProjectMonorail/ProjectMonorail/FormMonorail.resx
@@ -1,17 +1,17 @@
-
diff --git a/ProjectMonorail/ProjectMonorail/Program.cs b/ProjectMonorail/ProjectMonorail/Program.cs
index 05e6dd5..3f68a06 100644
--- a/ProjectMonorail/ProjectMonorail/Program.cs
+++ b/ProjectMonorail/ProjectMonorail/Program.cs
@@ -11,7 +11,7 @@ namespace ProjectMonorail
// 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 FormMonorail());
}
}
}
\ No newline at end of file
diff --git a/ProjectMonorail/ProjectMonorail/ProjectMonorail.csproj b/ProjectMonorail/ProjectMonorail/ProjectMonorail.csproj
index b57c89e..13ee123 100644
--- a/ProjectMonorail/ProjectMonorail/ProjectMonorail.csproj
+++ b/ProjectMonorail/ProjectMonorail/ProjectMonorail.csproj
@@ -8,4 +8,19 @@
enable
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/ProjectMonorail/ProjectMonorail/Properties/Resources.Designer.cs b/ProjectMonorail/ProjectMonorail/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..bfdab06
--- /dev/null
+++ b/ProjectMonorail/ProjectMonorail/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectMonorail.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("ProjectMonorail.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 arrowDown {
+ get {
+ object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowLeft {
+ get {
+ object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowRight {
+ get {
+ object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowUp {
+ get {
+ object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/ProjectMonorail/ProjectMonorail/Properties/Resources.resx b/ProjectMonorail/ProjectMonorail/Properties/Resources.resx
new file mode 100644
index 0000000..d08f0f7
--- /dev/null
+++ b/ProjectMonorail/ProjectMonorail/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\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/ProjectMonorail/ProjectMonorail/Resources/arrowDown.png b/ProjectMonorail/ProjectMonorail/Resources/arrowDown.png
new file mode 100644
index 0000000000000000000000000000000000000000..16b4f593bd26b5eb84407bebcbe55c1aaeec95a0
GIT binary patch
literal 415
zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf&U>cv7h@-A}f&3S>O>_%)r334ulzV-xx^&1tm*dBT9nv(@M${i&7cN
z%ggmL^RkPR6AM!H@{7`Ezq0`;`tRxD7~P?^!8c@i=zDlvj@=Qp#I-
zKKktQyqXyApweg@bKqasE;$9;OS3OTZjo@+ywU8mBTf|o5ezd4OFR`tb;8emW`c)I$ztaD0e0szRs
Bqig^G
literal 0
HcmV?d00001
diff --git a/ProjectMonorail/ProjectMonorail/Resources/arrowLeft.png b/ProjectMonorail/ProjectMonorail/Resources/arrowLeft.png
new file mode 100644
index 0000000000000000000000000000000000000000..8fb9ab154ebc71fdb6fe5827fe9cd93fd6f3b455
GIT binary patch
literal 411
zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf&U>cv7h@-A}f&3S>O>_%)r334ulzV-xx^&1tm*dBT9nv(@M${i&7cN
z%ggmL^RkPR6AM!H@{7`Ezq0`;`t9lB7~&rg;N)66!cl!Tf@yl$FB%hT?Z!{*#0@&7EQ3WTV}3dQloNRV0V+f?H~Kd
zhiOc~9#ucjZTLRR?IGv1M&;HojoW?JHQ6py{5`8ntix&pv*p3_`cWy?0Z-PxICw|5
xqVje2x0duN69jK09JMtMtThS_{>Is1x2xg6`(~pwj>V
literal 0
HcmV?d00001
diff --git a/ProjectMonorail/ProjectMonorail/Resources/arrowRight.png b/ProjectMonorail/ProjectMonorail/Resources/arrowRight.png
new file mode 100644
index 0000000000000000000000000000000000000000..95eccc3243ce2d86be760d409611518b9274f59b
GIT binary patch
literal 352
zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ
zFs%b@shXQb0k;64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhK#J~qx;Tb-
zbiTc6=;iDv!1f^jlBNgOLAB6ZCS`Go?g4AwDz}u#9k{1`gLB)x1Gl^sTPql?Otk@VR9OF8{Ihr5e;7XtEq}WvK2HzmQ3g*}KbLh*2~7YbW`~Oa
literal 0
HcmV?d00001
diff --git a/ProjectMonorail/ProjectMonorail/Resources/arrowUp.png b/ProjectMonorail/ProjectMonorail/Resources/arrowUp.png
new file mode 100644
index 0000000000000000000000000000000000000000..8771ae3cef6a025275442a791b4151a061771e42
GIT binary patch
literal 412
zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf&U>cv7h@-A}f&3S>O>_%)r334ulzV-xx^&1tm*dBT9nv(@M${i&7cN
z%ggmL^RkPR6AM!H@{7`Ezq0`;`s3;17~4Qjyq1^c($R1?R8?t
z#nveaY@d|G0uuM?MU^PlT1QB4h!fY%@{pcawqo_+a~WG^IL#{9c6f&NmK!%kbh(yr
zX