diff --git a/Locomotive/Locomotive/FormLocomotive.cs b/Locomotive/Locomotive/FormLocomotive.cs
index 567dcdb..7d782f5 100644
--- a/Locomotive/Locomotive/FormLocomotive.cs
+++ b/Locomotive/Locomotive/FormLocomotive.cs
@@ -30,7 +30,13 @@ namespace Locomotive
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
- _locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ _locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
SetData();
Draw();
@@ -67,9 +73,23 @@ namespace Locomotive
private void buttonCreateModified_Click(object sender, EventArgs e)
{
Random rnd = new();
+
+ Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialogDop = new();
+ if (dialogDop.ShowDialog() == DialogResult.OK)
+ {
+ dopColor = dialogDop.Color;
+ }
+
_locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
+ color,
+ dopColor,
Convert.ToBoolean(rnd.Next(0, 2)),
Convert.ToBoolean(rnd.Next(0, 2)));
diff --git a/Locomotive/Locomotive/FormMap.Designer.cs b/Locomotive/Locomotive/FormMap.Designer.cs
deleted file mode 100644
index e885489..0000000
--- a/Locomotive/Locomotive/FormMap.Designer.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-namespace Locomotive
-{
- partial class FormMap
- {
- ///
- /// 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.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
- this.statusStrip1 = new System.Windows.Forms.StatusStrip();
- this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
- 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.buttonCreateModified = new System.Windows.Forms.Button();
- this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
- this.statusStrip1.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(778, 416);
- this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxLocomotive.TabIndex = 0;
- this.pictureBoxLocomotive.TabStop = false;
- //
- // statusStrip1
- //
- this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripStatusLabelSpeed,
- this.toolStripStatusLabelWeight,
- this.toolStripStatusLabelColor});
- this.statusStrip1.Location = new System.Drawing.Point(0, 416);
- this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(778, 26);
- this.statusStrip1.TabIndex = 1;
- this.statusStrip1.Text = "statusStrip1";
- //
- // toolStripStatusLabelSpeed
- //
- this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(51, 20);
- this.toolStripStatusLabelSpeed.Text = "Speed";
- //
- // toolStripStatusLabelWeight
- //
- this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(56, 20);
- this.toolStripStatusLabelWeight.Text = "Weight";
- //
- // toolStripStatusLabelColor
- //
- this.toolStripStatusLabelColor.Name = "toolStripStatusLabelColor";
- this.toolStripStatusLabelColor.Size = new System.Drawing.Size(45, 20);
- this.toolStripStatusLabelColor.Text = "Color";
- //
- // 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(12, 377);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(94, 29);
- this.buttonCreate.TabIndex = 2;
- this.buttonCreate.Text = "Create ";
- 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::Locomotive.Properties.Resources.up_arrow;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(680, 320);
- this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(40, 40);
- this.buttonUp.TabIndex = 3;
- this.buttonUp.UseVisualStyleBackColor = true;
- this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonLeft
- //
- this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonLeft.BackgroundImage = global::Locomotive.Properties.Resources.left_arrow;
- this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(634, 366);
- this.buttonLeft.Name = "buttonLeft";
- this.buttonLeft.Size = new System.Drawing.Size(40, 40);
- this.buttonLeft.TabIndex = 4;
- 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::Locomotive.Properties.Resources.down_arrow;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(680, 366);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(40, 40);
- this.buttonDown.TabIndex = 5;
- 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::Locomotive.Properties.Resources.right_arrow;
- this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(726, 366);
- this.buttonRight.Name = "buttonRight";
- this.buttonRight.Size = new System.Drawing.Size(40, 40);
- this.buttonRight.TabIndex = 6;
- this.buttonRight.UseVisualStyleBackColor = true;
- this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonCreateModified
- //
- this.buttonCreateModified.Location = new System.Drawing.Point(112, 377);
- this.buttonCreateModified.Name = "buttonCreateModified";
- this.buttonCreateModified.Size = new System.Drawing.Size(94, 29);
- this.buttonCreateModified.TabIndex = 7;
- this.buttonCreateModified.Text = "Modified";
- this.buttonCreateModified.UseVisualStyleBackColor = true;
- this.buttonCreateModified.Click += new System.EventHandler(this.buttonCreateModified_Click);
- //
- // comboBoxSelectorMap
- //
- this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBoxSelectorMap.FormattingEnabled = true;
- this.comboBoxSelectorMap.Items.AddRange(new object[] {
- "Простая карта",
- "Карта с шипами",
- "Карта с рельсами"});
- this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
- this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
- this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
- this.comboBoxSelectorMap.TabIndex = 8;
- this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelectorMap_SelectedIndexChanged);
- //
- // FormMap
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(778, 442);
- this.Controls.Add(this.comboBoxSelectorMap);
- this.Controls.Add(this.buttonCreateModified);
- 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.statusStrip1);
- this.Name = "FormMap";
- this.Text = "Map";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
- this.statusStrip1.ResumeLayout(false);
- this.statusStrip1.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private PictureBox pictureBoxLocomotive;
- private StatusStrip statusStrip1;
- private ToolStripStatusLabel toolStripStatusLabelSpeed;
- private ToolStripStatusLabel toolStripStatusLabelWeight;
- private ToolStripStatusLabel toolStripStatusLabelColor;
- private Button buttonCreate;
- private Button buttonUp;
- private Button buttonLeft;
- private Button buttonDown;
- private Button buttonRight;
- private Button buttonCreateModified;
- private ComboBox comboBoxSelectorMap;
- }
-}
\ No newline at end of file
diff --git a/Locomotive/Locomotive/FormMap.cs b/Locomotive/Locomotive/FormMap.cs
deleted file mode 100644
index 4333523..0000000
--- a/Locomotive/Locomotive/FormMap.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Locomotive
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- }
-
- /// Заполнение информации по объекту
- private void SetData(DrawningLocomotive locomotive)
- {
- toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
- toolStripStatusLabelColor.Text = $"Цвет: { locomotive.Locomotive.BodyColor.Name}";
- pictureBoxLocomotive.Image = _abstractMap.CreateMap(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height,
- new DrawningObjectLocomotive(locomotive));
- }
-
- /// Обработка нажатия кнопки "Создать"
- private void buttonCreate_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var car = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(car);
- }
-
- /// Изменение размеров формы
- private void ButtonMove_Click(object sender, EventArgs e)
- {
- //получаем имя кнопки
- string name = ((Button)sender)?.Name ?? string.Empty;
- Direction dir = Direction.None;
- switch (name)
- {
- case "buttonUp":
- dir = Direction.Up;
- break;
- case "buttonDown":
- dir = Direction.Down;
- break;
- case "buttonLeft":
- dir = Direction.Left;
- break;
- case "buttonRight":
- dir = Direction.Right;
- break;
- }
- pictureBoxLocomotive.Image = _abstractMap?.MoveObject(dir);
- }
-
- /// Обработка нажатия кнопки "Модификация"
- private void buttonCreateModified_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var car = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000,
- 2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0,
- 256)),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0,
- 256)),
- Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,
- 2)));
- SetData(car);
- }
-
- /// Смена карты
- private void comboBoxSelectorMap_SelectedIndexChanged(object sender,
- EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Карта с шипами":
- _abstractMap = new SpikeMap();
- break;
- case "Карта с рельсами":
- _abstractMap = new RailroadMap();
- break;
-
- }
- }
- }
-}
diff --git a/Locomotive/Locomotive/FormMap.resx b/Locomotive/Locomotive/FormMap.resx
deleted file mode 100644
index 5cb320f..0000000
--- a/Locomotive/Locomotive/FormMap.resx
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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
-
-
- 17, 17
-
-
\ No newline at end of file