From d1878811232c690f32eb4f292b649a11f09fb0c6 Mon Sep 17 00:00:00 2001 From: xom9kxom9k Date: Sun, 17 Mar 2024 12:28:35 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICollectionGenericObjects.cs | 47 ++++++ .../MassiveGenereticObjects.cs | 136 ++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 AntiAircraftGun/CollectionGenereticObjects/ICollectionGenericObjects.cs create mode 100644 AntiAircraftGun/CollectionGenereticObjects/MassiveGenereticObjects.cs diff --git a/AntiAircraftGun/CollectionGenereticObjects/ICollectionGenericObjects.cs b/AntiAircraftGun/CollectionGenereticObjects/ICollectionGenericObjects.cs new file mode 100644 index 0000000..f746200 --- /dev/null +++ b/AntiAircraftGun/CollectionGenereticObjects/ICollectionGenericObjects.cs @@ -0,0 +1,47 @@ +namespace AntiAircraftGun.CollectionGenereticObject; +/// +/// Интерфейс описания действий для набора хранимых данных +/// +/// +public interface ICollectionGenericObjects + where T : class +{ + /// + /// Количество объектов в коллекции + /// + int Count { get; } + + /// + /// Установка максимального количества элементов + /// + int SetMaxCount { set; } + + /// + /// Добавление объекта в коллекцию + /// + /// Добавляемый объект + /// true - вставка прошла удачно, false - вставка не удалась + int Insert(T obj); + + /// + /// Добавление объекта в коллекцию на конкретную позицию + /// + /// Добавляемый объект + /// Позиция + /// true - вставка прошла удачно, false - вставка не удалась + int Insert(T obj, int position); + + /// + /// Удаление объекта из коллекции с конкретной позиции + /// + /// Позиция + /// true - удаление прошло удачно, false - удаление не удалось + T? Remove(int position); + + /// + /// Получение объекта по позиции + /// + /// Позиция + /// Объект + T? Get(int position); +} diff --git a/AntiAircraftGun/CollectionGenereticObjects/MassiveGenereticObjects.cs b/AntiAircraftGun/CollectionGenereticObjects/MassiveGenereticObjects.cs new file mode 100644 index 0000000..1412e89 --- /dev/null +++ b/AntiAircraftGun/CollectionGenereticObjects/MassiveGenereticObjects.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AntiAircraftGun.CollectionGenereticObject; + +/// +/// Параметризованный набор объектов +/// +/// Параметр: ограничение - ссылочный тип +public class MassiveGenericObjects : ICollectionGenericObjects + where T : class +{ + /// + /// Массив объектов, которые храним + /// + private T?[] _collection; + + public int Count => _collection.Length; + + public int SetMaxCount + { + set + { + if (value > 0) + { + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } + } + } + } + + /// + /// Конструктор + /// + public MassiveGenericObjects() + { + _collection = Array.Empty(); + } + + public T? Get(int position) + { + if (position >= 0 && position < Count) + { + return _collection[position]; + } + + return null; + } + + public int Insert(T obj) + { + // вставка в свободное место набора + for (int i = 0; i < Count; i++) + { + if (_collection[i] == null) + { + _collection[i] = obj; + return i; + } + } + + return -1; + } + + public int Insert(T obj, int position) + { + // проверка позиции + if (position < 0 || position >= Count) + { + return -1; + } + + // проверка, что элемент массива по этой позиции пустой, если нет, то + // ищется свободное место после этой позиции и идет вставка туда + // если нет после, ищем до + if (_collection[position] != null) + { + bool pushed = false; + for (int index = position + 1; index < Count; index++) + { + if (_collection[index] == null) + { + position = index; + pushed = true; + break; + } + } + + if (!pushed) + { + for (int index = position - 1; index >= 0; index--) + { + if (_collection[index] == null) + { + position = index; + pushed = true; + break; + } + } + } + + if (!pushed) + { + return position; + } + } + + // вставка + _collection[position] = obj; + return position; + } + + public T? Remove(int position) + { + // проверка позиции + if (position < 0 || position >= Count) + { + return null; + } + + if (_collection[position] == null) return null; + + T? temp = _collection[position]; + _collection[position] = null; + return temp; + } +} -- 2.25.1 From 485b0683d8dca4f1281e4ab4d5354819cba5d46c Mon Sep 17 00:00:00 2001 From: xom9kxom9k Date: Sun, 17 Mar 2024 14:18:19 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B3?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 118 +++++++++++ .../CollectionGenericObjects/CarBase.cs | 54 +++++ .../ICollectionGenericObjects.cs | 0 .../MassiveGenericObjects.cs} | 7 +- .../Drawnings/DrawningAntiAircraftGun.cs | 2 +- ...ngAircraftGun.cs => DrawningArmoredCar.cs} | 12 +- .../Entities/EntityAntiAircraftGun.cs | 2 +- ...tityAircraftGun.cs => EntityArmoredCar.cs} | 4 +- .../FormAntiAircraftGun.Designer.cs | 28 --- AntiAircraftGun/FormAntiAircraftGun.cs | 58 ++---- .../FormArmoredCarCollection.Designer.cs | 167 +++++++++++++++ AntiAircraftGun/FormArmoredCarCollection.cs | 191 ++++++++++++++++++ AntiAircraftGun/FormArmoredCarCollection.resx | 120 +++++++++++ .../MovementStrategy/MoveableAircraftGun.cs | 4 +- 14 files changed, 678 insertions(+), 89 deletions(-) create mode 100644 AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs create mode 100644 AntiAircraftGun/CollectionGenericObjects/CarBase.cs rename AntiAircraftGun/{CollectionGenereticObjects => CollectionGenericObjects}/ICollectionGenericObjects.cs (100%) rename AntiAircraftGun/{CollectionGenereticObjects/MassiveGenereticObjects.cs => CollectionGenericObjects/MassiveGenericObjects.cs} (96%) rename AntiAircraftGun/Drawnings/{DrawningAircraftGun.cs => DrawningArmoredCar.cs} (95%) rename AntiAircraftGun/Entities/{EntityAircraftGun.cs => EntityArmoredCar.cs} (89%) create mode 100644 AntiAircraftGun/FormArmoredCarCollection.Designer.cs create mode 100644 AntiAircraftGun/FormArmoredCarCollection.cs create mode 100644 AntiAircraftGun/FormArmoredCarCollection.resx diff --git a/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs new file mode 100644 index 0000000..94d28b4 --- /dev/null +++ b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs @@ -0,0 +1,118 @@ +using AntiAircraftGun.CollectionGenereticObject; +using AntiAircraftGun.Drawnings; + + +namespace AntiAircraftGun.CollectionGenereticObjects; + +/// +/// Абстракция компании, хранящий коллекцию автомобилей +/// +public abstract class AbstractCompany +{ + /// + /// Размер места (ширина) + /// + protected readonly int _placeSizeWidth = 210; + + /// + /// Размер места (высота) + /// + protected readonly int _placeSizeHeight = 80; + + /// + /// Ширина окна + /// + protected readonly int _pictureWidth; + + /// + /// Высота окна + /// + protected readonly int _pictureHeight; + + /// + /// Коллекция поездов + /// + protected ICollectionGenericObjects? _collection = null; + + /// + /// Вычисление максимального количества элементов, который можно разместить в окне + /// + private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight); + + /// + /// Конструктор + /// + /// Ширина окна + /// Высота окна + /// Коллекция поездов + public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) + { + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _collection = collection; + _collection.SetMaxCount = GetMaxCount; + } + + /// + /// Перегрузка оператора сложения для класса + /// + /// Компания + /// Добавляемый объект + /// + public static int operator +(AbstractCompany company, DrawningArmoredCar car) + { + return company._collection.Insert(car); + } + + /// + /// Перегрузка оператора удаления для класса + /// + /// Компания + /// Номер удаляемого объекта + /// + public static DrawningArmoredCar? operator -(AbstractCompany company, int position) + { + return company._collection?.Remove(position); + } + + /// + /// Получение случайного объекта из коллекции + /// + /// + public DrawningArmoredCar? GetRandomObject() + { + Random rnd = new(); + return _collection?.Get(rnd.Next(GetMaxCount)); + } + + /// + /// Вывод всей коллекции + /// + /// + public Bitmap? Show() + { + Bitmap bitmap = new(_pictureWidth, _pictureHeight); + Graphics graphics = Graphics.FromImage(bitmap); + DrawBackgound(graphics); + + SetObjectsPosition(); + for (int i = 0; i < (_collection?.Count ?? 0); ++i) + { + DrawningArmoredCar? obj = _collection?.Get(i); + obj?.DrawTransport(graphics); + } + + return bitmap; + } + + /// + /// Вывод заднего фона + /// + /// + protected abstract void DrawBackgound(Graphics g); + + /// + /// Расстановка объектов + /// + protected abstract void SetObjectsPosition(); +} diff --git a/AntiAircraftGun/CollectionGenericObjects/CarBase.cs b/AntiAircraftGun/CollectionGenericObjects/CarBase.cs new file mode 100644 index 0000000..019daf9 --- /dev/null +++ b/AntiAircraftGun/CollectionGenericObjects/CarBase.cs @@ -0,0 +1,54 @@ +using AntiAircraftGun.CollectionGenereticObject; +using AntiAircraftGun.Drawnings; + + +namespace AntiAircraftGun.CollectionGenereticObjects; +/// +/// Реализация абстрактной компании - база бронемашин +/// +public class CarBase : AbstractCompany +{ + /// + /// Конструктор + /// + /// + /// + /// + public CarBase(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) + { + } + + protected override void DrawBackgound(Graphics g) + { + Pen pen = new(Color.Black); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + { + for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) + { + g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * j)); + g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new(_placeSizeWidth * i, _placeSizeHeight * (j + 1))); + } + g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * (_pictureHeight / _placeSizeHeight)), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight))); + } + + + } + + protected override void SetObjectsPosition() + { + int n = 0; + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + { + for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) + { + DrawningArmoredCar? drawingTrans = _collection?.Get(n); + n++; + if (drawingTrans != null) + { + drawingTrans.SetPictureSize(_pictureWidth, _pictureHeight); + drawingTrans.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5); + } + } + } + } +} diff --git a/AntiAircraftGun/CollectionGenereticObjects/ICollectionGenericObjects.cs b/AntiAircraftGun/CollectionGenericObjects/ICollectionGenericObjects.cs similarity index 100% rename from AntiAircraftGun/CollectionGenereticObjects/ICollectionGenericObjects.cs rename to AntiAircraftGun/CollectionGenericObjects/ICollectionGenericObjects.cs diff --git a/AntiAircraftGun/CollectionGenereticObjects/MassiveGenereticObjects.cs b/AntiAircraftGun/CollectionGenericObjects/MassiveGenericObjects.cs similarity index 96% rename from AntiAircraftGun/CollectionGenereticObjects/MassiveGenereticObjects.cs rename to AntiAircraftGun/CollectionGenericObjects/MassiveGenericObjects.cs index 1412e89..febd359 100644 --- a/AntiAircraftGun/CollectionGenereticObjects/MassiveGenereticObjects.cs +++ b/AntiAircraftGun/CollectionGenericObjects/MassiveGenericObjects.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - +using AntiAircraftGun.Drawnings; namespace AntiAircraftGun.CollectionGenereticObject; /// diff --git a/AntiAircraftGun/Drawnings/DrawningAntiAircraftGun.cs b/AntiAircraftGun/Drawnings/DrawningAntiAircraftGun.cs index ffe3fd0..c55e767 100644 --- a/AntiAircraftGun/Drawnings/DrawningAntiAircraftGun.cs +++ b/AntiAircraftGun/Drawnings/DrawningAntiAircraftGun.cs @@ -4,7 +4,7 @@ namespace AntiAircraftGun.Drawnings; /// /// Класс отвечающий за прорисовку и перемещение объекта - сущности /// -public class DrawningAntiAircraftGun : DrawningAircraftGun +public class DrawningAntiAircraftGun : DrawningArmoredCar { /// /// Конструктор diff --git a/AntiAircraftGun/Drawnings/DrawningAircraftGun.cs b/AntiAircraftGun/Drawnings/DrawningArmoredCar.cs similarity index 95% rename from AntiAircraftGun/Drawnings/DrawningAircraftGun.cs rename to AntiAircraftGun/Drawnings/DrawningArmoredCar.cs index 097115b..a629544 100644 --- a/AntiAircraftGun/Drawnings/DrawningAircraftGun.cs +++ b/AntiAircraftGun/Drawnings/DrawningArmoredCar.cs @@ -2,12 +2,12 @@ namespace AntiAircraftGun.Drawnings; -public class DrawningAircraftGun +public class DrawningArmoredCar { /// /// Класс-сущность /// - public EntityAircraftGun? EntityAircraftGun { get; protected set; } + public EntityArmoredCar? EntityAircraftGun { get; protected set; } /// /// Ширина @@ -62,7 +62,7 @@ public class DrawningAircraftGun /// /// Пустой конструктор /// - private DrawningAircraftGun() + private DrawningArmoredCar() { _pictureWidth = null; _pictureHeight = null; @@ -76,9 +76,9 @@ public class DrawningAircraftGun /// Скорость /// Вес /// Основной цвет - public DrawningAircraftGun(int speed, double weight, Color bodyColor) : this() + public DrawningArmoredCar(int speed, double weight, Color bodyColor) : this() { - EntityAircraftGun = new EntityAircraftGun(speed, weight, bodyColor); + EntityAircraftGun = new EntityArmoredCar(speed, weight, bodyColor); } /// @@ -86,7 +86,7 @@ public class DrawningAircraftGun /// /// Ширина прорисовки зенитной установки /// Высота прорисовки зенитной установки - protected DrawningAircraftGun(int drawningGunWidth, int drawningGunHeight) : this() + protected DrawningArmoredCar(int drawningGunWidth, int drawningGunHeight) : this() { _drawningGunWidth = drawningGunWidth; _drawningGunHeight = drawningGunHeight; diff --git a/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs b/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs index 404ba48..f19de8a 100644 --- a/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs +++ b/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs @@ -2,7 +2,7 @@ /// /// Класс-сущность Зенитная установка /// -public class EntityAntiAircraftGun : EntityAircraftGun +public class EntityAntiAircraftGun : EntityArmoredCar { /// /// Дополниетльный цвет diff --git a/AntiAircraftGun/Entities/EntityAircraftGun.cs b/AntiAircraftGun/Entities/EntityArmoredCar.cs similarity index 89% rename from AntiAircraftGun/Entities/EntityAircraftGun.cs rename to AntiAircraftGun/Entities/EntityArmoredCar.cs index 03e77b0..9de4ea7 100644 --- a/AntiAircraftGun/Entities/EntityAircraftGun.cs +++ b/AntiAircraftGun/Entities/EntityArmoredCar.cs @@ -2,7 +2,7 @@ /// /// Класс - сущность Бронированная машина /// -public class EntityAircraftGun +public class EntityArmoredCar { /// /// Скорость @@ -27,7 +27,7 @@ public class EntityAircraftGun /// /// /// - public EntityAircraftGun(int speed, double weight, Color bodyColor) + public EntityArmoredCar(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; diff --git a/AntiAircraftGun/FormAntiAircraftGun.Designer.cs b/AntiAircraftGun/FormAntiAircraftGun.Designer.cs index 5f13f5f..02da2ee 100644 --- a/AntiAircraftGun/FormAntiAircraftGun.Designer.cs +++ b/AntiAircraftGun/FormAntiAircraftGun.Designer.cs @@ -33,8 +33,6 @@ buttonDown = new Button(); buttonRight = new Button(); buttonUp = new Button(); - buttonCreate = new Button(); - buttonCreatAircraftGun = new Button(); comboBoxStrategy = new ComboBox(); buttonStrategyStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxAntiAircraftGun).BeginInit(); @@ -97,28 +95,6 @@ buttonUp.UseVisualStyleBackColor = true; buttonUp.Click += ButtonMove_Click; // - // buttonCreate - // - buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreate.Location = new Point(12, 406); - buttonCreate.Name = "buttonCreate"; - buttonCreate.Size = new Size(215, 32); - buttonCreate.TabIndex = 1; - buttonCreate.Text = "Создать зенитную установку"; - buttonCreate.UseVisualStyleBackColor = true; - buttonCreate.Click += ButtonCreate_Click; - // - // buttonCreatAircraftGun - // - buttonCreatAircraftGun.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreatAircraftGun.Location = new Point(233, 406); - buttonCreatAircraftGun.Name = "buttonCreatAircraftGun"; - buttonCreatAircraftGun.Size = new Size(215, 32); - buttonCreatAircraftGun.TabIndex = 6; - buttonCreatAircraftGun.Text = "Создать бронированную машину"; - buttonCreatAircraftGun.UseVisualStyleBackColor = true; - buttonCreatAircraftGun.Click += buttonCreatAircraftGun_Click; - // // comboBoxStrategy // comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; @@ -146,12 +122,10 @@ ClientSize = new Size(800, 450); Controls.Add(buttonStrategyStep); Controls.Add(comboBoxStrategy); - Controls.Add(buttonCreatAircraftGun); Controls.Add(buttonUp); Controls.Add(buttonRight); Controls.Add(buttonDown); Controls.Add(buttonLeft); - Controls.Add(buttonCreate); Controls.Add(pictureBoxAntiAircraftGun); Name = "FormAntiAircraftGun"; Text = "Зенитная установка"; @@ -166,8 +140,6 @@ private Button buttonDown; private Button buttonRight; private Button buttonUp; - private Button buttonCreate; - private Button buttonCreatAircraftGun; private ComboBox comboBoxStrategy; private Button buttonStrategyStep; } diff --git a/AntiAircraftGun/FormAntiAircraftGun.cs b/AntiAircraftGun/FormAntiAircraftGun.cs index db4b09f..054de55 100644 --- a/AntiAircraftGun/FormAntiAircraftGun.cs +++ b/AntiAircraftGun/FormAntiAircraftGun.cs @@ -8,12 +8,26 @@ public partial class FormAntiAircraftGun : Form /// /// Поле объект для прорисовки объекта /// - private DrawningAircraftGun? _drawningAircraftGun; + private DrawningArmoredCar? _drawningAircraftGun; /// /// Стратегия перемещения /// private AbstractStrategy? _strategy; /// + /// Получение объекта + /// + public DrawningArmoredCar SetArmoredCar + { + set + { + _drawningAircraftGun = value; + _drawningAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height); + comboBoxStrategy.Enabled = true; + _strategy = null; + Draw(); + } + } + /// /// конструктор формы /// public FormAntiAircraftGun() @@ -35,48 +49,6 @@ public partial class FormAntiAircraftGun : Form _drawningAircraftGun.DrawTransport(gr); pictureBoxAntiAircraftGun.Image = bmp; } - /// - /// Метод создания объекта - /// - /// - private void CreateObject(string type) - { - Random random = new(); - switch (type) - { - case nameof(DrawningAircraftGun): - _drawningAircraftGun = new DrawningAircraftGun(random.Next(100, 300), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); - break; - case nameof(DrawningAntiAircraftGun): - _drawningAircraftGun = new DrawningAntiAircraftGun(random.Next(100, 300), 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))); - break; - default: - return; - } - - _drawningAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height); - _drawningAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100)); - _strategy = null; - comboBoxStrategy.Enabled = true; - Draw(); - } - /// - /// Обработка кнопик Создать Зенитную установку - /// - /// - /// - private void ButtonCreate_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun)); - /// - /// Обработка кнопик Создать установку - /// - /// - /// - private void buttonCreatAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAircraftGun)); - /// /// Перемещение объекта по форме /// diff --git a/AntiAircraftGun/FormArmoredCarCollection.Designer.cs b/AntiAircraftGun/FormArmoredCarCollection.Designer.cs new file mode 100644 index 0000000..5412d6c --- /dev/null +++ b/AntiAircraftGun/FormArmoredCarCollection.Designer.cs @@ -0,0 +1,167 @@ +namespace AntiAircraftGun +{ + partial class FormArmoredCarCollection + { + /// + /// 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() + { + groupBoxToools = new GroupBox(); + buttonRefresh = new Button(); + buttonGoToChek = new Button(); + buttonRemoveArmoredCar = new Button(); + maskedTextBox = new MaskedTextBox(); + buttonAddAntiAircraftGun = new Button(); + buttonAddArmoredCar = new Button(); + comboBoxSelectorCompany = new ComboBox(); + pictureBox = new PictureBox(); + groupBoxToools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + SuspendLayout(); + // + // groupBoxToools + // + groupBoxToools.Controls.Add(buttonRefresh); + groupBoxToools.Controls.Add(buttonGoToChek); + groupBoxToools.Controls.Add(buttonRemoveArmoredCar); + groupBoxToools.Controls.Add(maskedTextBox); + groupBoxToools.Controls.Add(buttonAddAntiAircraftGun); + groupBoxToools.Controls.Add(buttonAddArmoredCar); + groupBoxToools.Controls.Add(comboBoxSelectorCompany); + groupBoxToools.Dock = DockStyle.Right; + groupBoxToools.Location = new Point(1057, 0); + groupBoxToools.Name = "groupBoxToools"; + groupBoxToools.Size = new Size(210, 615); + groupBoxToools.TabIndex = 0; + groupBoxToools.TabStop = false; + groupBoxToools.Text = "Инструменты"; + // + // buttonRefresh + // + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRefresh.Location = new Point(6, 527); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(198, 39); + buttonRefresh.TabIndex = 6; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + // + // buttonGoToChek + // + buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonGoToChek.Location = new Point(6, 482); + buttonGoToChek.Name = "buttonGoToChek"; + buttonGoToChek.Size = new Size(198, 39); + buttonGoToChek.TabIndex = 5; + buttonGoToChek.Text = "Передать на тесты"; + buttonGoToChek.UseVisualStyleBackColor = true; + // + // buttonRemoveArmoredCar + // + buttonRemoveArmoredCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRemoveArmoredCar.Location = new Point(6, 302); + buttonRemoveArmoredCar.Name = "buttonRemoveArmoredCar"; + buttonRemoveArmoredCar.Size = new Size(198, 60); + buttonRemoveArmoredCar.TabIndex = 4; + buttonRemoveArmoredCar.Text = "Удалить бронемашину"; + buttonRemoveArmoredCar.UseVisualStyleBackColor = true; + // + // maskedTextBox + // + maskedTextBox.Location = new Point(6, 249); + maskedTextBox.Mask = "00"; + maskedTextBox.Name = "maskedTextBox"; + maskedTextBox.Size = new Size(198, 23); + maskedTextBox.TabIndex = 3; + maskedTextBox.ValidatingType = typeof(int); + // + // buttonAddAntiAircraftGun + // + buttonAddAntiAircraftGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddAntiAircraftGun.Location = new Point(6, 164); + buttonAddAntiAircraftGun.Name = "buttonAddAntiAircraftGun"; + buttonAddAntiAircraftGun.Size = new Size(198, 60); + buttonAddAntiAircraftGun.TabIndex = 2; + buttonAddAntiAircraftGun.Text = "Добавление зениитной установки"; + buttonAddAntiAircraftGun.UseVisualStyleBackColor = true; + // + // buttonAddArmoredCar + // + buttonAddArmoredCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddArmoredCar.Location = new Point(6, 86); + buttonAddArmoredCar.Name = "buttonAddArmoredCar"; + buttonAddArmoredCar.Size = new Size(198, 60); + buttonAddArmoredCar.TabIndex = 1; + buttonAddArmoredCar.Text = "Добавление бронемашины"; + buttonAddArmoredCar.UseVisualStyleBackColor = true; + // + // comboBoxSelectorCompany + // + comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxSelectorCompany.FormattingEnabled = true; + comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); + comboBoxSelectorCompany.Location = new Point(6, 22); + comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; + comboBoxSelectorCompany.Size = new Size(198, 23); + comboBoxSelectorCompany.TabIndex = 0; + // + // pictureBox + // + pictureBox.Dock = DockStyle.Fill; + pictureBox.Location = new Point(0, 0); + pictureBox.Name = "pictureBox"; + pictureBox.Size = new Size(1057, 615); + pictureBox.TabIndex = 1; + pictureBox.TabStop = false; + // + // FormArmoredCarCollection + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1267, 615); + Controls.Add(pictureBox); + Controls.Add(groupBoxToools); + Name = "FormArmoredCarCollection"; + Text = "Коллекция бронемашин"; + groupBoxToools.ResumeLayout(false); + groupBoxToools.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxToools; + private ComboBox comboBoxSelectorCompany; + private Button buttonAddArmoredCar; + private Button buttonAddAntiAircraftGun; + private PictureBox pictureBox; + private Button buttonRemoveArmoredCar; + private MaskedTextBox maskedTextBox; + private Button buttonRefresh; + private Button buttonGoToChek; + } +} \ No newline at end of file diff --git a/AntiAircraftGun/FormArmoredCarCollection.cs b/AntiAircraftGun/FormArmoredCarCollection.cs new file mode 100644 index 0000000..02ed2e9 --- /dev/null +++ b/AntiAircraftGun/FormArmoredCarCollection.cs @@ -0,0 +1,191 @@ +using AntiAircraftGun.CollectionGenereticObject; +using AntiAircraftGun.CollectionGenereticObjects; +using AntiAircraftGun.Drawnings; + + +namespace AntiAircraftGun; +/// +/// Форма работы с компанией и ее коллекцией +/// +public partial class FormArmoredCarCollection : Form +{ + /// + /// Компания + /// + private AbstractCompany? _company = null; + + /// + /// Конструктор + /// + public FormArmoredCarCollection() + { + InitializeComponent(); + } + + /// + /// Выбор компании + /// + /// + /// + private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBoxSelectorCompany.Text) + { + case "Хранилище": + _company = new CarBase(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); + break; + } + } + + /// + /// Добавление бронерованной машины + /// + /// + /// + private void ButtonAddArmoredCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningArmoredCar)); + + /// + /// Добавление зенитной установки + /// + /// + /// + private void ButtonAddAntiAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun)); + + /// + /// Создание объекта класса-перемещения + /// + /// Тип создаваемого объекта + private void CreateObject(string type) + { + if (_company == null) + { + return; + } + + Random random = new(); + DrawningArmoredCar drawningArmoredCar; + switch (type) + { + case nameof(DrawningArmoredCar): + drawningArmoredCar = new DrawningArmoredCar(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); + break; + case nameof(DrawningAntiAircraftGun): + // вызов диалогового окна для выбора цвета + drawningArmoredCar = new DrawningAntiAircraftGun(random.Next(100, 300), random.Next(1000, 3000), + GetColor(random), + GetColor(random), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + break; + default: + return; + } + + if (_company + drawningArmoredCar != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _company.Show(); + } + else + { + _ = MessageBox.Show(drawningArmoredCar.ToString()); + } + } + + /// + /// Получение цвета + /// + /// Генератор случайных чисел + /// + private static Color GetColor(Random random) + { + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + + return color; + } + + /// + /// Удаление объекта + /// + /// + /// + private void ButtonRemoveArmoredCar_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) + { + return; + } + + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + { + return; + } + + int pos = Convert.ToInt32(maskedTextBox.Text); + if (_company - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBox.Image = _company.Show(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + + /// + /// Передача объекта в другую форму + /// + /// + /// + private void ButtonGoToCheck_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + + DrawningArmoredCar? armoredcar = null; + int counter = 100; + while (armoredcar == null) + { + armoredcar = _company.GetRandomObject(); + counter--; + if (counter <= 0) + { + break; + } + } + + if (armoredcar == null) + { + return; + } + + FormAntiAircraftGun form = new() + { + SetArmoredCar = armoredcar + }; + + form.ShowDialog(); + } + + /// + /// Перерисовка коллекции + /// + /// + /// + private void ButtonRefresh_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + + pictureBox.Image = _company.Show(); + } +} diff --git a/AntiAircraftGun/FormArmoredCarCollection.resx b/AntiAircraftGun/FormArmoredCarCollection.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/AntiAircraftGun/FormArmoredCarCollection.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/AntiAircraftGun/MovementStrategy/MoveableAircraftGun.cs b/AntiAircraftGun/MovementStrategy/MoveableAircraftGun.cs index 94b93bb..762d4dd 100644 --- a/AntiAircraftGun/MovementStrategy/MoveableAircraftGun.cs +++ b/AntiAircraftGun/MovementStrategy/MoveableAircraftGun.cs @@ -7,12 +7,12 @@ public class MoveableAircraftGun: IMoveableObject /// /// Поле-объект класса DrawningAircraftGun или его наследника /// - private readonly DrawningAircraftGun? _drawningAircraftGun = null; + private readonly DrawningArmoredCar? _drawningAircraftGun = null; /// /// Конструктор /// /// Объект класса DrawningTrans - public MoveableAircraftGun(DrawningAircraftGun trans) + public MoveableAircraftGun(DrawningArmoredCar trans) { _drawningAircraftGun = trans; } -- 2.25.1 From 29a246d8f33d2220a8a1ac61ef0f8140419c3664 Mon Sep 17 00:00:00 2001 From: xom9kxom9k Date: Mon, 18 Mar 2024 14:23:34 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 14 +++--- .../CollectionGenericObjects/CarBase.cs | 49 ++++++++++++------- .../FormArmoredCarCollection.Designer.cs | 6 +++ AntiAircraftGun/FormArmoredCarCollection.cs | 43 ++++++++-------- AntiAircraftGun/Program.cs | 2 +- 5 files changed, 65 insertions(+), 49 deletions(-) diff --git a/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs index 94d28b4..6962202 100644 --- a/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs +++ b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs @@ -5,7 +5,7 @@ using AntiAircraftGun.Drawnings; namespace AntiAircraftGun.CollectionGenereticObjects; /// -/// Абстракция компании, хранящий коллекцию автомобилей +/// Абстракция компании, хранящий коллекцию бронемашин /// public abstract class AbstractCompany { @@ -30,7 +30,7 @@ public abstract class AbstractCompany protected readonly int _pictureHeight; /// - /// Коллекция поездов + /// Коллекция броенамашин /// protected ICollectionGenericObjects? _collection = null; @@ -57,11 +57,11 @@ public abstract class AbstractCompany /// Перегрузка оператора сложения для класса /// /// Компания - /// Добавляемый объект + /// Добавляемый объект /// - public static int operator +(AbstractCompany company, DrawningArmoredCar car) + public static int operator +(AbstractCompany company, DrawningArmoredCar airplan) { - return company._collection.Insert(car); + return company._collection.Insert(airplan); } /// @@ -70,9 +70,9 @@ public abstract class AbstractCompany /// Компания /// Номер удаляемого объекта /// - public static DrawningArmoredCar? operator -(AbstractCompany company, int position) + public static DrawningArmoredCar operator -(AbstractCompany company, int position) { - return company._collection?.Remove(position); + return company._collection.Remove(position); } /// diff --git a/AntiAircraftGun/CollectionGenericObjects/CarBase.cs b/AntiAircraftGun/CollectionGenericObjects/CarBase.cs index 019daf9..005230b 100644 --- a/AntiAircraftGun/CollectionGenericObjects/CarBase.cs +++ b/AntiAircraftGun/CollectionGenericObjects/CarBase.cs @@ -18,36 +18,47 @@ public class CarBase : AbstractCompany { } + /// + /// Отрисовка базы + /// + /// Графика protected override void DrawBackgound(Graphics g) { - Pen pen = new(Color.Black); - for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + Pen pen = new Pen(Color.Black, 4f); + for (int i = 0; i < _pictureHeight / _placeSizeHeight / 2; i++) { - for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) + g.DrawLine(pen, 0, i * _placeSizeHeight * 2, _pictureWidth / _placeSizeWidth * _placeSizeWidth, i * _placeSizeHeight * 2); + for (int j = 0; j < _pictureWidth / _placeSizeWidth + 1; ++j) { - g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * j)); - g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new(_placeSizeWidth * i, _placeSizeHeight * (j + 1))); + g.DrawLine(pen, j * _placeSizeWidth, i * _placeSizeHeight * 2, j * _placeSizeWidth, i * _placeSizeHeight * 2 + _placeSizeHeight); } - g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * (_pictureHeight / _placeSizeHeight)), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight))); } - - } - + /// + /// Установка объекта в базу + /// protected override void SetObjectsPosition() { - int n = 0; - for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + int nowWidth = 0; + int nowHeight = 0; + + for (int i = 0; i < (_collection?.Count ?? 0); i++) { - for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) + if (nowHeight > _pictureHeight / _placeSizeHeight) { - DrawningArmoredCar? drawingTrans = _collection?.Get(n); - n++; - if (drawingTrans != null) - { - drawingTrans.SetPictureSize(_pictureWidth, _pictureHeight); - drawingTrans.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5); - } + return; + } + if (_collection?.Get(i) != null) + { + _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); + _collection?.Get(i)?.SetPosition(_placeSizeWidth * nowWidth + 30, nowHeight * _placeSizeHeight * 2 + 20); + } + + if (nowWidth < _pictureWidth / _placeSizeWidth - 1) nowWidth++; + else + { + nowWidth = 0; + nowHeight++; } } } diff --git a/AntiAircraftGun/FormArmoredCarCollection.Designer.cs b/AntiAircraftGun/FormArmoredCarCollection.Designer.cs index 5412d6c..c369d4c 100644 --- a/AntiAircraftGun/FormArmoredCarCollection.Designer.cs +++ b/AntiAircraftGun/FormArmoredCarCollection.Designer.cs @@ -67,6 +67,7 @@ buttonRefresh.TabIndex = 6; buttonRefresh.Text = "Обновить"; buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += buttonRefresh_Click; // // buttonGoToChek // @@ -77,6 +78,7 @@ buttonGoToChek.TabIndex = 5; buttonGoToChek.Text = "Передать на тесты"; buttonGoToChek.UseVisualStyleBackColor = true; + buttonGoToChek.Click += buttonGoToChek_Click; // // buttonRemoveArmoredCar // @@ -87,6 +89,7 @@ buttonRemoveArmoredCar.TabIndex = 4; buttonRemoveArmoredCar.Text = "Удалить бронемашину"; buttonRemoveArmoredCar.UseVisualStyleBackColor = true; + buttonRemoveArmoredCar.Click += buttonRemoveArmoredCar_Click; // // maskedTextBox // @@ -106,6 +109,7 @@ buttonAddAntiAircraftGun.TabIndex = 2; buttonAddAntiAircraftGun.Text = "Добавление зениитной установки"; buttonAddAntiAircraftGun.UseVisualStyleBackColor = true; + buttonAddAntiAircraftGun.Click += buttonAddAntiAircraftGun_Click; // // buttonAddArmoredCar // @@ -116,6 +120,7 @@ buttonAddArmoredCar.TabIndex = 1; buttonAddArmoredCar.Text = "Добавление бронемашины"; buttonAddArmoredCar.UseVisualStyleBackColor = true; + buttonAddArmoredCar.Click += buttonAddArmoredCar_Click; // // comboBoxSelectorCompany // @@ -127,6 +132,7 @@ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(198, 23); comboBoxSelectorCompany.TabIndex = 0; + comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged; // // pictureBox // diff --git a/AntiAircraftGun/FormArmoredCarCollection.cs b/AntiAircraftGun/FormArmoredCarCollection.cs index 02ed2e9..5dd8927 100644 --- a/AntiAircraftGun/FormArmoredCarCollection.cs +++ b/AntiAircraftGun/FormArmoredCarCollection.cs @@ -27,7 +27,7 @@ public partial class FormArmoredCarCollection : Form /// /// /// - private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) + private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBoxSelectorCompany.Text) { @@ -42,15 +42,14 @@ public partial class FormArmoredCarCollection : Form /// /// /// - private void ButtonAddArmoredCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningArmoredCar)); + private void buttonAddArmoredCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningArmoredCar)); /// /// Добавление зенитной установки /// /// /// - private void ButtonAddAntiAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun)); - + private void buttonAddAntiAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun)); /// /// Создание объекта класса-перемещения /// @@ -113,18 +112,16 @@ public partial class FormArmoredCarCollection : Form /// /// /// - private void ButtonRemoveArmoredCar_Click(object sender, EventArgs e) + private void buttonRemoveArmoredCar_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) { return; } - if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } - int pos = Convert.ToInt32(maskedTextBox.Text); if (_company - pos != null) { @@ -137,12 +134,27 @@ public partial class FormArmoredCarCollection : Form } } + /// + /// Перерисовка коллекции + /// + /// + /// + private void buttonRefresh_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + + pictureBox.Image = _company.Show(); + } + /// /// Передача объекта в другую форму /// /// /// - private void ButtonGoToCheck_Click(object sender, EventArgs e) + private void buttonGoToChek_Click(object sender, EventArgs e) { if (_company == null) { @@ -174,18 +186,5 @@ public partial class FormArmoredCarCollection : Form form.ShowDialog(); } - /// - /// Перерисовка коллекции - /// - /// - /// - private void ButtonRefresh_Click(object sender, EventArgs e) - { - if (_company == null) - { - return; - } - - pictureBox.Image = _company.Show(); - } + } diff --git a/AntiAircraftGun/Program.cs b/AntiAircraftGun/Program.cs index 5abc523..09b34fb 100644 --- a/AntiAircraftGun/Program.cs +++ b/AntiAircraftGun/Program.cs @@ -11,7 +11,7 @@ namespace AntiAircraftGun // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormAntiAircraftGun()); + Application.Run(new FormArmoredCarCollection()); } } } \ No newline at end of file -- 2.25.1 From 3de0a2be47fd10b75b41e788acce80d737db6404 Mon Sep 17 00:00:00 2001 From: xom9kxom9k Date: Tue, 19 Mar 2024 18:16:53 +0400 Subject: [PATCH 4/5] =?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=D1=83=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=B0=20=D0=B2=20=D0=B1=D0=B0=D0=B7=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs | 4 ++-- AntiAircraftGun/CollectionGenericObjects/CarBase.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs index 6962202..c33b1ae 100644 --- a/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs +++ b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs @@ -12,12 +12,12 @@ public abstract class AbstractCompany /// /// Размер места (ширина) /// - protected readonly int _placeSizeWidth = 210; + protected readonly int _placeSizeWidth = 180; /// /// Размер места (высота) /// - protected readonly int _placeSizeHeight = 80; + protected readonly int _placeSizeHeight = 100; /// /// Ширина окна diff --git a/AntiAircraftGun/CollectionGenericObjects/CarBase.cs b/AntiAircraftGun/CollectionGenericObjects/CarBase.cs index 005230b..4fe96ec 100644 --- a/AntiAircraftGun/CollectionGenericObjects/CarBase.cs +++ b/AntiAircraftGun/CollectionGenericObjects/CarBase.cs @@ -50,8 +50,8 @@ public class CarBase : AbstractCompany } if (_collection?.Get(i) != null) { - _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); - _collection?.Get(i)?.SetPosition(_placeSizeWidth * nowWidth + 30, nowHeight * _placeSizeHeight * 2 + 20); + _collection?.Get(i)?.SetPictureSize(_pictureWidth , _pictureHeight); + _collection?.Get(i)?.SetPosition(_placeSizeWidth * nowWidth + 10, nowHeight * _placeSizeHeight * 2 ); } if (nowWidth < _pictureWidth / _placeSizeWidth - 1) nowWidth++; -- 2.25.1 From 46c57f0c2224f13ea7bd4f55c270c0b53f1478e9 Mon Sep 17 00:00:00 2001 From: xom9kxom9k Date: Sat, 23 Mar 2024 13:03:54 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BD=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=20=E2=84=963?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs index c33b1ae..74b107e 100644 --- a/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs +++ b/AntiAircraftGun/CollectionGenericObjects/AbstractCompany.cs @@ -37,7 +37,7 @@ public abstract class AbstractCompany /// /// Вычисление максимального количества элементов, который можно разместить в окне /// - private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight); + private int GetMaxCount => _pictureWidth / _placeSizeWidth * (_pictureHeight / _placeSizeHeight / 2); /// /// Конструктор -- 2.25.1