Лабораторная работа 4

This commit is contained in:
Almaz 2024-04-15 22:01:02 +04:00
parent 1aa2952a84
commit cabdb41342
8 changed files with 425 additions and 61 deletions

View File

@ -62,9 +62,9 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param>
/// <param name="cruiser">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningCruiser cruiser)
public static bool operator +(AbstractCompany company, DrawningCruiser cruiser)
{
return company._collection.Insert(cruiser);
return company._collection?.Insert(cruiser) ?? false;
}
/// <summary>
@ -73,9 +73,9 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static DrawningCruiser? operator -(AbstractCompany company, int position)
public static bool operator -(AbstractCompany company, int position)
{
return company._collection.Remove(position);
return company._collection?.Remove(position) ?? false;
}
/// <summary>

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCruiser.CollectionGenericObjects;
public enum CollectionType
{
/// <summary>
/// Неопределено
/// </summary>
None = 0,
/// <summary>
/// Массив
/// </summary>
Massive = 1,
/// <summary>
/// Список
/// </summary>
List = 2
}

View File

@ -27,7 +27,7 @@ public interface ICollectionGenericObjects<T>
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
bool Insert(T obj);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
@ -35,14 +35,14 @@ public interface ICollectionGenericObjects<T>
/// <param name="obj">Добавляемый объект</param>
/// <param name="position">Позиция</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, int position);
bool Insert(T obj, int position);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
/// </summary>
/// <param name="position">Позиция</param>
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
T? Remove(int position);
bool Remove(int position);
/// <summary>
/// Получение объекта по позиции

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCruiser.CollectionGenericObjects;
/// <summary>
/// Параметризованный набор объектов
/// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
where T : class
{
/// <summary>
/// Список объектов, которые храним
/// </summary>
private readonly List<T?> _collection;
/// <summary>
/// Максимально допустимое число объектов в списке
/// </summary>
private int _maxCount;
public int Count => _collection.Count;
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
/// <summary>
/// Конструктор
/// </summary>
public ListGenericObjects()
{
_collection = new();
}
public T? Get(int position)
{
// TODO проверка позиции
if (!_collection.Any()) { return null; }
if (_collection.Count <= position || position < 0 || position >= _maxCount) { return null; }
return _collection[position];
}
public bool Insert(T obj)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO вставка в конец набора
if (_collection.Count >= _maxCount) return false;
_collection.Add(obj);
return true;
}
public bool Insert(T obj, int position)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO проверка позиции
// TODO вставка по позиции
if (_collection.Count >= _maxCount || _collection[position] == null || position < 0) { return false; }
_collection.Insert(position, obj);
return true;
}
public bool Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из списка
if (_collection[position] == null)
{
return false;
}
_collection.RemoveAt(position);
return true;
}
}

View File

@ -52,48 +52,46 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return _collection[position];
}
public int Insert(T obj)
public bool Insert(T obj)
{
// TODO вставка в свободное место набора
for (int i = 0; i < Count; i++)
{
if (InsertingElementCollection(i, obj)) return i;
if (InsertingElementCollection(i, obj)) return true;
}
return -1;
return false;
}
public int Insert(T obj, int position)
public bool Insert(T obj, int position)
{
// TODO проверка позиции
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
// ищется свободное место после этой позиции и идет вставка туда
// если нет после, ищем до
// TODO вставка
if (InsertingElementCollection(position, obj)) return position;
if (InsertingElementCollection(position, obj)) return true;
for (int i = position + 1; i < Count; i++)
{
if (InsertingElementCollection(i, obj)) return position;
if (InsertingElementCollection(i, obj)) return true;
}
for (int i = position - 1; i >= 0; i--)
{
if (InsertingElementCollection(i, obj)) return position;
if (InsertingElementCollection(i, obj)) return true;
}
return -1;
return false;
}
public T? Remove(int position)
public bool Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из массива, присвоив элементу массива значение null
if (_collection[position] == null) return null;
T? temp = _collection[position];
if (_collection[position] == null) return false;
_collection[position] = null;
return temp;
return true;
}
private bool InsertingElementCollection(int index, T obj)

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCruiser.CollectionGenericObjects;
/// <summary>
/// Класс-хранилище коллекций
/// </summary>
/// <typeparam name="T"></typeparam>
public class StorageCollection<T>
where T : class
{
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => _storages.Keys.ToList();
/// <summary>
/// Конструктор
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
}
/// <summary>
/// Добавление коллекции в хранилище
/// </summary>
/// <param name="name">Название коллекции</param>
/// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
{
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
// TODO Прописать логику для добавления
if (name.Length <= 0 || _storages.ContainsKey(name))
{
return;
}
switch (collectionType)
{
case CollectionType.List:
_storages.Add(name, new ListGenericObjects<T>());
break;
case CollectionType.Massive:
_storages.Add(name, new MassiveGenericObjects<T>());
break;
default:
return;
}
}
/// <summary>
/// Удаление коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
{
// TODO Прописать логику для удаления коллекции
if (!_storages.ContainsKey(name)) { return; }
_storages.Remove(name);
}
/// <summary>
/// Доступ к коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
{
get
{
// TODO Продумать логику получения объекта
if (!_storages.ContainsKey(name)) { return null; }
return _storages[name];
}
}
}

