From bb43453044e665393cae799733b22301fee1529b Mon Sep 17 00:00:00 2001
From: SAliulov <146759803+SAliulov@users.noreply.github.com>
Date: Wed, 24 Apr 2024 00:33:24 +0300
Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=20=E2=84=964?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BomberHungarService.cs | 16 +-
.../CollectionType.cs | 26 ++
.../ListGenericObjects.cs | 59 ++++
.../StorageCollection.cs | 74 +++++
.../FormBomberCollection.Designer.cs | 265 +++++++++++++-----
.../ProjectAirBomber/FormBomberCollection.cs | 105 ++++++-
6 files changed, 465 insertions(+), 80 deletions(-)
create mode 100644 ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/CollectionType.cs
create mode 100644 ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/ListGenericObjects.cs
create mode 100644 ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/StorageCollection.cs
diff --git a/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/BomberHungarService.cs b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/BomberHungarService.cs
index d83c69a..7625891 100644
--- a/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/BomberHungarService.cs
+++ b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/BomberHungarService.cs
@@ -25,21 +25,23 @@ public class BomberHungarService : AbstractCompany
///
///
protected override void DrawBackgound(Graphics g)
- {
+ {
Pen pen = new(Color.Black, 2);
for (int i = 0; i < _pictureWidth / _placeSizeWidth + 1; i++)
{
- for(int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
+ for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
{
- g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.7f)), _placeSizeHeight * j));
- g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new(_placeSizeWidth * i, _placeSizeHeight * (j + 1)));
- }
+ g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.7f)), _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.7f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight)));
}
-
-
}
+
+
+
+
///
/// Установка объекта в Ангар
///
diff --git a/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/CollectionType.cs b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/CollectionType.cs
new file mode 100644
index 0000000..abc634b
--- /dev/null
+++ b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/CollectionType.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirBomber.CollectionGenericObjects;
+
+///
+/// Тип коллекции
+///
+public enum CollectionType
+{
+ ///
+ /// Неопределено
+ ///
+ None = 0,
+ ///
+ /// Массив
+ ///
+ Massive = 1,
+ ///
+ /// Список
+ ///
+ List = 2
+}
\ No newline at end of file
diff --git a/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/ListGenericObjects.cs b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/ListGenericObjects.cs
new file mode 100644
index 0000000..b11e83c
--- /dev/null
+++ b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/ListGenericObjects.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+namespace ProjectAirBomber.CollectionGenericObjects;
+
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public class ListGenericObjects : ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Список объектов, которые храним
+ ///
+ private readonly List _collection;
+ ///
+ /// Максимально допустимое число объектов в списке
+ ///
+ private int _maxCount;
+ public int Count => _collection.Count;
+ public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
+ ///
+ /// Конструктор
+ ///
+ public ListGenericObjects()
+ {
+ _collection = new();
+ }
+ public T? Get(int position)
+ {
+ if (position >= Count || position < 0) return null;
+ return _collection[position];
+ }
+ public int Insert(T obj)
+ {
+ if (Count + 1 > _maxCount) return -1;
+ _collection.Add(obj);
+ return Count;
+ }
+ public int Insert(T obj, int position)
+ {
+ if (Count + 1 > _maxCount) return -1;
+ if (position < 0 || position > Count) return -1;
+ _collection.Insert(position, obj);
+ return 1;
+ }
+ public T? Remove(int position)
+ {
+ if (position < 0 || position > Count) return null;
+ T? temp = _collection[position];
+ _collection.RemoveAt(position);
+ return temp;
+ }
+}
diff --git a/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/StorageCollection.cs b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/StorageCollection.cs
new file mode 100644
index 0000000..ef5175c
--- /dev/null
+++ b/ProjectAirBomber/ProjectAirBomber/CollectionGenericObjects/StorageCollection.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirBomber.CollectionGenericObjects;
+
+///
+/// Класс-хранилище коллекций
+///
+///
+public class StorageCollection
+ where T : class
+{
+ ///
+ /// Словарь (хранилище) с коллекциями
+ ///
+ readonly Dictionary> _storages;
+
+ ///
+ /// Возвращение списка названий коллекций
+ ///
+ public List Keys => _storages.Keys.ToList();
+
+ ///
+ /// Конструктор
+ ///
+ public StorageCollection()
+ {
+ _storages = new Dictionary>();
+ }
+
+ ///
+ /// Добавление коллекции в хранилище
+ ///
+ /// Название коллекции
+ /// тип коллекции
+ public void AddCollection(string name, CollectionType collectionType)
+ {
+
+ if (_storages.ContainsKey(name)) return;
+ if (collectionType == CollectionType.None) return;
+ else if (collectionType == CollectionType.Massive)
+ _storages[name] = new MassiveGenericObjects();
+ else if (collectionType == CollectionType.List)
+ _storages[name] = new ListGenericObjects();
+ }
+
+ ///
+ /// Удаление коллекции
+ ///
+ /// Название коллекции
+ public void DelCollection(string name)
+ {
+ if (_storages.ContainsKey(name))
+ _storages.Remove(name);
+ }
+
+ ///
+ /// Доступ к коллекции
+ ///
+ /// Название коллекции
+ ///
+ public ICollectionGenericObjects? this[string name]
+ {
+ get
+ {
+ if (_storages.ContainsKey(name))
+ return _storages[name];
+ return null;
+ }
+ }
+}
diff --git a/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.Designer.cs b/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.Designer.cs
index f4cbbef..48f1fbd 100644
--- a/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.Designer.cs
+++ b/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.Designer.cs
@@ -29,98 +29,214 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
- buttonRefresh = new Button();
- buttonGoToCheck = new Button();
- buttonRemoveBomber = new Button();
- maskedTextBoxPosition = new MaskedTextBox();
- buttonAddAirBomber = new Button();
+ panelCompanyTools = new Panel();
buttonAddBomber = new Button();
+ buttonAddAirBomber = new Button();
+ maskedTextBoxPosition = new MaskedTextBox();
+ buttonRefresh = new Button();
+ buttonRemoveBomber = new Button();
+ buttonGoToCheck = new Button();
+ buttonCreateCompany = new Button();
+ panelStorage = new Panel();
+ buttonCollectionDel = new Button();
+ listBoxCollection = new ListBox();
+ buttonCollectionAdd = new Button();
+ radioButtonList = new RadioButton();
+ radioButtonMassive = new RadioButton();
+ textBoxCollectionName = new TextBox();
+ labelCollectionName = new Label();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
+ panelCompanyTools.SuspendLayout();
+ panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
- groupBoxTools.Controls.Add(buttonRefresh);
- groupBoxTools.Controls.Add(buttonGoToCheck);
- groupBoxTools.Controls.Add(buttonRemoveBomber);
- groupBoxTools.Controls.Add(maskedTextBoxPosition);
- groupBoxTools.Controls.Add(buttonAddAirBomber);
- groupBoxTools.Controls.Add(buttonAddBomber);
+ groupBoxTools.Controls.Add(panelCompanyTools);
+ groupBoxTools.Controls.Add(buttonCreateCompany);
+ groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
- groupBoxTools.Location = new Point(1136, 0);
+ groupBoxTools.Location = new Point(1104, 0);
groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(268, 835);
+ groupBoxTools.Size = new Size(268, 833);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
- // buttonRefresh
+ // panelCompanyTools
//
- buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonRefresh.Location = new Point(20, 567);
- buttonRefresh.Name = "buttonRefresh";
- buttonRefresh.Size = new Size(236, 42);
- buttonRefresh.TabIndex = 6;
- buttonRefresh.Text = "Обновить";
- buttonRefresh.UseVisualStyleBackColor = true;
- buttonRefresh.Click += ButtonRefresh_Click;
+ panelCompanyTools.Controls.Add(buttonAddBomber);
+ panelCompanyTools.Controls.Add(buttonAddAirBomber);
+ panelCompanyTools.Controls.Add(maskedTextBoxPosition);
+ panelCompanyTools.Controls.Add(buttonRefresh);
+ panelCompanyTools.Controls.Add(buttonRemoveBomber);
+ panelCompanyTools.Controls.Add(buttonGoToCheck);
+ panelCompanyTools.Dock = DockStyle.Bottom;
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(3, 545);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(262, 285);
+ panelCompanyTools.TabIndex = 9;
//
- // buttonGoToCheck
+ // buttonAddBomber
//
- buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonGoToCheck.Location = new Point(20, 314);
- buttonGoToCheck.Name = "buttonGoToCheck";
- buttonGoToCheck.Size = new Size(236, 42);
- buttonGoToCheck.TabIndex = 5;
- buttonGoToCheck.Text = "Передать на тесты";
- buttonGoToCheck.UseVisualStyleBackColor = true;
- buttonGoToCheck.Click += ButtonGoToCheck_Click;
- //
- // buttonRemoveBomber
- //
- buttonRemoveBomber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonRemoveBomber.Location = new Point(20, 255);
- buttonRemoveBomber.Name = "buttonRemoveBomber";
- buttonRemoveBomber.Size = new Size(236, 42);
- buttonRemoveBomber.TabIndex = 4;
- buttonRemoveBomber.Text = "Удалить военный самолёт";
- buttonRemoveBomber.UseVisualStyleBackColor = true;
- buttonRemoveBomber.Click += ButtonRemoveBomber_Click;
- //
- // maskedTextBoxPosition
- //
- maskedTextBoxPosition.Location = new Point(20, 210);
- maskedTextBoxPosition.Mask = "00";
- maskedTextBoxPosition.Name = "maskedTextBoxPosition";
- maskedTextBoxPosition.Size = new Size(236, 23);
- maskedTextBoxPosition.TabIndex = 3;
- maskedTextBoxPosition.ValidatingType = typeof(int);
+ buttonAddBomber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddBomber.Location = new Point(3, 3);
+ buttonAddBomber.Name = "buttonAddBomber";
+ buttonAddBomber.Size = new Size(253, 42);
+ buttonAddBomber.TabIndex = 1;
+ buttonAddBomber.Text = "Добавление военного самолёта";
+ buttonAddBomber.UseVisualStyleBackColor = true;
+ buttonAddBomber.Click += ButtonAddBomber_Click;
//
// buttonAddAirBomber
//
buttonAddAirBomber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddAirBomber.Location = new Point(20, 149);
+ buttonAddAirBomber.Location = new Point(3, 51);
buttonAddAirBomber.Name = "buttonAddAirBomber";
- buttonAddAirBomber.Size = new Size(236, 42);
+ buttonAddAirBomber.Size = new Size(253, 42);
buttonAddAirBomber.TabIndex = 2;
buttonAddAirBomber.Text = "Добавление бомбардировщика";
buttonAddAirBomber.UseVisualStyleBackColor = true;
buttonAddAirBomber.Click += ButtonAddAirBomber_Click;
//
- // buttonAddBomber
+ // maskedTextBoxPosition
//
- buttonAddBomber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddBomber.Location = new Point(20, 91);
- buttonAddBomber.Name = "buttonAddBomber";
- buttonAddBomber.Size = new Size(236, 42);
- buttonAddBomber.TabIndex = 1;
- buttonAddBomber.Text = "Добавление военного самолёта";
- buttonAddBomber.UseVisualStyleBackColor = true;
- buttonAddBomber.Click += ButtonAddBomber_Click;
+ maskedTextBoxPosition.Location = new Point(3, 99);
+ maskedTextBoxPosition.Mask = "00";
+ maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ maskedTextBoxPosition.Size = new Size(253, 23);
+ maskedTextBoxPosition.TabIndex = 3;
+ maskedTextBoxPosition.ValidatingType = typeof(int);
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(3, 228);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(253, 42);
+ buttonRefresh.TabIndex = 6;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // buttonRemoveBomber
+ //
+ buttonRemoveBomber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRemoveBomber.Location = new Point(3, 128);
+ buttonRemoveBomber.Name = "buttonRemoveBomber";
+ buttonRemoveBomber.Size = new Size(253, 42);
+ buttonRemoveBomber.TabIndex = 4;
+ buttonRemoveBomber.Text = "Удалить военный самолёт";
+ buttonRemoveBomber.UseVisualStyleBackColor = true;
+ buttonRemoveBomber.Click += ButtonRemoveBomber_Click;
+ //
+ // buttonGoToCheck
+ //
+ buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonGoToCheck.Location = new Point(3, 176);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(253, 46);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += ButtonGoToCheck_Click;
+ //
+ // buttonCreateCompany
+ //
+ buttonCreateCompany.Location = new Point(3, 481);
+ buttonCreateCompany.Name = "buttonCreateCompany";
+ buttonCreateCompany.Size = new Size(262, 44);
+ buttonCreateCompany.TabIndex = 8;
+ buttonCreateCompany.Text = "Создать компанию";
+ buttonCreateCompany.UseVisualStyleBackColor = true;
+ buttonCreateCompany.Click += ButtonCreateCompany_Click;
+ //
+ // panelStorage
+ //
+ panelStorage.Controls.Add(buttonCollectionDel);
+ panelStorage.Controls.Add(listBoxCollection);
+ panelStorage.Controls.Add(buttonCollectionAdd);
+ panelStorage.Controls.Add(radioButtonList);
+ panelStorage.Controls.Add(radioButtonMassive);
+ panelStorage.Controls.Add(textBoxCollectionName);
+ panelStorage.Controls.Add(labelCollectionName);
+ panelStorage.Dock = DockStyle.Top;
+ panelStorage.Location = new Point(3, 19);
+ panelStorage.Name = "panelStorage";
+ panelStorage.Size = new Size(262, 394);
+ panelStorage.TabIndex = 7;
+ //
+ // buttonCollectionDel
+ //
+ buttonCollectionDel.Location = new Point(3, 318);
+ buttonCollectionDel.Name = "buttonCollectionDel";
+ buttonCollectionDel.Size = new Size(256, 65);
+ buttonCollectionDel.TabIndex = 6;
+ buttonCollectionDel.Text = "Удалить коллекцию";
+ buttonCollectionDel.UseVisualStyleBackColor = true;
+ buttonCollectionDel.Click += ButtonCollectionDel_Click;
+ //
+ // listBoxCollection
+ //
+ listBoxCollection.FormattingEnabled = true;
+ listBoxCollection.ItemHeight = 15;
+ listBoxCollection.Location = new Point(3, 158);
+ listBoxCollection.Name = "listBoxCollection";
+ listBoxCollection.Size = new Size(256, 154);
+ listBoxCollection.TabIndex = 5;
+ //
+ // buttonCollectionAdd
+ //
+ buttonCollectionAdd.Location = new Point(3, 119);
+ buttonCollectionAdd.Name = "buttonCollectionAdd";
+ buttonCollectionAdd.Size = new Size(256, 33);
+ buttonCollectionAdd.TabIndex = 4;
+ buttonCollectionAdd.Text = "Добавить коллекцию";
+ buttonCollectionAdd.UseVisualStyleBackColor = true;
+ buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
+ //
+ // radioButtonList
+ //
+ radioButtonList.AutoSize = true;
+ radioButtonList.Location = new Point(130, 94);
+ radioButtonList.Name = "radioButtonList";
+ radioButtonList.Size = new Size(66, 19);
+ radioButtonList.TabIndex = 3;
+ radioButtonList.TabStop = true;
+ radioButtonList.Text = "Список";
+ radioButtonList.UseVisualStyleBackColor = true;
+ //
+ // radioButtonMassive
+ //
+ radioButtonMassive.AutoSize = true;
+ radioButtonMassive.Location = new Point(17, 94);
+ radioButtonMassive.Name = "radioButtonMassive";
+ radioButtonMassive.Size = new Size(67, 19);
+ radioButtonMassive.TabIndex = 2;
+ radioButtonMassive.TabStop = true;
+ radioButtonMassive.Text = "Массив";
+ radioButtonMassive.UseVisualStyleBackColor = true;
+ //
+ // textBoxCollectionName
+ //
+ textBoxCollectionName.Location = new Point(3, 56);
+ textBoxCollectionName.Name = "textBoxCollectionName";
+ textBoxCollectionName.Size = new Size(256, 23);
+ textBoxCollectionName.TabIndex = 1;
+ //
+ // labelCollectionName
+ //
+ labelCollectionName.AutoSize = true;
+ labelCollectionName.Location = new Point(74, 18);
+ labelCollectionName.Name = "labelCollectionName";
+ labelCollectionName.Size = new Size(122, 15);
+ labelCollectionName.TabIndex = 0;
+ labelCollectionName.Text = "Название коллекции";
//
// comboBoxSelectorCompany
//
@@ -128,9 +244,9 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- comboBoxSelectorCompany.Location = new Point(20, 22);
+ comboBoxSelectorCompany.Location = new Point(3, 438);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
- comboBoxSelectorCompany.Size = new Size(236, 23);
+ comboBoxSelectorCompany.Size = new Size(262, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
@@ -139,7 +255,7 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(1136, 835);
+ pictureBox.Size = new Size(1104, 833);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@@ -147,17 +263,22 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(1404, 835);
+ ClientSize = new Size(1372, 833);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormBomberCollection";
Text = "Коллекция самолетов";
groupBoxTools.ResumeLayout(false);
- groupBoxTools.PerformLayout();
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
+ panelStorage.ResumeLayout(false);
+ panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
+
+
#endregion
private GroupBox groupBoxTools;
@@ -169,5 +290,15 @@
private Button buttonRemoveBomber;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonRefresh;
+ private Panel panelStorage;
+ private RadioButton radioButtonList;
+ private RadioButton radioButtonMassive;
+ private TextBox textBoxCollectionName;
+ private Label labelCollectionName;
+ private Button buttonCollectionAdd;
+ private Button buttonCreateCompany;
+ private Button buttonCollectionDel;
+ private ListBox listBoxCollection;
+ private Panel panelCompanyTools;
}
}
\ No newline at end of file
diff --git a/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.cs b/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.cs
index bbd61d6..ba37283 100644
--- a/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.cs
+++ b/ProjectAirBomber/ProjectAirBomber/FormBomberCollection.cs
@@ -18,6 +18,12 @@ namespace ProjectAirBomber;
///
public partial class FormBomberCollection : Form
{
+
+ ///
+ /// Хранилише коллекций
+ ///
+ private readonly StorageCollection _storageCollection;
+
///
/// Компания
///
@@ -29,6 +35,7 @@ public partial class FormBomberCollection : Form
public FormBomberCollection()
{
InitializeComponent();
+ _storageCollection = new();
}
///
@@ -38,12 +45,7 @@ public partial class FormBomberCollection : Form
///
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
- switch (comboBoxSelectorCompany.Text)
- {
- case "Хранилище":
- _company = new BomberHungarService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
- break;
- }
+ panelCompanyTools.Enabled = false;
}
///
@@ -196,4 +198,95 @@ public partial class FormBomberCollection : Form
pictureBox.Image = _company.Show();
}
+
+ ///
+ /// Добавление коллекции
+ ///
+ ///
+ ///
+ private void ButtonCollectionAdd_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCollectionName.Text) ||
+ (!radioButtonList.Checked && !radioButtonMassive.Checked))
+ {
+ MessageBox.Show("Не все данные заполнены", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ CollectionType collectionType = CollectionType.None;
+ if (radioButtonMassive.Checked)
+ {
+ collectionType = CollectionType.Massive;
+ }
+ else if (radioButtonList.Checked)
+ {
+ collectionType = CollectionType.List;
+ }
+ _storageCollection.AddCollection(textBoxCollectionName.Text,
+ collectionType);
+ RerfreshListBoxItems();
+ }
+ ///
+ /// Удаление коллекции
+ ///
+ ///
+ ///
+ private void ButtonCollectionDel_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+
+ if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
+ RerfreshListBoxItems();
+ }
+
+ ///
+ /// Обновление списка в listBoxCollection
+ ///
+ private void RerfreshListBoxItems()
+ {
+ listBoxCollection.Items.Clear();
+ for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
+ {
+ string? colName = _storageCollection.Keys?[i];
+ if (!string.IsNullOrEmpty(colName))
+ {
+ listBoxCollection.Items.Add(colName);
+ }
+ }
+ }
+ ///
+ /// Создание компании
+ ///
+ ///
+ ///
+ private void ButtonCreateCompany_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+ ICollectionGenericObjects? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
+ if (collection == null)
+ {
+ MessageBox.Show("Коллекция не проинициализирована");
+ return;
+ }
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new BomberHungarService(pictureBox.Width, pictureBox.Height, collection);
+ break;
+ }
+ panelCompanyTools.Enabled = true;
+ RerfreshListBoxItems();
+ }
}
\ No newline at end of file