diff --git a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AbstractCompany.cs b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AbstractCompany.cs index 5349f37..0c58f0a 100644 --- a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AbstractCompany.cs @@ -1,6 +1,6 @@ using ProjectAirbus.Drawnings; -namespace ProjectMotorboat.CollectionGenericObjects; +namespace ProjectAirbus.CollectionGenericObjects; /// /// Абстракция компании, хранящий коллекцию автомобилей diff --git a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AerodromService.cs b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AerodromService.cs index b89407b..4e8a603 100644 --- a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AerodromService.cs +++ b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/AerodromService.cs @@ -1,6 +1,6 @@ using ProjectAirbus.CollectionGenericObjects; using ProjectAirbus.Drawnings; -using ProjectMotorboat.CollectionGenericObjects; +using ProjectAirbus.CollectionGenericObjects; namespace ProjectAirbus.CollectionGenericObjects; diff --git a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/CollectionType.cs b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/CollectionType.cs new file mode 100644 index 0000000..89090a1 --- /dev/null +++ b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/CollectionType.cs @@ -0,0 +1,21 @@ +namespace ProjectAirbus.CollectionGenericObjects; + +public enum CollectionType +{ + /// + /// Неопределено + /// + None = 0, + + /// + /// Массив + /// + Massive = 1, + + /// + /// Список + /// + List = 2 + + +} diff --git a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/ICollectionGenericObjects.cs index eaf98c0..4dffeec 100644 --- a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ProjectMotorboat.CollectionGenericObjects; +namespace ProjectAirbus.CollectionGenericObjects; public interface ICollectionGenericObjects diff --git a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/ListGenericObjects.cs b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..bae84d7 --- /dev/null +++ b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/ListGenericObjects.cs @@ -0,0 +1,70 @@ +using ProjectAirbus.CollectionGenericObjects; + +namespace ProjectAirBus.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 + 1 > _maxCount) return -1; + _collection.Add(obj); + return Count; + } + + public int Insert(T obj, int position) + { + // TODO проверка, что не превышено максимальное количество элементов + // TODO проверка позиции + // TODO вставка по позиции + if (Count + 1 > _maxCount) return -1; + if (position < 0 || position > Count) return -1; + _collection.Insert(position, obj); + return 1; + } + + public T? Remove(int position) + { + // TODO проверка позиции + // TODO удаление объекта из списка + if (position < 0 || position > Count) return null; + T? pos = _collection[position]; + _collection.RemoveAt(position); + return pos; + } +} diff --git a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/MassiveGenericObjects.cs index d80b1b2..1e6503f 100644 --- a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/MassiveGenericObjects.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ProjectMotorboat.CollectionGenericObjects; +namespace ProjectAirbus.CollectionGenericObjects; internal class MassiveGenericObjects : ICollectionGenericObjects where T : class diff --git a/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/StorageCollection.cs b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..70f8695 --- /dev/null +++ b/ProjectAirbus/ProjectAirbus/CollectionGenericObjects/StorageCollection.cs @@ -0,0 +1,82 @@ + + +using ProjectAirbus.CollectionGenericObjects; + + +namespace ProjectAirBus.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 (name == null || _storages.ContainsKey(name)) { return; } + switch (collectionType) + + { + case CollectionType.None: + return; + case CollectionType.Massive: + _storages[name] = new MassiveGenericObjects(); + return; + case CollectionType.List: + _storages[name] = new ListGenericObjects(); + return; + } + } + + /// + /// Удаление коллекции + /// + /// Название коллекции + public void DelCollection(string name) + { + // TODO Прописать логику для удаления коллекции + if (_storages.ContainsKey(name)) + _storages.Remove(name); + } + + /// + /// Доступ к коллекции + /// + /// Название коллекции + /// + public ICollectionGenericObjects? this[string name] + { + get + { + // TODO Продумать логику получения объекта + if (name == null || !_storages.ContainsKey(name)) { return null; } + return _storages[name]; + } + } +} diff --git a/ProjectAirbus/ProjectAirbus/FormAirbus.cs b/ProjectAirbus/ProjectAirbus/FormAirbus.cs index 15578ed..560468e 100644 --- a/ProjectAirbus/ProjectAirbus/FormAirbus.cs +++ b/ProjectAirbus/ProjectAirbus/FormAirbus.cs @@ -1,6 +1,6 @@ using ProjectAirbus.Drawnings; using ProjectAirbus.MovementStrategy; -using ProjectMotorboat.MovementStrategy; +using ProjectAirbus.MovementStrategy; using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/ProjectAirbus/ProjectAirbus/FormBusCollection.Designer.cs b/ProjectAirbus/ProjectAirbus/FormBusCollection.Designer.cs index bc3308e..a0ca369 100644 --- a/ProjectAirbus/ProjectAirbus/FormBusCollection.Designer.cs +++ b/ProjectAirbus/ProjectAirbus/FormBusCollection.Designer.cs @@ -29,41 +29,87 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + buttonCreateCompany = new Button(); + comboBoxSelectorCompany = new ComboBox(); + panelCompanyTools = new Panel(); buttonRefresh = new Button(); buttonGoToChek = new Button(); - buttonDelBus = new Button(); - maskedTextBox = new MaskedTextBox(); - buttonAddAirBus = new Button(); buttonAddBus = new Button(); - comboBoxSelectorCompany = new ComboBox(); + buttonDelBus = new Button(); + buttonAddAirBus = new Button(); + maskedTextBox = new MaskedTextBox(); + panelStorage = new Panel(); + buttonCollectionDel = new Button(); + listBoxCollection = new ListBox(); + buttonCollectionAdd = new Button(); + radioButtonList = new RadioButton(); + radioButtonMassive = new RadioButton(); + textBoxCollectionName = new TextBox(); + labelCollectionName = new Label(); pictureBox1 = new PictureBox(); groupBoxTools.SuspendLayout(); + panelCompanyTools.SuspendLayout(); + panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGoToChek); - groupBoxTools.Controls.Add(buttonDelBus); - groupBoxTools.Controls.Add(maskedTextBox); - groupBoxTools.Controls.Add(buttonAddAirBus); - groupBoxTools.Controls.Add(buttonAddBus); + groupBoxTools.Controls.Add(buttonCreateCompany); groupBoxTools.Controls.Add(comboBoxSelectorCompany); + groupBoxTools.Controls.Add(panelCompanyTools); + groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(774, 0); + groupBoxTools.Location = new Point(825, 0); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(303, 584); + groupBoxTools.Size = new Size(303, 644); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // buttonCreateCompany + // + buttonCreateCompany.Location = new Point(15, 316); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(270, 29); + buttonCreateCompany.TabIndex = 7; + buttonCreateCompany.Text = "Создать компанию "; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += buttonCreateCompany_Click; + // + // 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(18, 350); + comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; + comboBoxSelectorCompany.Size = new Size(267, 28); + comboBoxSelectorCompany.TabIndex = 0; + comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged; + // + // panelCompanyTools + // + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(buttonGoToChek); + panelCompanyTools.Controls.Add(buttonAddBus); + panelCompanyTools.Controls.Add(buttonDelBus); + panelCompanyTools.Controls.Add(buttonAddAirBus); + panelCompanyTools.Controls.Add(maskedTextBox); + panelCompanyTools.Dock = DockStyle.Bottom; + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 384); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(297, 257); + panelCompanyTools.TabIndex = 2; + // // buttonRefresh // buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(15, 523); + buttonRefresh.Location = new Point(12, 216); buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(276, 49); + buttonRefresh.Size = new Size(275, 35); buttonRefresh.TabIndex = 6; buttonRefresh.Text = "Обновить "; buttonRefresh.UseVisualStyleBackColor = true; @@ -72,73 +118,141 @@ // buttonGoToChek // buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToChek.Location = new Point(15, 445); + buttonGoToChek.Location = new Point(14, 173); buttonGoToChek.Name = "buttonGoToChek"; - buttonGoToChek.Size = new Size(276, 49); + buttonGoToChek.Size = new Size(273, 37); buttonGoToChek.TabIndex = 5; buttonGoToChek.Text = "Передать на тесты"; buttonGoToChek.UseVisualStyleBackColor = true; // + // buttonAddBus + // + buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddBus.Location = new Point(11, 17); + buttonAddBus.Name = "buttonAddBus"; + buttonAddBus.Size = new Size(270, 33); + buttonAddBus.TabIndex = 1; + buttonAddBus.Text = "Добавление самолета"; + buttonAddBus.UseVisualStyleBackColor = true; + buttonAddBus.Click += ButtonAddBus_Click; + // // buttonDelBus // buttonDelBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonDelBus.Location = new Point(15, 344); + buttonDelBus.Location = new Point(15, 132); buttonDelBus.Name = "buttonDelBus"; - buttonDelBus.Size = new Size(276, 49); + buttonDelBus.Size = new Size(272, 35); buttonDelBus.TabIndex = 4; buttonDelBus.Text = "Удалить самолет"; buttonDelBus.UseVisualStyleBackColor = true; // - // maskedTextBox - // - maskedTextBox.Location = new Point(15, 311); - maskedTextBox.Mask = "00"; - maskedTextBox.Name = "maskedTextBox"; - maskedTextBox.Size = new Size(276, 27); - maskedTextBox.TabIndex = 3; - maskedTextBox.ValidatingType = typeof(int); - maskedTextBox.MaskInputRejected += maskedTextBox_MaskInputRejected; - // // buttonAddAirBus // buttonAddAirBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddAirBus.Location = new Point(15, 181); + buttonAddAirBus.Location = new Point(12, 56); buttonAddAirBus.Name = "buttonAddAirBus"; - buttonAddAirBus.Size = new Size(276, 49); + buttonAddAirBus.Size = new Size(270, 37); buttonAddAirBus.TabIndex = 2; buttonAddAirBus.Text = "Добавление аэробуса"; buttonAddAirBus.UseVisualStyleBackColor = true; buttonAddAirBus.Click += ButtonAddAirbus_Click; // - // buttonAddBus + // maskedTextBox // - buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddBus.Location = new Point(15, 125); - buttonAddBus.Name = "buttonAddBus"; - buttonAddBus.Size = new Size(276, 50); - buttonAddBus.TabIndex = 1; - buttonAddBus.Text = "Добавление самолета"; - buttonAddBus.UseVisualStyleBackColor = true; - buttonAddBus.Click += ButtonAddPlane_Click; + maskedTextBox.Location = new Point(11, 99); + maskedTextBox.Mask = "00"; + maskedTextBox.Name = "maskedTextBox"; + maskedTextBox.Size = new Size(276, 27); + maskedTextBox.TabIndex = 3; + maskedTextBox.ValidatingType = typeof(int); // - // comboBoxSelectorCompany + // panelStorage // - comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; - comboBoxSelectorCompany.FormattingEnabled = true; - comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(15, 26); - comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; - comboBoxSelectorCompany.Size = new Size(276, 28); - comboBoxSelectorCompany.TabIndex = 0; - comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged; + 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(297, 287); + panelStorage.TabIndex = 2; + // + // buttonCollectionDel + // + buttonCollectionDel.Location = new Point(12, 251); + buttonCollectionDel.Name = "buttonCollectionDel"; + buttonCollectionDel.Size = new Size(270, 29); + buttonCollectionDel.TabIndex = 6; + buttonCollectionDel.Text = "Удалить коллекцию"; + buttonCollectionDel.UseVisualStyleBackColor = true; + buttonCollectionDel.Click += buttonCollectionDel_Click; + // + // listBoxCollection + // + listBoxCollection.FormattingEnabled = true; + listBoxCollection.Location = new Point(12, 141); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(264, 104); + listBoxCollection.TabIndex = 5; + // + // buttonCollectionAdd + // + buttonCollectionAdd.Location = new Point(12, 96); + buttonCollectionAdd.Name = "buttonCollectionAdd"; + buttonCollectionAdd.Size = new Size(270, 29); + buttonCollectionAdd.TabIndex = 4; + buttonCollectionAdd.Text = "Добавить коллекцию"; + buttonCollectionAdd.UseVisualStyleBackColor = true; + buttonCollectionAdd.Click += buttonCollectionAdd_Click; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(202, 66); + 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(12, 66); + 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(12, 33); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(270, 27); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(12, 10); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(158, 20); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции:"; // // pictureBox1 // pictureBox1.Dock = DockStyle.Fill; pictureBox1.Location = new Point(0, 0); pictureBox1.Name = "pictureBox1"; - pictureBox1.Size = new Size(774, 584); + pictureBox1.Size = new Size(825, 644); pictureBox1.TabIndex = 1; pictureBox1.TabStop = false; // @@ -146,13 +260,16 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1077, 584); + ClientSize = new Size(1128, 644); Controls.Add(pictureBox1); Controls.Add(groupBoxTools); Name = "FormBusCollection"; Text = "Коллекция самолетов "; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); + panelStorage.ResumeLayout(false); + panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); ResumeLayout(false); } @@ -168,5 +285,15 @@ private MaskedTextBox maskedTextBox; private Button buttonRefresh; private Button buttonGoToChek; + private Panel panelStorage; + private RadioButton radioButtonList; + private RadioButton radioButtonMassive; + private TextBox textBoxCollectionName; + private Label labelCollectionName; + private ListBox listBoxCollection; + private Button buttonCollectionAdd; + private Button buttonCreateCompany; + private Button buttonCollectionDel; + private Panel panelCompanyTools; } } \ No newline at end of file diff --git a/ProjectAirbus/ProjectAirbus/FormBusCollection.cs b/ProjectAirbus/ProjectAirbus/FormBusCollection.cs index b559f2e..a2efc33 100644 --- a/ProjectAirbus/ProjectAirbus/FormBusCollection.cs +++ b/ProjectAirbus/ProjectAirbus/FormBusCollection.cs @@ -1,33 +1,23 @@ using ProjectAirbus.CollectionGenericObjects; using ProjectAirbus.Drawnings; -using ProjectMotorboat.CollectionGenericObjects; -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; +using ProjectAirBus.CollectionGenericObjects; namespace ProjectAirbus { public partial class FormBusCollection : Form { + private readonly StorageCollection _storageCollection; + private AbstractCompany? _company; public FormBusCollection() { InitializeComponent(); + _storageCollection = new(); } + private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { - switch (comboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new AerodromService(pictureBox1.Width, pictureBox1.Height, new MassiveGenericObjects()); - break; - } + panelCompanyTools.Enabled = false; } /// @@ -90,7 +80,7 @@ namespace ProjectAirbus /// /// /// - private void ButtonAddPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus)); + private void ButtonAddBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus)); /// /// добавить аэробус @@ -177,9 +167,104 @@ namespace ProjectAirbus pictureBox1.Image = _company.Show(); } - private void maskedTextBox_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) + /// + /// Добавление коллекции + /// + /// + /// + 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.SelectedItem == null) + { + MessageBox.Show("Коллекция не выбрана"); + return; + } + if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + { + 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 AerodromService(pictureBox1.Width, pictureBox1.Height,collection); + break; + } + + panelCompanyTools.Enabled = true; + RerfreshListBoxItems(); + } } -} +} diff --git a/ProjectAirbus/ProjectAirbus/MovementStrategy/MoveToBorder.cs b/ProjectAirbus/ProjectAirbus/MovementStrategy/MoveToBorder.cs index cf29200..ffb9803 100644 --- a/ProjectAirbus/ProjectAirbus/MovementStrategy/MoveToBorder.cs +++ b/ProjectAirbus/ProjectAirbus/MovementStrategy/MoveToBorder.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ProjectMotorboat.MovementStrategy; +namespace ProjectAirbus.MovementStrategy; public class MoveToBorder : AbstractStrategy { protected override bool IsTargetDestinaion()