View File

@ -29,6 +29,15 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
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();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonRemoveCruiser = new Button();
@ -37,33 +46,124 @@
buttonAddCruiser = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
panelCompanyTools = new Panel();
groupBoxTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
panelCompanyTools.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGoToCheck);
groupBoxTools.Controls.Add(buttonRemoveCruiser);
groupBoxTools.Controls.Add(maskedTextBoxPosition);
groupBoxTools.Controls.Add(buttonAddMilitaryCruiser);
groupBoxTools.Controls.Add(buttonAddCruiser);
groupBoxTools.Controls.Add(panelCompanyTools);
groupBoxTools.Controls.Add(buttonCreateCompany);
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(821, 0);
groupBoxTools.Location = new Point(890, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(250, 602);
groupBoxTools.Size = new Size(250, 728);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(12, 396);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(232, 29);
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, 23);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(244, 333);
panelStorage.TabIndex = 7;
//
// buttonCollectionDel
//
buttonCollectionDel.Location = new Point(9, 296);
buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(226, 29);
buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true;
buttonCollectionDel.Click += ButtonCollectionDel_Click;
//
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.Location = new Point(9, 186);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(226, 104);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Location = new Point(9, 144);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(226, 29);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
//
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(140, 103);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(80, 24);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
radioButtonList.UseVisualStyleBackColor = true;
//
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(22, 103);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(82, 24);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
radioButtonMassive.UseVisualStyleBackColor = true;
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(9, 51);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(226, 27);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(41, 10);
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(6, 446);
buttonRefresh.Location = new Point(9, 234);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(232, 40);
buttonRefresh.Size = new Size(226, 40);
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(6, 363);
buttonGoToCheck.Location = new Point(9, 188);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(232, 40);
buttonGoToCheck.Size = new Size(226, 40);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать не тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
@ -83,9 +183,9 @@
// buttonRemoveCruiser
//
buttonRemoveCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveCruiser.Location = new Point(6, 267);
buttonRemoveCruiser.Location = new Point(9, 142);
buttonRemoveCruiser.Name = "buttonRemoveCruiser";
buttonRemoveCruiser.Size = new Size(232, 40);
buttonRemoveCruiser.Size = new Size(226, 40);
buttonRemoveCruiser.TabIndex = 4;
buttonRemoveCruiser.Text = "Удаление крейсера";
buttonRemoveCruiser.UseVisualStyleBackColor = true;
@ -93,7 +193,7 @@
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Location = new Point(6, 234);
maskedTextBoxPosition.Location = new Point(9, 109);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(232, 27);
@ -103,9 +203,9 @@
// buttonAddMilitaryCruiser
//
buttonAddMilitaryCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddMilitaryCruiser.Location = new Point(6, 142);
buttonAddMilitaryCruiser.Location = new Point(9, 49);
buttonAddMilitaryCruiser.Name = "buttonAddMilitaryCruiser";
buttonAddMilitaryCruiser.Size = new Size(232, 54);
buttonAddMilitaryCruiser.Size = new Size(226, 54);
buttonAddMilitaryCruiser.TabIndex = 2;
buttonAddMilitaryCruiser.Text = "Добавление военного крейсера";
buttonAddMilitaryCruiser.UseVisualStyleBackColor = true;
@ -114,9 +214,9 @@
// buttonAddCruiser
//
buttonAddCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddCruiser.Location = new Point(6, 96);
buttonAddCruiser.Location = new Point(9, 3);
buttonAddCruiser.Name = "buttonAddCruiser";
buttonAddCruiser.Size = new Size(232, 40);
buttonAddCruiser.Size = new Size(226, 40);
buttonAddCruiser.TabIndex = 1;
buttonAddCruiser.Text = "Добавление крейсера";
buttonAddCruiser.UseVisualStyleBackColor = true;
@ -128,7 +228,7 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(6, 26);
comboBoxSelectorCompany.Location = new Point(12, 362);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(232, 28);
comboBoxSelectorCompany.TabIndex = 0;
@ -139,22 +239,40 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(821, 602);
pictureBox.Size = new Size(890, 728);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddCruiser);
panelCompanyTools.Controls.Add(buttonAddMilitaryCruiser);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonRemoveCruiser);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 431);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(244, 294);
panelCompanyTools.TabIndex = 9;
//
// FormCruiserCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1071, 602);
ClientSize = new Size(1140, 728);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormCruiserCollection";
Text = "Коллекция Крейсеров";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
ResumeLayout(false);
}
@ -169,5 +287,15 @@
private PictureBox pictureBox;
private Button buttonRefresh;
private Button buttonGoToCheck;
private Panel panelStorage;
private RadioButton radioButtonMassive;
private TextBox textBoxCollectionName;
private Label labelCollectionName;
private Button buttonCreateCompany;
private Button buttonCollectionDel;
private ListBox listBoxCollection;
private Button buttonCollectionAdd;
private RadioButton radioButtonList;
private Panel panelCompanyTools;
}
}

