diff --git a/ProjertTrain/ProjertTrain/CollectionGenericObjects/CollectionType.cs b/ProjertTrain/ProjertTrain/CollectionGenericObjects/CollectionType.cs new file mode 100644 index 0000000..e95c25f --- /dev/null +++ b/ProjertTrain/ProjertTrain/CollectionGenericObjects/CollectionType.cs @@ -0,0 +1,18 @@ +namespace ProjectTrain.CollectionGenericObjects +{ + public enum CollectionType + { + /// + /// Неопределено + /// + None = 0, + /// + /// Массив + /// + Massive = 1, + /// + /// Список + /// + List = 2 + } +} diff --git a/ProjertTrain/ProjertTrain/CollectionGenericObjects/ListGenericObjects.cs b/ProjertTrain/ProjertTrain/CollectionGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..d3aca01 --- /dev/null +++ b/ProjertTrain/ProjertTrain/CollectionGenericObjects/ListGenericObjects.cs @@ -0,0 +1,65 @@ +namespace ProjectTrain.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 >= Count || position < 0) return null; + return _collection[position]; + } + + public int Insert(T obj) + { + // TODO проверка, что не превышено максимальное количество элементов + // TODO вставка в конец набора + if (Count == _maxCount) return -1; + _collection.Add(obj); + return Count; + } + + public int Insert(T obj, int position) + { + // TODO проверка, что не превышено максимальное количество элементов + // TODO проверка позиции + // TODO вставка по позиции + if (Count == _maxCount) return -1; + if (position >= Count || position < 0) return -1; + _collection.Insert(position, obj); + return position; + + } + + public T Remove(int position) + { + // TODO проверка позиции + // TODO удаление объекта из списка + if (position >= Count || position < 0) return null; + T obj = _collection[position]; + _collection.RemoveAt(position); + return obj; + } + } +} diff --git a/ProjertTrain/ProjertTrain/CollectionGenericObjects/StorageCollection.cs b/ProjertTrain/ProjertTrain/CollectionGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..9323dee --- /dev/null +++ b/ProjertTrain/ProjertTrain/CollectionGenericObjects/StorageCollection.cs @@ -0,0 +1,73 @@ +namespace ProjectTrain.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 (_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) + { + // 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/ProjertTrain/ProjertTrain/CollectionGenericObjects/CruiserDockingService.cs b/ProjertTrain/ProjertTrain/CollectionGenericObjects/TrainDockingService.cs similarity index 100% rename from ProjertTrain/ProjertTrain/CollectionGenericObjects/CruiserDockingService.cs rename to ProjertTrain/ProjertTrain/CollectionGenericObjects/TrainDockingService.cs diff --git a/ProjertTrain/ProjertTrain/FormTrainsCollection.Designer.cs b/ProjertTrain/ProjertTrain/FormTrainsCollection.Designer.cs index d1d3194..ce9fd5b 100644 --- a/ProjertTrain/ProjertTrain/FormTrainsCollection.Designer.cs +++ b/ProjertTrain/ProjertTrain/FormTrainsCollection.Designer.cs @@ -29,93 +29,166 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); - maskedTextBoxPosision = new MaskedTextBox(); - buttonRefresh = new Button(); - buttonGetToTest = new Button(); - ButtonRemoveTrain = new Button(); - ButtonAddElectroTrain = new Button(); - ButtonAddTrain = new Button(); + buttonCreateCompany = new Button(); + panelStorage = new Panel(); + buttonCollectionDel = new Button(); + listBoxCollection = new ListBox(); + buttonCollecctionAdd = new Button(); + radioButtonList = new RadioButton(); + radioButtonMassive = new RadioButton(); + textBoxCollectionName = new TextBox(); + labelCollectionName = new Label(); comboBoxSelectorCompany = new ComboBox(); + panelCompanyTools = new Panel(); + ButtonAddTrain = new Button(); + ButtonAddElectroTrain = new Button(); + buttonRefresh = new Button(); + ButtonRemoveTrain = new Button(); + maskedTextBoxPosision = new MaskedTextBox(); + buttonGetToTest = new Button(); pictureBoxTrain = new PictureBox(); groupBoxTools.SuspendLayout(); + panelStorage.SuspendLayout(); + panelCompanyTools.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxTrain).BeginInit(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(maskedTextBoxPosision); - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGetToTest); - groupBoxTools.Controls.Add(ButtonRemoveTrain); - groupBoxTools.Controls.Add(ButtonAddElectroTrain); - groupBoxTools.Controls.Add(ButtonAddTrain); + groupBoxTools.Controls.Add(buttonCreateCompany); + groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); + groupBoxTools.Controls.Add(panelCompanyTools); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(596, 0); + groupBoxTools.Location = new Point(583, 0); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(222, 574); + groupBoxTools.Size = new Size(222, 653); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "инструменты"; // - // maskedTextBoxPosision + // buttonCreateCompany // - maskedTextBoxPosision.Location = new Point(20, 229); - maskedTextBoxPosision.Mask = "00"; - maskedTextBoxPosision.Name = "maskedTextBoxPosision"; - maskedTextBoxPosision.Size = new Size(186, 27); - maskedTextBoxPosision.TabIndex = 2; - maskedTextBoxPosision.ValidatingType = typeof(int); + buttonCreateCompany.Location = new Point(21, 345); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(186, 27); + buttonCreateCompany.TabIndex = 7; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += ButtonCreateCompany_Click; // - // buttonRefresh + // panelStorage // - buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonRefresh.Location = new Point(20, 479); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(186, 40); - buttonRefresh.TabIndex = 5; - buttonRefresh.Text = "обновить"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += ButtonRefresh_Click; + panelStorage.Controls.Add(buttonCollectionDel); + panelStorage.Controls.Add(listBoxCollection); + panelStorage.Controls.Add(buttonCollecctionAdd); + 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(216, 283); + panelStorage.TabIndex = 6; // - // buttonGetToTest + // buttonCollectionDel // - buttonGetToTest.Anchor = AnchorStyles.Right; - buttonGetToTest.Location = new Point(20, 366); - buttonGetToTest.Name = "buttonGetToTest"; - buttonGetToTest.Size = new Size(186, 40); - buttonGetToTest.TabIndex = 4; - buttonGetToTest.Text = "передать на тесты"; - buttonGetToTest.UseVisualStyleBackColor = true; - buttonGetToTest.Click += ButtonGetToTest_Click; + buttonCollectionDel.Location = new Point(17, 247); + buttonCollectionDel.Name = "buttonCollectionDel"; + buttonCollectionDel.Size = new Size(186, 27); + buttonCollectionDel.TabIndex = 6; + buttonCollectionDel.Text = "Удалить коллекцию"; + buttonCollectionDel.UseVisualStyleBackColor = true; + buttonCollectionDel.Click += ButtonCollectionDel_Click; // - // ButtonRemoveTrain + // listBoxCollection // - ButtonRemoveTrain.Anchor = AnchorStyles.Right; - ButtonRemoveTrain.Location = new Point(20, 271); - ButtonRemoveTrain.Name = "ButtonRemoveTrain"; - ButtonRemoveTrain.Size = new Size(186, 40); - ButtonRemoveTrain.TabIndex = 3; - ButtonRemoveTrain.Text = "удалить крейсер"; - ButtonRemoveTrain.UseVisualStyleBackColor = true; - ButtonRemoveTrain.Click += ButtonRemoveTrain_Click; + listBoxCollection.FormattingEnabled = true; + listBoxCollection.ItemHeight = 20; + listBoxCollection.Location = new Point(17, 137); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(186, 104); + listBoxCollection.TabIndex = 5; // - // ButtonAddElectroTrain + // buttonCollecctionAdd // - ButtonAddElectroTrain.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - ButtonAddElectroTrain.Location = new Point(20, 152); - ButtonAddElectroTrain.Name = "ButtonAddElectroTrain"; - ButtonAddElectroTrain.Size = new Size(186, 50); - ButtonAddElectroTrain.TabIndex = 2; - ButtonAddElectroTrain.Text = "добваление военного крейсера"; - ButtonAddElectroTrain.UseVisualStyleBackColor = true; - ButtonAddElectroTrain.Click += ButtonAddElectroTrain_Click; + buttonCollecctionAdd.Location = new Point(17, 104); + buttonCollecctionAdd.Name = "buttonCollecctionAdd"; + buttonCollecctionAdd.Size = new Size(186, 27); + buttonCollecctionAdd.TabIndex = 4; + buttonCollecctionAdd.Text = "Добавить коллекцию"; + buttonCollecctionAdd.UseVisualStyleBackColor = true; + buttonCollecctionAdd.Click += ButtonCollecctionAdd_Click; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(123, 75); + 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(17, 75); + 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(17, 32); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(186, 27); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(26, 9); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(155, 20); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции"; + // + // comboBoxSelectorCompany + // + comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxSelectorCompany.FormattingEnabled = true; + comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); + comboBoxSelectorCompany.Location = new Point(21, 311); + comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; + comboBoxSelectorCompany.Size = new Size(186, 28); + comboBoxSelectorCompany.TabIndex = 0; + comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1; + // + // panelCompanyTools + // + panelCompanyTools.Controls.Add(ButtonAddTrain); + panelCompanyTools.Controls.Add(ButtonAddElectroTrain); + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(ButtonRemoveTrain); + panelCompanyTools.Controls.Add(maskedTextBoxPosision); + panelCompanyTools.Controls.Add(buttonGetToTest); + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 379); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(216, 274); + panelCompanyTools.TabIndex = 8; // // ButtonAddTrain // ButtonAddTrain.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; ButtonAddTrain.BackgroundImageLayout = ImageLayout.Center; - ButtonAddTrain.Location = new Point(20, 106); + ButtonAddTrain.Location = new Point(18, 3); ButtonAddTrain.Name = "ButtonAddTrain"; ButtonAddTrain.Size = new Size(186, 40); ButtonAddTrain.TabIndex = 1; @@ -123,23 +196,65 @@ ButtonAddTrain.UseVisualStyleBackColor = true; ButtonAddTrain.Click += ButtonAddTrain_Click; // - // comboBoxSelectorCompany + // ButtonAddElectroTrain // - comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; - comboBoxSelectorCompany.FormattingEnabled = true; - comboBoxSelectorCompany.Items.AddRange(new object[] { "хранилище" }); - comboBoxSelectorCompany.Location = new Point(20, 26); - comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; - comboBoxSelectorCompany.Size = new Size(186, 28); - comboBoxSelectorCompany.TabIndex = 0; - comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1; + ButtonAddElectroTrain.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + ButtonAddElectroTrain.Location = new Point(18, 49); + ButtonAddElectroTrain.Name = "ButtonAddElectroTrain"; + ButtonAddElectroTrain.Size = new Size(186, 51); + ButtonAddElectroTrain.TabIndex = 2; + ButtonAddElectroTrain.Text = "добваление военного крейсера"; + ButtonAddElectroTrain.UseVisualStyleBackColor = true; + ButtonAddElectroTrain.Click += ButtonAddElectroTrain_Click; + // + // buttonRefresh + // + buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRefresh.Location = new Point(18, 227); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(186, 41); + buttonRefresh.TabIndex = 5; + buttonRefresh.Text = "обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; + // + // ButtonRemoveTrain + // + ButtonRemoveTrain.Anchor = AnchorStyles.Right; + ButtonRemoveTrain.Location = new Point(18, 138); + ButtonRemoveTrain.Name = "ButtonRemoveTrain"; + ButtonRemoveTrain.Size = new Size(186, 40); + ButtonRemoveTrain.TabIndex = 3; + ButtonRemoveTrain.Text = "удалить крейсер"; + ButtonRemoveTrain.UseVisualStyleBackColor = true; + ButtonRemoveTrain.Click += ButtonRemoveTrain_Click; + // + // maskedTextBoxPosision + // + maskedTextBoxPosision.Location = new Point(17, 105); + maskedTextBoxPosision.Mask = "00"; + maskedTextBoxPosision.Name = "maskedTextBoxPosision"; + maskedTextBoxPosision.Size = new Size(187, 27); + maskedTextBoxPosision.TabIndex = 2; + maskedTextBoxPosision.ValidatingType = typeof(int); + // + // buttonGetToTest + // + buttonGetToTest.Anchor = AnchorStyles.Right; + buttonGetToTest.Location = new Point(18, 184); + buttonGetToTest.Name = "buttonGetToTest"; + buttonGetToTest.Size = new Size(186, 40); + buttonGetToTest.TabIndex = 4; + buttonGetToTest.Text = "передать на тесты"; + buttonGetToTest.UseVisualStyleBackColor = true; + buttonGetToTest.Click += ButtonGetToTest_Click; // // pictureBoxTrain // pictureBoxTrain.Dock = DockStyle.Fill; pictureBoxTrain.Location = new Point(0, 0); pictureBoxTrain.Name = "pictureBoxTrain"; - pictureBoxTrain.Size = new Size(596, 574); + pictureBoxTrain.Size = new Size(583, 653); pictureBoxTrain.TabIndex = 1; pictureBoxTrain.TabStop = false; // @@ -147,13 +262,16 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(818, 574); + ClientSize = new Size(805, 653); Controls.Add(pictureBoxTrain); Controls.Add(groupBoxTools); Name = "FormTrainsCollection"; Text = "FormTrainsCollection"; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); + panelStorage.ResumeLayout(false); + panelStorage.PerformLayout(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxTrain).EndInit(); ResumeLayout(false); } @@ -169,5 +287,15 @@ private Button buttonGetToTest; private PictureBox pictureBoxTrain; private MaskedTextBox maskedTextBoxPosision; + private Panel panelStorage; + private TextBox textBoxCollectionName; + private Label labelCollectionName; + private ListBox listBoxCollection; + private Button buttonCollecctionAdd; + private RadioButton radioButtonList; + private RadioButton radioButtonMassive; + private Button buttonCreateCompany; + private Button buttonCollectionDel; + private Panel panelCompanyTools; } } \ No newline at end of file diff --git a/ProjertTrain/ProjertTrain/FormTrainsCollection.cs b/ProjertTrain/ProjertTrain/FormTrainsCollection.cs index a7c9c1d..2bc4aad 100644 --- a/ProjertTrain/ProjertTrain/FormTrainsCollection.cs +++ b/ProjertTrain/ProjertTrain/FormTrainsCollection.cs @@ -5,16 +5,23 @@ namespace ProjectTrain { public partial class FormTrainsCollection : Form { + /// + /// Хранилише коллекций + /// + private readonly StorageCollection _storageCollection; + /// /// Компания /// private AbstractCompany? _company = null; + /// /// Конструктор /// public FormTrainsCollection() { InitializeComponent(); + _storageCollection = new(); } /// @@ -24,13 +31,7 @@ namespace ProjectTrain /// private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e) { - switch (comboBoxSelectorCompany.Text) - { - case "хранилище": - _company = new TrainDockingService(pictureBoxTrain.Width, - pictureBoxTrain.Height, new MassiveGenericObjects()); - break; - } + panelCompanyTools.Enabled = false; } /// @@ -51,23 +52,22 @@ namespace ProjectTrain drawningTrain = new DrawningTrain(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); break; case nameof(DrawningElectroTrain): + // TODO вызов диалогового окна для выбора цвета drawningTrain = new DrawningElectroTrain(random.Next(100, 300), random.Next(1000, 3000), - GetColor(random), - GetColor(random), - Convert.ToBoolean(random.Next(0, 2)), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + GetColor(random), GetColor(random), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); break; default: return; } if (_company + drawningTrain != -1) { - MessageBox.Show("объект добавлен"); + MessageBox.Show("Объект добавлен"); pictureBoxTrain.Image = _company.Show(); } else { - MessageBox.Show("не удалось добавить объект"); + MessageBox.Show("Не удалось добавить объект"); } } @@ -164,6 +164,97 @@ namespace ProjectTrain pictureBoxTrain.Image = _company.Show(); } + /// + /// Добавление коллекции + /// + /// + /// + private void ButtonCollecctionAdd_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 TrainDockingService(pictureBoxTrain.Width, pictureBoxTrain.Height, collection); + break; + } + panelCompanyTools.Enabled = true; + + } + } }