From 40fb3d4a260ddd54342221dfe16b9572c84de626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Wed, 12 Oct 2022 11:42:18 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locomotives/Locomotives/CrossMap.cs | 4 ++-- Locomotives/Locomotives/RoadsMap.cs | 4 ++-- Locomotives/Locomotives/SimpleMap.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Locomotives/Locomotives/CrossMap.cs b/Locomotives/Locomotives/CrossMap.cs index fc41c06..ffb23b0 100644 --- a/Locomotives/Locomotives/CrossMap.cs +++ b/Locomotives/Locomotives/CrossMap.cs @@ -26,9 +26,9 @@ _map = new int[100, 100]; _size_x = (float)_width / _map.GetLength(0); _size_y = (float)_height / _map.GetLength(1); - for (int i = 0; i < _map.GetLength(0); ++i) + for (int i = 0; i < _map.GetLength(0); i++) { - for (int j = 0; j < _map.GetLength(1); ++j) + for (int j = 0; j < _map.GetLength(1); j++) { _map[i, j] = _freeRoad; } diff --git a/Locomotives/Locomotives/RoadsMap.cs b/Locomotives/Locomotives/RoadsMap.cs index 84aeb69..28d1973 100644 --- a/Locomotives/Locomotives/RoadsMap.cs +++ b/Locomotives/Locomotives/RoadsMap.cs @@ -26,9 +26,9 @@ _map = new int[100, 100]; _size_x = (float)_width / _map.GetLength(0); _size_y = (float)_height / _map.GetLength(1); - for (int i = 0; i < _map.GetLength(0); ++i) + for (int i = 0; i < _map.GetLength(0); i++) { - for (int j = 0; j < _map.GetLength(1); ++j) + for (int j = 0; j < _map.GetLength(1); j++) { _map[i, j] = _freeRoad; } diff --git a/Locomotives/Locomotives/SimpleMap.cs b/Locomotives/Locomotives/SimpleMap.cs index 0a3969b..9c3f5b6 100644 --- a/Locomotives/Locomotives/SimpleMap.cs +++ b/Locomotives/Locomotives/SimpleMap.cs @@ -27,9 +27,9 @@ _size_x = (float)_width / _map.GetLength(0); _size_y = (float)_height / _map.GetLength(1); int counter = 0; - for (int i = 0; i < _map.GetLength(0); ++i) + for (int i = 0; i < _map.GetLength(0); i++) { - for (int j = 0; j < _map.GetLength(1); ++j) + for (int j = 0; j < _map.GetLength(1); j++) { _map[i, j] = _freeRoad; } From bf7cd8a3a101319a9a372d4584d1c1f1c022b604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Wed, 12 Oct 2022 14:08:22 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20FormLocomotive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Locomotives/FormLocomotive.Designer.cs | 43 +++++++++++++++- Locomotives/Locomotives/FormLocomotive.cs | 51 +++++++++++++++++-- 2 files changed, 89 insertions(+), 5 deletions(-) diff --git a/Locomotives/Locomotives/FormLocomotive.Designer.cs b/Locomotives/Locomotives/FormLocomotive.Designer.cs index 0f12d4e..cce3c09 100644 --- a/Locomotives/Locomotives/FormLocomotive.Designer.cs +++ b/Locomotives/Locomotives/FormLocomotive.Designer.cs @@ -33,11 +33,15 @@ this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelAdditionalColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelHasPipe = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelHasFuelTank = new System.Windows.Forms.ToolStripStatusLabel(); this.buttonCreate = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonUp = new System.Windows.Forms.Button(); + this.buttonCreateModif = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); @@ -59,7 +63,10 @@ this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabelSpeed, this.toolStripStatusLabelWeight, - this.toolStripStatusLabelBodyColor}); + this.toolStripStatusLabelBodyColor, + this.toolStripStatusLabelAdditionalColor, + this.toolStripStatusLabelHasPipe, + this.toolStripStatusLabelHasFuelTank}); this.statusStrip.Location = new System.Drawing.Point(0, 428); this.statusStrip.Name = "statusStrip"; this.statusStrip.Size = new System.Drawing.Size(800, 22); @@ -84,6 +91,24 @@ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(39, 17); this.toolStripStatusLabelBodyColor.Text = "Цвет: "; // + // toolStripStatusLabelAdditionalColor + // + this.toolStripStatusLabelAdditionalColor.Name = "toolStripStatusLabelAdditionalColor"; + this.toolStripStatusLabelAdditionalColor.Size = new System.Drawing.Size(137, 17); + this.toolStripStatusLabelAdditionalColor.Text = "Дополнительный цвет: "; + // + // toolStripStatusLabelHasPipe + // + this.toolStripStatusLabelHasPipe.Name = "toolStripStatusLabelHasPipe"; + this.toolStripStatusLabelHasPipe.Size = new System.Drawing.Size(99, 17); + this.toolStripStatusLabelHasPipe.Text = "Наличие трубы: "; + // + // toolStripStatusLabelHasFuelTank + // + this.toolStripStatusLabelHasFuelTank.Name = "toolStripStatusLabelHasFuelTank"; + this.toolStripStatusLabelHasFuelTank.Size = new System.Drawing.Size(158, 17); + this.toolStripStatusLabelHasFuelTank.Text = "Наличие топливного бака: "; + // // buttonCreate // this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -143,11 +168,23 @@ this.buttonUp.UseVisualStyleBackColor = true; this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); // + // buttonCreateModif + // + this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreateModif.Location = new System.Drawing.Point(108, 395); + this.buttonCreateModif.Name = "buttonCreateModif"; + this.buttonCreateModif.Size = new System.Drawing.Size(109, 30); + this.buttonCreateModif.TabIndex = 8; + this.buttonCreateModif.Text = "Модификация"; + this.buttonCreateModif.UseVisualStyleBackColor = true; + this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // // FormLocomotive // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonCreateModif); this.Controls.Add(this.buttonUp); this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonLeft); @@ -177,5 +214,9 @@ private Button buttonLeft; private Button buttonDown; private Button buttonUp; + private ToolStripStatusLabel toolStripStatusLabelAdditionalColor; + private ToolStripStatusLabel toolStripStatusLabelHasPipe; + private ToolStripStatusLabel toolStripStatusLabelHasFuelTank; + private Button buttonCreateModif; } } \ No newline at end of file diff --git a/Locomotives/Locomotives/FormLocomotive.cs b/Locomotives/Locomotives/FormLocomotive.cs index 20d5cbe..3a6d467 100644 --- a/Locomotives/Locomotives/FormLocomotive.cs +++ b/Locomotives/Locomotives/FormLocomotive.cs @@ -22,6 +22,34 @@ pictureBoxLocomotive.Image = bmp; } /// + /// Заполнение информации по объекту + /// + /// Объект от класса отрисовки или его наследника + private void SetData(DrawningLocomotive locomotive) + { + Random rnd = new(); + toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}"; + toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}"; + toolStripStatusLabelBodyColor.Text = $"Цвет: {locomotive.Locomotive.BodyColor.Name}"; + toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: н/д"; + toolStripStatusLabelHasPipe.Text = $"Наличие трубы: н/д"; + toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: н/д"; + _locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height); + } + /// + /// Заполнение дополнительной информации по объекту (только для усложнённого объекта) + /// + /// Объект от наследника класса отрисовки + private void SetAdditionalData(DrawningWarmlyLocomotive warmlylocomotive) + { + if (warmlylocomotive.Locomotive is EntityWarmlyLocomotive entityWarmlyLocomotive) + { + toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: {entityWarmlyLocomotive.AdditionalColor.Name}"; + toolStripStatusLabelHasPipe.Text = $"Наличие трубы: {entityWarmlyLocomotive.HasPipe}"; + toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: {entityWarmlyLocomotive.HasFuelTank}"; + } + } + /// /// Метод обработки нажатия на кнопку "Создать" /// /// @@ -30,10 +58,7 @@ { 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))); - _locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height); - toolStripStatusLabelSpeed.Text = $"Скорость: {_locomotive.Locomotive.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {_locomotive.Locomotive.Weight}"; - toolStripStatusLabelBodyColor.Text = $"Цвет: {_locomotive.Locomotive.BodyColor.Name}"; + SetData(_locomotive); Draw(); } /// @@ -72,5 +97,23 @@ _locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height); Draw(); } + /// + /// Обработка нажатия кнопки "Модификация" + /// + /// + /// + private void ButtonCreateModif_Click(object sender, EventArgs e) + { + Random rnd = new(); + _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)), + 160, 85, + 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(_locomotive); + SetAdditionalData((DrawningWarmlyLocomotive)_locomotive); + Draw(); + } } } From d26f6f304ad2e48e1913f874d95fc0998e88f513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Thu, 20 Oct 2022 16:42:41 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B5=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locomotives/Locomotives/AbstractMap.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Locomotives/Locomotives/AbstractMap.cs b/Locomotives/Locomotives/AbstractMap.cs index f27ed6e..2708099 100644 --- a/Locomotives/Locomotives/AbstractMap.cs +++ b/Locomotives/Locomotives/AbstractMap.cs @@ -186,7 +186,6 @@ int x = _random.Next(10, 100); int y = _random.Next(10, 100); _drawningObject.SetObject(x, y, _width, _height); - // TODO првоерка, что объект не "накладывается" на закрытые участки if (!AbleToSetObject()) { return false;