View File

@ -14,6 +14,7 @@ namespace ProjectCruiser;
public partial class FormCruiserCollection : Form
{
private readonly StorageCollection<DrawningCruiser> _storageCollection;
/// <summary>
/// Компания
@ -24,16 +25,12 @@ public partial class FormCruiserCollection : Form
public FormCruiserCollection()
{
InitializeComponent();
_storageCollection = new();
}
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new CruiserSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningCruiser>());
break;
}
panelCompanyTools.Enabled = true;
}
@ -45,21 +42,21 @@ public partial class FormCruiserCollection : Form
return;
}
Random random = new();
DrawningCruiser drawningCruiser;
Random random = new();
switch (type)
{
case nameof(DrawningCruiser):
drawningCruiser = new DrawningCruiser(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
drawningCruiser = new DrawningCruiser(random.Next(100, 300), random.Next(1000, 3000), SetColor(random));
break;
case nameof(DrawningMilitaryCruiser):
drawningCruiser = new DrawningMilitaryCruiser(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)),
SetColor(random),
SetColor(random),
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)));
@ -69,7 +66,7 @@ public partial class FormCruiserCollection : Form
default:
return;
}
if (_company + drawningCruiser != -1)
if (_company + drawningCruiser)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -85,7 +82,7 @@ public partial class FormCruiserCollection : Form
/// </summary>
/// <param name="random">Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
private static Color SetColor(Random random)
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
@ -103,18 +100,17 @@ public partial class FormCruiserCollection : Form
private void ButtonRemoveCruiser_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
if (_company == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
{
return;
}
if (MessageBox.Show("Удалить объект", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; }
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_company - pos is DrawningCruiser)
if (_company - pos)
{
MessageBox.Show("Объект удален");
pictureBox.Image = _company.Show();
@ -162,7 +158,76 @@ public partial class FormCruiserCollection : Form
{
return;
}
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.SelectedItem == null || listBoxCollection.SelectedIndex < 0)
{
MessageBox.Show("Коллекция для удаления не выбрана");
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<DrawningCruiser>? collection =
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
if (collection == null)
{
MessageBox.Show("Коллекция не проинициализирована");
return;
}
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new CruiserSharingService(pictureBox.Width, pictureBox.Height, collection);
break;
}
panelCompanyTools.Enabled = true;
RerfreshListBoxItems();
}
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);
}
}
}
}