diff --git a/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/CollectionType.cs b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/CollectionType.cs
new file mode 100644
index 0000000..a2c9295
--- /dev/null
+++ b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/CollectionType.cs
@@ -0,0 +1,20 @@
+namespace ProjectStormtrooper.CollectionGenericObjects;
+
+///
+/// Тип коллекции
+///
+public enum CollectionType
+{
+ ///
+ /// Неопределено
+ ///
+ None = 0,
+ ///
+ /// Массив
+ ///
+ Massive = 1,
+ ///
+ /// Список
+ ///
+ List = 2
+}
\ No newline at end of file
diff --git a/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/ListGenericObjects.cs b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/ListGenericObjects.cs
new file mode 100644
index 0000000..0e15a69
--- /dev/null
+++ b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/ListGenericObjects.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectStormtrooper.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)
+ {
+ // TODO проверка позиции
+ if( position>= 0 && position < Count)
+ {
+ return _collection[position];
+ }
+ return null;
+ }
+ public int Insert(T obj)
+ {
+ // TODO проверка, что не превышено максимальное количество элементов
+ // TODO вставка в конец набора
+ if (Count <= _maxCount)
+ {
+ _collection.Add(obj);
+ return Count;
+ }
+ return -1;
+ }
+ public int Insert(T obj, int position)
+ {
+ // TODO проверка, что не превышено максимальное количество элементов
+ // TODO проверка позиции
+ // TODO вставка по позиции
+ if (Count < _maxCount && position>=0 && position < _maxCount)
+ {
+ _collection.Insert(position, obj);
+ return position;
+ }
+ return -1;
+ }
+ public T Remove(int position)
+ {
+ // TODO проверка позиции
+ // TODO удаление объекта из списка
+ T temp = _collection[position];
+ if(position>=0 && position < _maxCount)
+ {
+ _collection.RemoveAt(position);
+ return temp;
+ }
+ return null;
+ }
+
+}
+
diff --git a/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/MassiveGenericObjects.cs
index 85dc44d..2556922 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -40,7 +40,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects
_collection = Array.Empty();
}
- public T? Get(int position)
+ public T Get(int position)
{
// TODO проверка позиции
if (position >= _collection.Length || position < 0) return null;
diff --git a/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/StorageCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/StorageCollection.cs
new file mode 100644
index 0000000..0c51784
--- /dev/null
+++ b/ProjectStormtrooper/ProjectStormtrooper/CollectionGenericObjects/StorageCollection.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectStormtrooper.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)
+ {
+ // TODO проверка, что name не пустой и нет в словаре записи с таким ключом
+ // TODO Прописать логику для добавления
+ if(!(collectionType == CollectionType.None) && !_storages.ContainsKey(name)){
+ if(collectionType== CollectionType.List)
+ {
+ _storages.Add(name, new ListGenericObjects());
+ }
+ else if (collectionType == CollectionType.Massive)
+ {
+ _storages.Add(name, new MassiveGenericObjects());
+ }
+ }
+ }
+ ///
+ /// Удаление коллекции
+ ///
+ /// Название коллекции
+ public void DelCollection(string name)
+ {
+ // TODO Прописать логику для удаления коллекции
+ if (_storages.ContainsKey(name)) { _storages.Remove(name); }
+ }
+ ///
+ /// Доступ к коллекции
+ ///
+ /// Название коллекции
+ ///
+ public ICollectionGenericObjects? this[string name]
+ {
+ get
+ {
+ // TODO Продумать логику получения объекта
+ if (_storages.ContainsKey(name))
+ {
+ return _storages[name];
+ }
+ return null;
+ }
+ }
+}
+
diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.Designer.cs b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.Designer.cs
index 327c1b6..9dbb7dc 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.Designer.cs
+++ b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.Designer.cs
@@ -29,26 +29,34 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
+ panelCompanyTools = new Panel();
+ buttonCreateCompany = new Button();
+ buttonAddBaseStormtrooper = new Button();
+ buttonAddStormtrooper = new Button();
buttonRefresh = new Button();
+ maskedTextBoxPosition = new MaskedTextBox();
buttonGoToCheck = new Button();
buttonRemoveStormtrooper = new Button();
- maskedTextBoxPosition = new MaskedTextBox();
- buttonAddStormtrooper = new Button();
- buttonAddBaseStormtrooper = 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(buttonRemoveStormtrooper);
- groupBoxTools.Controls.Add(maskedTextBoxPosition);
- groupBoxTools.Controls.Add(buttonAddStormtrooper);
- groupBoxTools.Controls.Add(buttonAddBaseStormtrooper);
+ groupBoxTools.Controls.Add(panelCompanyTools);
+ groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(898, 0);
@@ -58,9 +66,55 @@
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
+ // panelCompanyTools
+ //
+ panelCompanyTools.Controls.Add(buttonCreateCompany);
+ panelCompanyTools.Controls.Add(buttonAddBaseStormtrooper);
+ panelCompanyTools.Controls.Add(buttonAddStormtrooper);
+ panelCompanyTools.Controls.Add(buttonRefresh);
+ panelCompanyTools.Controls.Add(maskedTextBoxPosition);
+ panelCompanyTools.Controls.Add(buttonGoToCheck);
+ panelCompanyTools.Controls.Add(buttonRemoveStormtrooper);
+ panelCompanyTools.Dock = DockStyle.Bottom;
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(3, 299);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(219, 357);
+ panelCompanyTools.TabIndex = 8;
+ //
+ // buttonCreateCompany
+ //
+ buttonCreateCompany.Location = new Point(3, 3);
+ buttonCreateCompany.Name = "buttonCreateCompany";
+ buttonCreateCompany.Size = new Size(213, 23);
+ buttonCreateCompany.TabIndex = 7;
+ buttonCreateCompany.Text = "Создать компанию";
+ buttonCreateCompany.UseVisualStyleBackColor = true;
+ buttonCreateCompany.Click += buttonCreateCompany_Click;
+ //
+ // buttonAddBaseStormtrooper
+ //
+ buttonAddBaseStormtrooper.Location = new Point(3, 90);
+ buttonAddBaseStormtrooper.Name = "buttonAddBaseStormtrooper";
+ buttonAddBaseStormtrooper.Size = new Size(213, 52);
+ buttonAddBaseStormtrooper.TabIndex = 1;
+ buttonAddBaseStormtrooper.Text = "Добавление базового бомбардировщика";
+ buttonAddBaseStormtrooper.UseVisualStyleBackColor = true;
+ buttonAddBaseStormtrooper.Click += buttonAddBaseStormtrooper_Click;
+ //
+ // buttonAddStormtrooper
+ //
+ buttonAddStormtrooper.Location = new Point(3, 32);
+ buttonAddStormtrooper.Name = "buttonAddStormtrooper";
+ buttonAddStormtrooper.Size = new Size(213, 52);
+ buttonAddStormtrooper.TabIndex = 2;
+ buttonAddStormtrooper.Text = "Добавление бомбардировщика";
+ buttonAddStormtrooper.UseVisualStyleBackColor = true;
+ buttonAddStormtrooper.Click += buttonAddStormtrooper_Click;
+ //
// buttonRefresh
//
- buttonRefresh.Location = new Point(6, 563);
+ buttonRefresh.Location = new Point(3, 293);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(213, 52);
buttonRefresh.TabIndex = 6;
@@ -68,9 +122,18 @@
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += buttonRefresh_Click;
//
+ // maskedTextBoxPosition
+ //
+ maskedTextBoxPosition.Location = new Point(3, 148);
+ maskedTextBoxPosition.Mask = "00";
+ maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ maskedTextBoxPosition.Size = new Size(213, 23);
+ maskedTextBoxPosition.TabIndex = 3;
+ maskedTextBoxPosition.ValidatingType = typeof(int);
+ //
// buttonGoToCheck
//
- buttonGoToCheck.Location = new Point(6, 378);
+ buttonGoToCheck.Location = new Point(3, 235);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(213, 52);
buttonGoToCheck.TabIndex = 5;
@@ -80,7 +143,7 @@
//
// buttonRemoveStormtrooper
//
- buttonRemoveStormtrooper.Location = new Point(6, 265);
+ buttonRemoveStormtrooper.Location = new Point(3, 177);
buttonRemoveStormtrooper.Name = "buttonRemoveStormtrooper";
buttonRemoveStormtrooper.Size = new Size(213, 52);
buttonRemoveStormtrooper.TabIndex = 4;
@@ -88,34 +151,87 @@
buttonRemoveStormtrooper.UseVisualStyleBackColor = true;
buttonRemoveStormtrooper.Click += buttonRemoveStormtrooper_Click;
//
- // maskedTextBoxPosition
+ // panelStorage
//
- maskedTextBoxPosition.Location = new Point(6, 226);
- maskedTextBoxPosition.Mask = "00";
- maskedTextBoxPosition.Name = "maskedTextBoxPosition";
- maskedTextBoxPosition.Size = new Size(213, 23);
- maskedTextBoxPosition.TabIndex = 3;
- maskedTextBoxPosition.ValidatingType = typeof(int);
+ 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(219, 242);
+ panelStorage.TabIndex = 7;
//
- // buttonAddStormtrooper
+ // buttonCollectionDel
//
- buttonAddStormtrooper.Location = new Point(6, 124);
- buttonAddStormtrooper.Name = "buttonAddStormtrooper";
- buttonAddStormtrooper.Size = new Size(213, 52);
- buttonAddStormtrooper.TabIndex = 2;
- buttonAddStormtrooper.Text = "Добавление бомбардировщика";
- buttonAddStormtrooper.UseVisualStyleBackColor = true;
- buttonAddStormtrooper.Click += buttonAddStormtrooper_Click;
+ buttonCollectionDel.Location = new Point(3, 211);
+ buttonCollectionDel.Name = "buttonCollectionDel";
+ buttonCollectionDel.Size = new Size(213, 23);
+ buttonCollectionDel.TabIndex = 6;
+ buttonCollectionDel.Text = "Удалить коллекцию";
+ buttonCollectionDel.UseVisualStyleBackColor = true;
+ buttonCollectionDel.Click += buttonCollectionDel_Click;
//
- // buttonAddBaseStormtrooper
+ // listBoxCollection
//
- buttonAddBaseStormtrooper.Location = new Point(6, 66);
- buttonAddBaseStormtrooper.Name = "buttonAddBaseStormtrooper";
- buttonAddBaseStormtrooper.Size = new Size(213, 52);
- buttonAddBaseStormtrooper.TabIndex = 1;
- buttonAddBaseStormtrooper.Text = "Добавление базового бомбардировщика";
- buttonAddBaseStormtrooper.UseVisualStyleBackColor = true;
- buttonAddBaseStormtrooper.Click += buttonAddBaseStormtrooper_Click;
+ listBoxCollection.FormattingEnabled = true;
+ listBoxCollection.ItemHeight = 15;
+ listBoxCollection.Location = new Point(3, 111);
+ listBoxCollection.Name = "listBoxCollection";
+ listBoxCollection.Size = new Size(213, 94);
+ listBoxCollection.TabIndex = 5;
+ //
+ // buttonCollectionAdd
+ //
+ buttonCollectionAdd.Location = new Point(3, 82);
+ buttonCollectionAdd.Name = "buttonCollectionAdd";
+ buttonCollectionAdd.Size = new Size(213, 23);
+ buttonCollectionAdd.TabIndex = 4;
+ buttonCollectionAdd.Text = "Добавить коллекцию";
+ buttonCollectionAdd.UseVisualStyleBackColor = true;
+ buttonCollectionAdd.Click += buttonCollectionAdd_Click;
+ //
+ // radioButtonList
+ //
+ radioButtonList.AutoSize = true;
+ radioButtonList.Location = new Point(106, 57);
+ 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(33, 57);
+ 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, 28);
+ textBoxCollectionName.Name = "textBoxCollectionName";
+ textBoxCollectionName.Size = new Size(213, 23);
+ textBoxCollectionName.TabIndex = 1;
+ //
+ // labelCollectionName
+ //
+ labelCollectionName.AutoSize = true;
+ labelCollectionName.Location = new Point(50, 10);
+ labelCollectionName.Name = "labelCollectionName";
+ labelCollectionName.Size = new Size(122, 15);
+ labelCollectionName.TabIndex = 0;
+ labelCollectionName.Text = "Название коллекции";
//
// comboBoxSelectorCompany
//
@@ -123,7 +239,7 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- comboBoxSelectorCompany.Location = new Point(6, 22);
+ comboBoxSelectorCompany.Location = new Point(6, 267);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(213, 23);
comboBoxSelectorCompany.TabIndex = 0;
@@ -148,7 +264,10 @@
Name = "FormStormtrooperCollection";
Text = "Коллекция бомбардировщиков";
groupBoxTools.ResumeLayout(false);
- groupBoxTools.PerformLayout();
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
+ panelStorage.ResumeLayout(false);
+ panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
@@ -164,5 +283,15 @@
private PictureBox pictureBox;
private Button buttonRefresh;
private Button buttonGoToCheck;
+ private Panel panelStorage;
+ private RadioButton radioButtonList;
+ private RadioButton radioButtonMassive;
+ private TextBox textBoxCollectionName;
+ private Label labelCollectionName;
+ private Button buttonCreateCompany;
+ private Button buttonCollectionDel;
+ private ListBox listBoxCollection;
+ private Button buttonCollectionAdd;
+ private Panel panelCompanyTools;
}
}
\ No newline at end of file
diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.cs
index 5be0f14..d4eaaed 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.cs
+++ b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooperCollection.cs
@@ -1,14 +1,5 @@
using ProjectStormtrooper.CollectionGenericObjects;
using ProjectStormtrooper.Drawnings;
-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 ProjectStormtrooper;
///
@@ -16,6 +7,11 @@ namespace ProjectStormtrooper;
///
public partial class FormStormtrooperCollection : Form
{
+ ///
+ /// Хранилище коллекций
+ ///
+ private readonly StorageCollection _storageCollection;
+
///
/// Компания
///
@@ -26,6 +22,7 @@ public partial class FormStormtrooperCollection : Form
public FormStormtrooperCollection()
{
InitializeComponent();
+ _storageCollection = new();
}
///
/// Выбор компании
@@ -34,12 +31,7 @@ public partial class FormStormtrooperCollection : Form
///
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
- switch (comboBoxSelectorCompany.Text)
- {
- case "Хранилище":
- _company = new StormtrooperSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
- break;
- }
+ panelCompanyTools.Enabled = true;
}
///
/// Создание объекта класса-перемещения
@@ -59,7 +51,7 @@ public partial class FormStormtrooperCollection : Form
drawningBaseStormtrooper = new DrawningBaseStormtrooper(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawingStormtrooper):
- drawningBaseStormtrooper = new DrawingStormtrooper(random.Next(100, 300), random.Next(1000, 3000),GetColor(random),GetColor(random),
+ drawningBaseStormtrooper = new DrawingStormtrooper(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:
@@ -121,7 +113,7 @@ public partial class FormStormtrooperCollection : Form
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
int tempSize = StormtrooperSharingService.getAmountOfObjects();
- if (_company-pos!=null)
+ if (_company - pos != null)
{
MessageBox.Show("Объект удалён");
pictureBox.Image = _company.Show();
@@ -143,9 +135,9 @@ public partial class FormStormtrooperCollection : Form
{
return;
}
- DrawningBaseStormtrooper? stormtrooper= null;
+ DrawningBaseStormtrooper? stormtrooper = null;
int counter = 100;
- while(stormtrooper == null)
+ while (stormtrooper == null)
{
stormtrooper = _company.GetRandomObject();
counter--;
@@ -178,5 +170,103 @@ public partial class FormStormtrooperCollection : 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)
+ {
+ // TODO прописать логику удаления элемента из коллекции
+ // нужно убедиться, что есть выбранная коллекция
+ // спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись
+ // удалить и обновить ListBox
+ 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();
+ }
+
+ ///
+ /// Создание компании
+ ///
+ ///
+ ///
+ 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 StormtrooperSharingService(pictureBox.Width, pictureBox.Height, collection);
+ break;
+ }
+ panelCompanyTools.Enabled = true;
+ 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);
+ }
+ }
+ }
}
+
+