From 47eec56d345a00ff4fbb6561466c28427ee1a0e9 Mon Sep 17 00:00:00 2001 From: dlopatin Date: Mon, 18 Mar 2024 11:23:53 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D1=83=D1=8E=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=83=D1=8E=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=83=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 3 +- .../CollectionGenericObjects/ArtilleryBase.cs | 37 ++++++++++++++++++- .../Drawnings/DrawningPropelledArtillery.cs | 2 +- .../DrawningSelfPropelledArtilleryUnit.cs | 2 +- ...rmPropelledArtilleryCollection.Designer.cs | 2 + .../FormPropelledArtilleryCollection.cs | 30 +++++++++------ 6 files changed, 59 insertions(+), 17 deletions(-) diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/AbstractCompany.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/AbstractCompany.cs index b62b879..39e9cdf 100644 --- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/AbstractCompany.cs +++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/AbstractCompany.cs @@ -15,7 +15,7 @@ public abstract class AbstractCompany /// /// Размер места (высота) /// - protected readonly int _placeSizeHeight = 80; + protected readonly int _placeSizeHeight = 120; /// /// Ширина окна @@ -73,6 +73,7 @@ public abstract class AbstractCompany return company._collection?.Remove(position); } + /// /// Получение случайного объекта из коллекции /// diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ArtilleryBase.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ArtilleryBase.cs index e5afd86..4405975 100644 --- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ArtilleryBase.cs +++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ArtilleryBase.cs @@ -19,11 +19,44 @@ public class ArtilleryBase : AbstractCompany protected override void DrawBackgound(Graphics g) { - throw new NotImplementedException(); + int width = _pictureWidth / _placeSizeWidth; + int height = _pictureHeight / _placeSizeHeight; + Pen pen = new(Color.Black, 3); + for (int i = 0; i < width; i++) + { + for (int j = 0; j < height + 1; ++j) + { + g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 5, j * _placeSizeHeight); + } + } } protected override void SetObjectsPosition() { - throw new NotImplementedException(); + int width = _pictureWidth / _placeSizeWidth; + int height = _pictureHeight / _placeSizeHeight; + + int curWidth = width - 1; + int curHeight = 0; + + for (int i = 0; i < (_collection?.Count ?? 0); i++) + { + if (_collection.Get(i) != null) + { + _collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight); + _collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 40, curHeight * _placeSizeHeight + 4); + } + if (curWidth > 0) + curWidth--; + else + { + curWidth = width - 1; + curHeight++; + } + if (curHeight > height) + { + return; + } + } } } diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningPropelledArtillery.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningPropelledArtillery.cs index c1a3260..1b7ea63 100644 --- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningPropelledArtillery.cs +++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningPropelledArtillery.cs @@ -229,7 +229,7 @@ public class DrawningPropelledArtillery g.DrawRectangle(pen, _startPosX.Value + 15, _startPosY.Value + 75, 90, 30); //границы ЦВЕТ - Brush brOlive = new SolidBrush(Color.Olive); + Brush brOlive = new SolidBrush(EntityPropelledArtillery.BodyColor); g.FillRectangle(brOlive, _startPosX.Value + 25, _startPosY.Value + 40, 35, 30);//башня g.FillEllipse(brOlive, _startPosX.Value + 0, _startPosY.Value + 75, 30, 30); g.FillEllipse(brOlive, _startPosX.Value + 90, _startPosY.Value + 75, 30, 30); diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningSelfPropelledArtilleryUnit.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningSelfPropelledArtilleryUnit.cs index 628afb9..e45c473 100644 --- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningSelfPropelledArtilleryUnit.cs +++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Drawnings/DrawningSelfPropelledArtilleryUnit.cs @@ -29,6 +29,7 @@ public class DrawningSelfPropelledArtilleryUnit : DrawningPropelledArtillery Pen pen = new(Color.Black); Brush additionalBrush = new SolidBrush(selfpropelledartilleryunit.AdditionalColor); + base.DrawTransport(g); if (selfpropelledartilleryunit.TurretCannon) { g.FillEllipse(additionalBrush, _startPosX.Value + 26, _startPosY.Value + 35, 50, 30); @@ -51,7 +52,6 @@ public class DrawningSelfPropelledArtilleryUnit : DrawningPropelledArtillery g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 25, 15, 5); } - base.DrawTransport(g); } diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.Designer.cs index dcaee96..3311f7c 100644 --- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.Designer.cs +++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.Designer.cs @@ -111,6 +111,7 @@ buttonAddSelfPropelledArtilleryUnit.TabIndex = 2; buttonAddSelfPropelledArtilleryUnit.Text = "Добавление самоходная арт. установки"; buttonAddSelfPropelledArtilleryUnit.UseVisualStyleBackColor = true; + buttonAddSelfPropelledArtilleryUnit.Click += buttonAddSelfPropelledArtilleryUnit_Click_1; // // buttonAddPropelledArtillery // @@ -121,6 +122,7 @@ buttonAddPropelledArtillery.TabIndex = 1; buttonAddPropelledArtillery.Text = "Добавление бронированной машины"; buttonAddPropelledArtillery.UseVisualStyleBackColor = true; + buttonAddPropelledArtillery.Click += buttonAddPropelledArtillery_Click_1; // // comboBoxSelectorCompany // diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.cs index a33e363..8fc01bf 100644 --- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.cs +++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.cs @@ -42,20 +42,24 @@ public partial class FormPropelledArtilleryCollection : Form break; } } + private void buttonAddPropelledArtillery_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningPropelledArtillery)); + - /// - /// Добавление Бронированная машина - /// - /// - /// - private void ButtonAddPropelledArtillery_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPropelledArtillery)); + private void buttonAddSelfPropelledArtilleryUnit_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningSelfPropelledArtilleryUnit)); - /// - /// Добавление Самоходная арт. установка - /// - /// - /// - private void ButtonAddSelfPropelledArtilleryUnit_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSelfPropelledArtilleryUnit)); + // /// + ///// Добавление Бронированная машина + ///// + ///// + ///// + //private void ButtonAddPropelledArtillery_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPropelledArtillery)); + + // /// + // /// Добавление Самоходная арт. установка + // /// + // /// + // /// + // private void ButtonAddSelfPropelledArtilleryUnit_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSelfPropelledArtilleryUnit)); /// /// Создание объекта класса-перемещения @@ -192,6 +196,8 @@ public partial class FormPropelledArtilleryCollection : Form } pictureBox.Image = _company.Show(); } + + }