diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/AbstractCompany.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/AbstractCompany.cs index 3387242..5bde8ce 100644 --- a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/AbstractCompany.cs +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/AbstractCompany.cs @@ -54,7 +54,7 @@ private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _ /// public static int operator +(AbstractCompany company, DrawningBoat boat) { - return company._collection?.Insert(boat) ?? 0; + return company._collection?.Insert(boat) ?? -1; } /// /// Перегрузка оператора удаления для класса @@ -84,6 +84,7 @@ private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _ Bitmap bitmap = new(_pictureWidth, _pictureHeight); Graphics graphics = Graphics.FromImage(bitmap); DrawBackgound(graphics); + SetObjectsPosition(); for (int i = 0; i < (_collection?.Count ?? 0); ++i) { diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatHarborService.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatHarborService.cs index b443156..bddbc58 100644 --- a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatHarborService.cs +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatHarborService.cs @@ -12,6 +12,7 @@ namespace ProjectCatamaran.CollectiongGenericObjects; /// public class BoatHarborService : AbstractCompany { + /// /// /// diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/CollectionType .cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/CollectionType .cs new file mode 100644 index 0000000..bd0ea82 --- /dev/null +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/CollectionType .cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectCatamaran.CollectiongGenericObjects; + +public enum CollectionType +{ + /// + /// Неопределено + /// + None = 0, + + /// + /// Массив + /// + Massive = 1, + + /// + /// Список + /// + List = 2 +} diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/ICollectionGenericObjects.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/ICollectionGenericObjects.cs index 4d4562e..a19a0fc 100644 --- a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/ICollectionGenericObjects.cs @@ -17,19 +17,16 @@ public interface ICollectionGenericObjects /// Количество объектов в коллекции /// int Count { get; } - /// /// Установка максимального количества элементов /// int SetMaxCount { set; } - /// /// Добавление объекта в коллекцию /// /// Добавляемый объект /// true - вставка прошла удачно, false - вставка не удалась int Insert(T obj); - /// /// Добавление объекта в коллекцию на конкретную позицию /// @@ -37,14 +34,12 @@ public interface ICollectionGenericObjects /// Позиция /// true - вставка прошла удачно, false - вставка не удалась int Insert(T obj, int position); - /// /// Удаление объекта из коллекции с конкретной позиции /// /// Позиция /// true - удаление прошло удачно, false - удаление не удалось T? Remove(int position); - /// /// Получение объекта по позиции /// diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/ListGenericObjects.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..9725f20 --- /dev/null +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/ListGenericObjects.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectCatamaran.CollectiongGenericObjects; + +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) + { + if (Count <= _maxCount) + { + _collection.Add(obj); + return Count; + } + return -1; + } + public int Insert(T obj, int position) + { + if (Count < _maxCount && position >= 0 && position < _maxCount) + { + _collection.Insert(position, obj); + return position; + } + return -1; + } + public T Remove(int position) + { + T temp = _collection[position]; + if (position >= 0 && position < _maxCount) + { + _collection.RemoveAt(position); + return temp; + } + return null; + } + +} diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/MassiveGenericObjects.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/MassiveGenericObjects.cs index 9a6f02b..bc4b918 100644 --- a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/MassiveGenericObjects.cs +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/MassiveGenericObjects.cs @@ -18,38 +18,43 @@ namespace ProjectCatamaran.CollectiongGenericObjects; /// private T?[] _collection; public int Count => _collection.Length; - public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } } + 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(); + _collection = Array.Empty(); } - - /// - /// проверка позиции - /// - /// - /// public T? Get(int position) { - + // проверка позиции if (position >= _collection.Length || position < 0) { return null; } return _collection[position]; } - - /// - /// вставка в свободное место набора - /// - /// - /// public int Insert(T obj) { + // вставка в свободное место набора int index = 0; while (index < _collection.Length) { @@ -62,15 +67,9 @@ namespace ProjectCatamaran.CollectiongGenericObjects; } return -1; } - - /// - /// проверка позиции - /// - /// - /// - /// public int Insert(T obj, int position) { + if (position >= _collection.Length || position < 0) { return -1; } @@ -100,15 +99,12 @@ namespace ProjectCatamaran.CollectiongGenericObjects; } return -1; } - - public T? Remove(int position) + public T Remove(int position) { if (position >= _collection.Length || position < 0) - { - return null; - } - T drawningBoat = _collection[position]; + { return null; } + T DrawningAircraft = _collection[position]; _collection[position] = null; - return drawningBoat; + return DrawningAircraft; } } diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/StorageCollection.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..7ec2f2d --- /dev/null +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/StorageCollection.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectCatamaran.CollectiongGenericObjects; + +/// +/// Класс-хранилище коллекций +/// +/// +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 (!(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) + { + 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/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs index 9e0b36c..e6fe517 100644 --- a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs +++ b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs @@ -29,6 +29,15 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + buttonCreateCompany = new Button(); + panelStorage = new Panel(); + radioButtonList = new RadioButton(); + radioButtonMassive = new RadioButton(); + buttonCollectionaDel = new Button(); + listBoxCollection = new ListBox(); + buttonCollectionaAdd = new Button(); + textBoxCollectionName = new TextBox(); + labelCollectionName = new Label(); buttonRefresh = new Button(); buttonGoToCheck = new Button(); buttonRemoveBoat = new Button(); @@ -37,18 +46,18 @@ buttonAddBoat = new Button(); comboBoxSelectorCompany = new ComboBox(); pictureBoxBoat = new PictureBox(); + panelCompanyTools = new Panel(); groupBoxTools.SuspendLayout(); + panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxBoat).BeginInit(); + panelCompanyTools.SuspendLayout(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGoToCheck); - groupBoxTools.Controls.Add(buttonRemoveBoat); - groupBoxTools.Controls.Add(maskedTextBoxPosition); - groupBoxTools.Controls.Add(buttonAddCatamaran); - groupBoxTools.Controls.Add(buttonAddBoat); + groupBoxTools.Controls.Add(panelCompanyTools); + groupBoxTools.Controls.Add(buttonCreateCompany); + groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Location = new Point(849, 0); @@ -58,12 +67,103 @@ groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // buttonCreateCompany + // + buttonCreateCompany.Location = new Point(16, 353); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(251, 29); + buttonCreateCompany.TabIndex = 7; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += ButtonCreateCompany_Click; + // + // panelStorage + // + panelStorage.Controls.Add(radioButtonList); + panelStorage.Controls.Add(radioButtonMassive); + panelStorage.Controls.Add(buttonCollectionaDel); + panelStorage.Controls.Add(listBoxCollection); + panelStorage.Controls.Add(buttonCollectionaAdd); + panelStorage.Controls.Add(textBoxCollectionName); + panelStorage.Controls.Add(labelCollectionName); + panelStorage.Dock = DockStyle.Top; + panelStorage.Location = new Point(3, 23); + panelStorage.Name = "panelStorage"; + panelStorage.Size = new Size(273, 276); + panelStorage.TabIndex = 7; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(158, 65); + radioButtonList.Name = "radioButtonList"; + radioButtonList.Size = new Size(80, 24); + radioButtonList.TabIndex = 9; + radioButtonList.TabStop = true; + radioButtonList.Text = "Список"; + radioButtonList.UseVisualStyleBackColor = true; + // + // radioButtonMassive + // + radioButtonMassive.AutoSize = true; + radioButtonMassive.Location = new Point(29, 65); + radioButtonMassive.Name = "radioButtonMassive"; + radioButtonMassive.Size = new Size(82, 24); + radioButtonMassive.TabIndex = 8; + radioButtonMassive.TabStop = true; + radioButtonMassive.Text = "Массив"; + radioButtonMassive.UseVisualStyleBackColor = true; + // + // buttonCollectionaDel + // + buttonCollectionaDel.Location = new Point(12, 240); + buttonCollectionaDel.Name = "buttonCollectionaDel"; + buttonCollectionaDel.Size = new Size(251, 29); + buttonCollectionaDel.TabIndex = 6; + buttonCollectionaDel.Text = "Удалить коллекцию"; + buttonCollectionaDel.UseVisualStyleBackColor = true; + buttonCollectionaDel.Click += ButtonCollectionDel_Click; + // + // listBoxCollection + // + listBoxCollection.ItemHeight = 20; + listBoxCollection.Location = new Point(3, 130); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(267, 104); + listBoxCollection.TabIndex = 7; + // + // buttonCollectionaAdd + // + buttonCollectionaAdd.Location = new Point(13, 95); + buttonCollectionaAdd.Name = "buttonCollectionaAdd"; + buttonCollectionaAdd.Size = new Size(251, 29); + buttonCollectionaAdd.TabIndex = 4; + buttonCollectionaAdd.Text = "Добавить коллекцию"; + buttonCollectionaAdd.UseVisualStyleBackColor = true; + buttonCollectionaAdd.Click += ButtonCollectionAdd_Click; + // + // textBoxCollectionName + // + textBoxCollectionName.Location = new Point(3, 32); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(267, 27); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(57, 9); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(158, 20); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции:"; + // // buttonRefresh // buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(16, 522); + buttonRefresh.Location = new Point(3, 181); buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(250, 51); + buttonRefresh.Size = new Size(267, 31); buttonRefresh.TabIndex = 6; buttonRefresh.Text = "Обновить"; buttonRefresh.UseVisualStyleBackColor = true; @@ -72,9 +172,9 @@ // buttonGoToCheck // buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(16, 408); + buttonGoToCheck.Location = new Point(4, 146); buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(250, 51); + buttonGoToCheck.Size = new Size(266, 29); buttonGoToCheck.TabIndex = 5; buttonGoToCheck.Text = "Передать на тесты"; buttonGoToCheck.UseVisualStyleBackColor = true; @@ -83,9 +183,9 @@ // buttonRemoveBoat // buttonRemoveBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemoveBoat.Location = new Point(16, 301); + buttonRemoveBoat.Location = new Point(3, 113); buttonRemoveBoat.Name = "buttonRemoveBoat"; - buttonRemoveBoat.Size = new Size(250, 51); + buttonRemoveBoat.Size = new Size(267, 27); buttonRemoveBoat.TabIndex = 4; buttonRemoveBoat.Text = "Удалить лодку"; buttonRemoveBoat.UseVisualStyleBackColor = true; @@ -94,19 +194,19 @@ // maskedTextBoxPosition // maskedTextBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - maskedTextBoxPosition.Location = new Point(16, 258); + maskedTextBoxPosition.Location = new Point(3, 80); maskedTextBoxPosition.Mask = "00"; maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - maskedTextBoxPosition.Size = new Size(250, 27); + maskedTextBoxPosition.Size = new Size(267, 27); maskedTextBoxPosition.TabIndex = 3; maskedTextBoxPosition.ValidatingType = typeof(int); // // buttonAddCatamaran // buttonAddCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddCatamaran.Location = new Point(16, 174); + buttonAddCatamaran.Location = new Point(3, 41); buttonAddCatamaran.Name = "buttonAddCatamaran"; - buttonAddCatamaran.Size = new Size(250, 51); + buttonAddCatamaran.Size = new Size(267, 33); buttonAddCatamaran.TabIndex = 2; buttonAddCatamaran.Text = "Добавление катамарана"; buttonAddCatamaran.UseVisualStyleBackColor = true; @@ -115,9 +215,9 @@ // buttonAddBoat // buttonAddBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddBoat.Location = new Point(16, 117); + buttonAddBoat.Location = new Point(3, 3); buttonAddBoat.Name = "buttonAddBoat"; - buttonAddBoat.Size = new Size(250, 51); + buttonAddBoat.Size = new Size(267, 32); buttonAddBoat.TabIndex = 1; buttonAddBoat.Text = "Добавление лодки"; buttonAddBoat.UseVisualStyleBackColor = true; @@ -129,7 +229,7 @@ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(16, 30); + comboBoxSelectorCompany.Location = new Point(17, 305); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(250, 28); comboBoxSelectorCompany.TabIndex = 0; @@ -144,6 +244,21 @@ pictureBoxBoat.TabIndex = 1; pictureBoxBoat.TabStop = false; // + // panelCompanyTools + // + panelCompanyTools.Controls.Add(buttonAddCatamaran); + panelCompanyTools.Controls.Add(buttonAddBoat); + panelCompanyTools.Controls.Add(maskedTextBoxPosition); + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(buttonRemoveBoat); + panelCompanyTools.Controls.Add(buttonGoToCheck); + panelCompanyTools.Dock = DockStyle.Bottom; + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 397); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(273, 229); + panelCompanyTools.TabIndex = 8; + // // FormBoatCollection // AutoScaleDimensions = new SizeF(8F, 20F); @@ -154,8 +269,11 @@ Name = "FormBoatCollection"; Text = "Коллекция лодок"; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); + panelStorage.ResumeLayout(false); + panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxBoat).EndInit(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); ResumeLayout(false); } @@ -170,5 +288,15 @@ private Button buttonRemoveBoat; private MaskedTextBox maskedTextBoxPosition; private PictureBox pictureBoxBoat; + private Panel panelStorage; + private Label labelCollectionName; + private TextBox textBoxCollectionName; + private Button buttonCollectionaAdd; + private Button buttonCreateCompany; + private Button buttonCollectionaDel; + private ListBox listBoxCollection; + private RadioButton radioButtonList; + private RadioButton radioButtonMassive; + private Panel panelCompanyTools; } } \ No newline at end of file diff --git a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs index e185b94..bef142a 100644 --- a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs +++ b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs @@ -17,6 +17,8 @@ namespace ProjectCatamaran; /// public partial class FormBoatCollection : Form { + private readonly StorageCollection _storageCollection; + /// /// Компания /// @@ -25,6 +27,7 @@ public partial class FormBoatCollection : Form public FormBoatCollection() { InitializeComponent(); + _storageCollection = new(); } /// @@ -34,13 +37,7 @@ public partial class FormBoatCollection : Form /// private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { - switch (comboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new BoatHarborService(pictureBoxBoat.Width, - pictureBoxBoat.Height, new MassiveGenericObjects()); - break; - } + panelCompanyTools.Enabled = false; } @@ -189,4 +186,100 @@ public partial class FormBoatCollection : Form pictureBoxBoat.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(); + + } + + /// + /// Создание компании + /// + /// + /// + 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 BoatHarborService(pictureBoxBoat.Width, pictureBoxBoat.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); + } + } + } }