From eb1240b42da9b5b87313c87a5a01f870d83c3791 Mon Sep 17 00:00:00 2001 From: Aidar Date: Fri, 3 May 2024 21:39:13 +0400 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 --- .../CollectionType.cs | 22 ++ .../ListGenericObjects.cs | 66 +++++ .../StorageCollection.cs | 86 ++++++ .../FormShipCollection.Designer.cs | 266 +++++++++++++----- .../ProjectLiner/FormShipCollection.cs | 109 ++++++- .../ProjectLiner/FormShipCollection.resx | 3 - 6 files changed, 472 insertions(+), 80 deletions(-) create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs new file mode 100644 index 0000000..e817799 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs @@ -0,0 +1,22 @@ +namespace ProjectLiner.CollectionGenericObjects; + +/// +/// Тип коллекции +/// +public enum CollectionType +{ + /// + /// Неопределено + /// + None = 0, + + /// + /// Массив + /// + Massive = 1, + + /// + /// Список + /// + List = 2 +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..be59236 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs @@ -0,0 +1,66 @@ +namespace ProjectLiner.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 < 0 || position > _collection.Count) + { + return null; + } + return _collection[position]; + } + + public int Insert(T obj) + { + return Insert(obj, _collection.Count); + } + + public int Insert(T obj, int position) + { + if (_maxCount == _collection.Count || position < 0 || position > _collection.Count) + { + return -1; + } + _collection.Insert(position, obj); + return _collection.Count; + } + + public T? Remove(int position) + { + if (position < 0 || position > _collection.Count) + { + return null; + } + T? obj = _collection[position]; + _collection.RemoveAt(position); + return obj; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..7df3d68 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs @@ -0,0 +1,86 @@ +namespace ProjectLiner.CollectionGenericObjects; + + +/// +/// Класс-хранилище коллекций +/// +/// +public class StorageCollection + where T : class +{ + /// + /// Словарь (хранилище) с коллекциями + /// + readonly Dictionary> _storage; + + /// + /// Возвращение списка названий коллекций + /// + public List Keys => _storage.Keys.ToList(); + + /// + /// Конструктор + /// + public StorageCollection() + { + _storage = new Dictionary>(); + } + + /// + /// Добавление коллекции в хранилище + /// + /// Название коллекции + /// тип коллекции + public void AddCollection(string name, CollectionType collectionType) + { + if (string.IsNullOrEmpty(name) || _storage.ContainsKey(name)) + { + return; + } + if (collectionType == CollectionType.None) + { + return; + } + if (collectionType == CollectionType.Massive) + { + _storage[name] = new MassiveGenericObjects(); + } + else if (collectionType == CollectionType.List) + { + _storage[name] = new ListGenericObjects(); + } + } + + /// + /// Удаление коллекции + /// + /// Название коллекции + public void DelCollection(string name) + { + if (name == null || !_storage.ContainsKey(name)) + { + return; + } + _storage.Remove(name); + } + + /// + /// Доступ к коллекции + /// + /// Название коллекции + /// + public ICollectionGenericObjects? this[string name] + { + get + { + if (_storage.ContainsKey(name)) + { + return _storage[name]; + } + else + { + return null; + } + } + } +} diff --git a/ProjectLiner/ProjectLiner/FormShipCollection.Designer.cs b/ProjectLiner/ProjectLiner/FormShipCollection.Designer.cs index 05c1501..643059e 100644 --- a/ProjectLiner/ProjectLiner/FormShipCollection.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormShipCollection.Designer.cs @@ -1,4 +1,8 @@ -namespace ProjectLiner +using static System.Net.Mime.MediaTypeNames; +using System.Windows.Forms; +using System.Xml.Linq; + +namespace ProjectLiner { partial class FormShipCollection { @@ -29,53 +33,103 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + panelCompanyTools = new Panel(); + buttonAddShip = new Button(); + buttonAddLiner = new Button(); buttonRefresh = new Button(); + maskedTextBoxPosition = new MaskedTextBox(); buttonGoToCheck = new Button(); buttonRemoveShip = new Button(); - maskedTextBoxPosition = new MaskedTextBox(); - buttonAddLiner = new Button(); - buttonAddShip = new Button(); - ComboBoxSelectorCompany = new ComboBox(); + 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(); - colorDialog1 = new ColorDialog(); groupBoxTools.SuspendLayout(); + panelCompanyTools.SuspendLayout(); + panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGoToCheck); - groupBoxTools.Controls.Add(buttonRemoveShip); - groupBoxTools.Controls.Add(maskedTextBoxPosition); - groupBoxTools.Controls.Add(buttonAddLiner); - groupBoxTools.Controls.Add(buttonAddShip); - groupBoxTools.Controls.Add(ComboBoxSelectorCompany); + groupBoxTools.Controls.Add(panelCompanyTools); + groupBoxTools.Controls.Add(buttonCreateCompany); + groupBoxTools.Controls.Add(panelStorage); + groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(1006, 0); + groupBoxTools.Location = new Point(793, 0); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(178, 561); + groupBoxTools.Size = new Size(144, 571); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // panelCompanyTools + // + panelCompanyTools.Controls.Add(buttonAddShip); + panelCompanyTools.Controls.Add(buttonAddLiner); + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(maskedTextBoxPosition); + panelCompanyTools.Controls.Add(buttonGoToCheck); + panelCompanyTools.Controls.Add(buttonRemoveShip); + panelCompanyTools.Dock = DockStyle.Bottom; + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 321); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(138, 247); + panelCompanyTools.TabIndex = 10; + // + // buttonAddLiner + // + buttonAddLiner.Location = new Point(3, 51); + buttonAddLiner.Name = "buttonAddLiner"; + buttonAddLiner.Size = new Size(126, 44); + buttonAddLiner.TabIndex = 2; + buttonAddLiner.Text = "Добавление лайнера"; + buttonAddLiner.UseVisualStyleBackColor = true; + buttonAddLiner.Click += ButtonAddLiner_Click; + // + // buttonAddShip + // + buttonAddShip.Location = new Point(4, 3); + buttonAddShip.Name = "buttonAddShip"; + buttonAddShip.Size = new Size(126, 42); + buttonAddShip.TabIndex = 1; + buttonAddShip.Text = "Добавление корабля"; + buttonAddShip.UseVisualStyleBackColor = true; + buttonAddShip.Click += ButtonAddShip_Click; + // // buttonRefresh // - buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(0, 302); + buttonRefresh.Location = new Point(3, 202); buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(178, 40); + buttonRefresh.Size = new Size(126, 42); buttonRefresh.TabIndex = 6; buttonRefresh.Text = "Обновить"; buttonRefresh.UseVisualStyleBackColor = true; buttonRefresh.Click += ButtonRefresh_Click; // + // maskedTextBoxPosition + // + maskedTextBoxPosition.Location = new Point(4, 101); + maskedTextBoxPosition.Mask = "00"; + maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + maskedTextBoxPosition.Size = new Size(126, 23); + maskedTextBoxPosition.TabIndex = 3; + maskedTextBoxPosition.ValidatingType = typeof(int); + // // buttonGoToCheck // - buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(0, 256); + buttonGoToCheck.Location = new Point(4, 166); buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(178, 40); + buttonGoToCheck.Size = new Size(126, 30); buttonGoToCheck.TabIndex = 5; buttonGoToCheck.Text = "Передать на тесты"; buttonGoToCheck.UseVisualStyleBackColor = true; @@ -83,64 +137,126 @@ // // buttonRemoveShip // - buttonRemoveShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemoveShip.Location = new Point(0, 191); + buttonRemoveShip.Location = new Point(4, 130); buttonRemoveShip.Name = "buttonRemoveShip"; - buttonRemoveShip.Size = new Size(178, 40); + buttonRemoveShip.Size = new Size(126, 30); buttonRemoveShip.TabIndex = 4; - buttonRemoveShip.Text = "Удаление корабля"; + buttonRemoveShip.Text = "Удалить корабль"; buttonRemoveShip.UseVisualStyleBackColor = true; buttonRemoveShip.Click += ButtonRemoveShip_Click; // - // maskedTextBoxPosition + // buttonCreateCompany // - maskedTextBoxPosition.Location = new Point(0, 162); - maskedTextBoxPosition.Mask = "00"; - maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - maskedTextBoxPosition.Size = new Size(178, 23); - maskedTextBoxPosition.TabIndex = 3; - maskedTextBoxPosition.ValidatingType = typeof(int); + buttonCreateCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonCreateCompany.Location = new Point(7, 285); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(126, 30); + buttonCreateCompany.TabIndex = 9; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += ButtonCreateCompany_Click; // - // buttonAddLiner + // panelStorage // - buttonAddLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddLiner.Location = new Point(0, 97); - buttonAddLiner.Name = "buttonAddLiner"; - buttonAddLiner.Size = new Size(178, 40); - buttonAddLiner.TabIndex = 2; - buttonAddLiner.Text = "Добавление лайнера"; - buttonAddLiner.UseVisualStyleBackColor = true; - buttonAddLiner.Click += buttonAddLiner_Click; + 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(138, 231); + panelStorage.TabIndex = 7; // - // buttonAddShip + // buttonCollectionDel // - buttonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddShip.Location = new Point(0, 51); - buttonAddShip.Name = "buttonAddShip"; - buttonAddShip.Size = new Size(178, 40); - buttonAddShip.TabIndex = 1; - buttonAddShip.Text = "Добавление корабля"; - buttonAddShip.UseVisualStyleBackColor = true; - buttonAddShip.Click += buttonAddShip_Click; + buttonCollectionDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonCollectionDel.Location = new Point(3, 196); + buttonCollectionDel.Name = "buttonCollectionDel"; + buttonCollectionDel.Size = new Size(126, 30); + buttonCollectionDel.TabIndex = 8; + buttonCollectionDel.Text = "Удалить коллекцию"; + buttonCollectionDel.UseVisualStyleBackColor = true; + buttonCollectionDel.Click += ButtonCollectionDel_Click; // - // ComboBoxSelectorCompany + // listBoxCollection // - ComboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - ComboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; - ComboBoxSelectorCompany.FormattingEnabled = true; - ComboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - ComboBoxSelectorCompany.Location = new Point(0, 22); - ComboBoxSelectorCompany.Name = "ComboBoxSelectorCompany"; - ComboBoxSelectorCompany.Size = new Size(178, 23); - ComboBoxSelectorCompany.TabIndex = 0; - ComboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; + listBoxCollection.FormattingEnabled = true; + listBoxCollection.ItemHeight = 15; + listBoxCollection.Location = new Point(3, 126); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(126, 64); + listBoxCollection.TabIndex = 5; + // + // buttonCollectionAdd + // + buttonCollectionAdd.Location = new Point(4, 81); + buttonCollectionAdd.Name = "buttonCollectionAdd"; + buttonCollectionAdd.Size = new Size(125, 39); + buttonCollectionAdd.TabIndex = 4; + buttonCollectionAdd.Text = "Добавить коллекцию"; + buttonCollectionAdd.UseVisualStyleBackColor = true; + buttonCollectionAdd.Click += ButtonCollectionAdd_Click; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(69, 56); + 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(4, 56); + 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, 27); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(126, 23); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(4, 9); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(125, 15); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции:"; + // + // 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, 256); + comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; + comboBoxSelectorCompany.Size = new Size(126, 23); + comboBoxSelectorCompany.TabIndex = 0; + comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; // // pictureBox // pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 0); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(1006, 561); + pictureBox.Size = new Size(793, 571); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // @@ -148,13 +264,16 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1184, 561); + ClientSize = new Size(937, 571); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Name = "FormShipCollection"; - Text = "Коллекция кораблей"; + Text = "Коллекция самолётов"; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); + panelStorage.ResumeLayout(false); + panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); ResumeLayout(false); } @@ -162,14 +281,23 @@ #endregion private GroupBox groupBoxTools; - private ComboBox ComboBoxSelectorCompany; - private Button buttonAddLiner; + private ComboBox comboBoxSelectorCompany; private Button buttonAddShip; - private Button buttonRefresh; - private Button buttonGoToCheck; + private Button buttonAddLiner; private Button buttonRemoveShip; private MaskedTextBox maskedTextBoxPosition; private PictureBox pictureBox; - private ColorDialog colorDialog1; + private Button buttonRefresh; + private Button buttonGoToCheck; + private Panel panelStorage; + private Label labelCollectionName; + private RadioButton radioButtonMassive; + private TextBox textBoxCollectionName; + private Button buttonCollectionAdd; + private RadioButton radioButtonList; + private ListBox listBoxCollection; + private Button buttonCollectionDel; + private Button buttonCreateCompany; + private Panel panelCompanyTools; } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormShipCollection.cs b/ProjectLiner/ProjectLiner/FormShipCollection.cs index 5e2979a..10beb6a 100644 --- a/ProjectLiner/ProjectLiner/FormShipCollection.cs +++ b/ProjectLiner/ProjectLiner/FormShipCollection.cs @@ -8,6 +8,11 @@ namespace ProjectLiner; /// public partial class FormShipCollection : Form { + /// + /// Хранилише коллекций + /// + private readonly StorageCollection _storageCollection; + /// /// Компания /// @@ -19,6 +24,7 @@ public partial class FormShipCollection : Form public FormShipCollection() { InitializeComponent(); + _storageCollection = new(); } /// @@ -28,12 +34,7 @@ public partial class FormShipCollection : Form /// private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { - switch (ComboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new ShipSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); - break; - } + panelCompanyTools.Enabled = false; } /// @@ -41,14 +42,14 @@ public partial class FormShipCollection : Form /// /// /// - private void buttonAddShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningShip)); + private void ButtonAddShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningShip)); /// /// Добавление лайнера /// /// /// - private void buttonAddLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner)); + private void ButtonAddLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner)); /// /// Создание объекта класса-перемещения @@ -176,4 +177,96 @@ public partial class FormShipCollection : 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); + RefreshListBoxItems(); + } + + /// + /// Удаление коллекции + /// + /// + /// + private void ButtonCollectionDel_Click(object sender, EventArgs e) + { + if (listBoxCollection.SelectedIndex < 0) + { + MessageBox.Show("Сначала выберите коллекцию"); + return; + } + if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + _storageCollection.DelCollection(listBoxCollection.SelectedItem?.ToString() ?? string.Empty); + RefreshListBoxItems(); + } + + + /// + /// Обновление списка в listBoxCollection + /// + private void RefreshListBoxItems() + { + 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 ShipSharingService(pictureBox.Width, pictureBox.Height, collection); + break; + } + panelCompanyTools.Enabled = true; + RefreshListBoxItems(); + } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormShipCollection.resx b/ProjectLiner/ProjectLiner/FormShipCollection.resx index 818dfae..af32865 100644 --- a/ProjectLiner/ProjectLiner/FormShipCollection.resx +++ b/ProjectLiner/ProjectLiner/FormShipCollection.resx @@ -117,7 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file