diff --git a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs
index 124dc6c..30a2ee7 100644
--- a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs
+++ b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.Designer.cs
@@ -28,19 +28,155 @@
///
private void InitializeComponent()
{
+ this.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.statusStrip = new System.Windows.Forms.StatusStrip();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
+ this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
+ // pictureBoxLocomotive
+ //
+ this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
+ this.pictureBoxLocomotive.Size = new System.Drawing.Size(800, 418);
+ this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBoxLocomotive.TabIndex = 0;
+ this.pictureBoxLocomotive.TabStop = false;
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Location = new System.Drawing.Point(12, 375);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(93, 30);
+ this.buttonCreate.TabIndex = 2;
+ this.buttonCreate.Text = "Создать";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::ProjectLocomotive.Properties.Resources.up;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(675, 339);
+ 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);
+ this.buttonUp.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonLeft.BackgroundImage = global::ProjectLocomotive.Properties.Resources.left;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(639, 374);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+ this.buttonLeft.TabIndex = 4;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
+ this.buttonLeft.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
+ //
+ // buttonRight
+ //
+ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRight.BackgroundImage = global::ProjectLocomotive.Properties.Resources.right;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(711, 375);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 5;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+ this.buttonRight.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::ProjectLocomotive.Properties.Resources.down;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(675, 373);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 6;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ this.buttonDown.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
+ //
+ // toolStripStatusLabelSpeed
+ //
+ this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
+ this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(93, 25);
+ this.toolStripStatusLabelSpeed.Text = "Скорость:";
+ //
+ // toolStripStatusLabelWeight
+ //
+ this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
+ this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(43, 25);
+ this.toolStripStatusLabelWeight.Text = "Вес:";
+ //
+ // toolStripStatusLabelBodyColor
+ //
+ this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
+ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(55, 25);
+ this.toolStripStatusLabelBodyColor.Text = "Цвет:";
+ //
+ // statusStrip
+ //
+ this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
+ this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusLabelSpeed,
+ this.toolStripStatusLabelWeight,
+ this.toolStripStatusLabelBodyColor});
+ this.statusStrip.Location = new System.Drawing.Point(0, 418);
+ this.statusStrip.Name = "statusStrip";
+ this.statusStrip.Size = new System.Drawing.Size(800, 32);
+ this.statusStrip.TabIndex = 1;
+ //
// FormLocomotive
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonRight);
+ this.Controls.Add(this.buttonDown);
+ this.Controls.Add(this.buttonLeft);
+ this.Controls.Add(this.buttonUp);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.pictureBoxLocomotive);
+ this.Controls.Add(this.statusStrip);
this.Name = "FormLocomotive";
this.Text = "Локомотив";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
+ this.statusStrip.ResumeLayout(false);
+ this.statusStrip.PerformLayout();
this.ResumeLayout(false);
+ this.PerformLayout();
}
#endregion
+
+ private PictureBox pictureBoxLocomotive;
+ private Button buttonCreate;
+ private Button buttonUp;
+ private Button buttonLeft;
+ private Button buttonDown;
+ private Button buttonRight;
+ private ToolStripStatusLabel toolStripStatusLabelSpeed;
+ private ToolStripStatusLabel toolStripStatusLabelWeight;
+ private ToolStripStatusLabel toolStripStatusLabelBodyColor;
+ private StatusStrip statusStrip;
}
}
\ No newline at end of file
diff --git a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs
index e76f9ea..5827c25 100644
--- a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs
+++ b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs
@@ -2,9 +2,75 @@ namespace ProjectLocomotive
{
public partial class FormLocomotive : Form
{
+ private DrawningLocomotive _elloc;
+
public FormLocomotive()
{
InitializeComponent();
}
+
+ ///
+ ///
+ ///
+ private void Draw()
+ {
+ Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _elloc?.DrawTransport(gr);
+ pictureBoxLocomotive.Image = bmp;
+ }
+ ///
+ /// ""
+ ///
+ ///
+ ///
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ _elloc = new DrawningLocomotive();
+ _elloc.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ _elloc.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
+ toolStripStatusLabelSpeed.Text = $": {_elloc.Locomotiv.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_elloc.Locomotiv.Weight}";
+ toolStripStatusLabelBodyColor.Text = $": {_elloc.Locomotiv.BodyColor.Name}";
+ Draw();
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ //
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ switch (name)
+ {
+ case "buttonUp":
+ _elloc?.MoveTransport(Direction.Up);
+ break;
+ case "buttonDown":
+ _elloc?.MoveTransport(Direction.Down);
+ break;
+ case "buttonLeft":
+ _elloc?.MoveTransport(Direction.Left);
+ break;
+ case "buttonRight":
+ _elloc?.MoveTransport(Direction.Right);
+ break;
+ }
+ Draw();
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PictureBoxLocomotive_Resize(object sender, EventArgs e)
+ {
+ _elloc?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
+ Draw();
+ }
}
}
\ No newline at end of file
diff --git a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.resx b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.resx
index f298a7b..2c0949d 100644
--- a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.resx
+++ b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.resx
@@ -57,4 +57,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
\ No newline at end of file
diff --git a/ProjectLocomotive/ProjectLocomotive/ProjectLocomotive.csproj b/ProjectLocomotive/ProjectLocomotive/ProjectLocomotive.csproj
index b57c89e..13ee123 100644
--- a/ProjectLocomotive/ProjectLocomotive/ProjectLocomotive.csproj
+++ b/ProjectLocomotive/ProjectLocomotive/ProjectLocomotive.csproj
@@ -8,4 +8,19 @@
enable
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/ProjectLocomotive/ProjectLocomotive/Properties/Resources.Designer.cs b/ProjectLocomotive/ProjectLocomotive/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..d150b92
--- /dev/null
+++ b/ProjectLocomotive/ProjectLocomotive/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectLocomotive.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("ProjectLocomotive.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/ProjectLocomotive/ProjectLocomotive/Properties/Resources.resx b/ProjectLocomotive/ProjectLocomotive/Properties/Resources.resx
new file mode 100644
index 0000000..53ec0b4
--- /dev/null
+++ b/ProjectLocomotive/ProjectLocomotive/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\down.png;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.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
+
+
\ No newline at end of file
diff --git a/ProjectLocomotive/ProjectLocomotive/Resources/down.png b/ProjectLocomotive/ProjectLocomotive/Resources/down.png
new file mode 100644
index 0000000..2f2fc13
Binary files /dev/null and b/ProjectLocomotive/ProjectLocomotive/Resources/down.png differ
diff --git a/ProjectLocomotive/ProjectLocomotive/Resources/left.png b/ProjectLocomotive/ProjectLocomotive/Resources/left.png
new file mode 100644
index 0000000..2b22b23
Binary files /dev/null and b/ProjectLocomotive/ProjectLocomotive/Resources/left.png differ
diff --git a/ProjectLocomotive/ProjectLocomotive/Resources/right.png b/ProjectLocomotive/ProjectLocomotive/Resources/right.png
new file mode 100644
index 0000000..eb37115
Binary files /dev/null and b/ProjectLocomotive/ProjectLocomotive/Resources/right.png differ
diff --git a/ProjectLocomotive/ProjectLocomotive/Resources/up.png b/ProjectLocomotive/ProjectLocomotive/Resources/up.png
new file mode 100644
index 0000000..7019eb5
Binary files /dev/null and b/ProjectLocomotive/ProjectLocomotive/Resources/up.png differ