From 612133fe1d53b22a3f4993b3cc704905a68ad11e Mon Sep 17 00:00:00 2001 From: alhimek17 Date: Mon, 8 Apr 2024 00:48:44 +0400 Subject: [PATCH 1/2] =?UTF-8?q?4=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionType.cs | 22 ++ .../ListGenericObjects.cs | 70 +++++ .../StorageCollection.cs | 78 ++++++ .../FormPlaneCollection.Designer.cs | 261 +++++++++++++----- .../ProjectAirPlane/FormPlaneCollection.cs | 116 +++++++- 5 files changed, 471 insertions(+), 76 deletions(-) create mode 100644 ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/CollectionType.cs create mode 100644 ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs create mode 100644 ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs diff --git a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/CollectionType.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/CollectionType.cs new file mode 100644 index 0000000..d88b9f1 --- /dev/null +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/CollectionType.cs @@ -0,0 +1,22 @@ +namespace ProjectAirPlane.CollectionGenericObjects; + +/// +/// Тип коллекции +/// +public enum CollectionType +{ + /// + /// Неопределено + /// + None = 0, + + /// + /// Массив + /// + Massive = 1, + + /// + /// Список + /// + List = 2 +} \ No newline at end of file diff --git a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..f356dfc --- /dev/null +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAirPlane.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/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..d1b2c3d --- /dev/null +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs @@ -0,0 +1,78 @@ +namespace ProjectAirPlane.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 (!(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) + { + // 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/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.Designer.cs b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.Designer.cs index ec8bb03..b13da08 100644 --- a/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.Designer.cs +++ b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.Designer.cs @@ -29,99 +29,215 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); - buttonRefresh = new Button(); - buttonGoToCheck = new Button(); - buttonRemovePlane = new Button(); - maskedTextBox = new MaskedTextBox(); - buttonAddAirPlane = new Button(); + panelCompanyTools = new Panel(); buttonAddPlane = new Button(); + buttonAddAirPlane = new Button(); + maskedTextBox = new MaskedTextBox(); + buttonRefresh = new Button(); + buttonRemovePlane = new Button(); + buttonGoToCheck = new Button(); + 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(); groupBoxTools.SuspendLayout(); + panelCompanyTools.SuspendLayout(); + panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGoToCheck); - groupBoxTools.Controls.Add(buttonRemovePlane); - groupBoxTools.Controls.Add(maskedTextBox); - groupBoxTools.Controls.Add(buttonAddAirPlane); - groupBoxTools.Controls.Add(buttonAddPlane); + groupBoxTools.Controls.Add(panelCompanyTools); + groupBoxTools.Controls.Add(buttonCreateCompany); + groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Location = new Point(686, 0); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(195, 513); + groupBoxTools.Size = new Size(195, 558); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // - // buttonRefresh + // panelCompanyTools // - buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(6, 417); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(177, 35); - buttonRefresh.TabIndex = 6; - buttonRefresh.Text = "Обновить"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += ButtonRefresh_Click; + panelCompanyTools.Controls.Add(buttonAddPlane); + panelCompanyTools.Controls.Add(buttonAddAirPlane); + panelCompanyTools.Controls.Add(maskedTextBox); + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(buttonRemovePlane); + panelCompanyTools.Controls.Add(buttonGoToCheck); + panelCompanyTools.Dock = DockStyle.Bottom; + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 340); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(189, 215); + panelCompanyTools.TabIndex = 8; // - // buttonGoToCheck + // buttonAddPlane // - buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(6, 320); - buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(177, 35); - buttonGoToCheck.TabIndex = 5; - buttonGoToCheck.Text = "Передать на тесты"; - buttonGoToCheck.UseVisualStyleBackColor = true; - buttonGoToCheck.Click += ButtonGoToCheck_Click; - // - // buttonRemovePlane - // - buttonRemovePlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemovePlane.Location = new Point(7, 255); - buttonRemovePlane.Name = "buttonRemovePlane"; - buttonRemovePlane.Size = new Size(177, 35); - buttonRemovePlane.TabIndex = 4; - buttonRemovePlane.Text = "Удалить самолёт"; - buttonRemovePlane.UseVisualStyleBackColor = true; - buttonRemovePlane.Click += ButtonRemovePlane_Click; - // - // maskedTextBox - // - maskedTextBox.Location = new Point(7, 207); - maskedTextBox.Mask = "00"; - maskedTextBox.Name = "maskedTextBox"; - maskedTextBox.Size = new Size(180, 23); - maskedTextBox.TabIndex = 3; - maskedTextBox.ValidatingType = typeof(int); - maskedTextBox.MaskInputRejected += MaskedTextBox_MaskInputRejected; + buttonAddPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddPlane.Location = new Point(3, 13); + buttonAddPlane.Name = "buttonAddPlane"; + buttonAddPlane.Size = new Size(166, 28); + buttonAddPlane.TabIndex = 1; + buttonAddPlane.Text = "Добавление самолёта"; + buttonAddPlane.UseVisualStyleBackColor = true; + buttonAddPlane.Click += ButtonAddPlane_Click; // // buttonAddAirPlane // buttonAddAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddAirPlane.Location = new Point(7, 135); + buttonAddAirPlane.Location = new Point(3, 47); buttonAddAirPlane.Name = "buttonAddAirPlane"; - buttonAddAirPlane.Size = new Size(177, 47); + buttonAddAirPlane.Size = new Size(166, 38); buttonAddAirPlane.TabIndex = 2; buttonAddAirPlane.Text = "Добавление самолёта с радаром"; buttonAddAirPlane.UseVisualStyleBackColor = true; buttonAddAirPlane.Click += ButtonAddAirPlane_Click; // - // buttonAddPlane + // maskedTextBox // - buttonAddPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddPlane.Location = new Point(6, 80); - buttonAddPlane.Name = "buttonAddPlane"; - buttonAddPlane.Size = new Size(177, 37); - buttonAddPlane.TabIndex = 1; - buttonAddPlane.Text = "Добавление самолёта"; - buttonAddPlane.UseVisualStyleBackColor = true; - buttonAddPlane.Click += ButtonAddPlane_Click; + maskedTextBox.Location = new Point(3, 91); + maskedTextBox.Mask = "00"; + maskedTextBox.Name = "maskedTextBox"; + maskedTextBox.Size = new Size(166, 23); + maskedTextBox.TabIndex = 3; + maskedTextBox.ValidatingType = typeof(int); + maskedTextBox.MaskInputRejected += MaskedTextBox_MaskInputRejected; + // + // buttonRefresh + // + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRefresh.Location = new Point(4, 181); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(166, 25); + buttonRefresh.TabIndex = 6; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; + // + // buttonRemovePlane + // + buttonRemovePlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRemovePlane.Location = new Point(3, 120); + buttonRemovePlane.Name = "buttonRemovePlane"; + buttonRemovePlane.Size = new Size(166, 24); + buttonRemovePlane.TabIndex = 4; + buttonRemovePlane.Text = "Удалить самолёт"; + buttonRemovePlane.UseVisualStyleBackColor = true; + buttonRemovePlane.Click += ButtonRemovePlane_Click; + // + // buttonGoToCheck + // + buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonGoToCheck.Location = new Point(4, 150); + buttonGoToCheck.Name = "buttonGoToCheck"; + buttonGoToCheck.Size = new Size(166, 25); + buttonGoToCheck.TabIndex = 5; + buttonGoToCheck.Text = "Передать на тесты"; + buttonGoToCheck.UseVisualStyleBackColor = true; + buttonGoToCheck.Click += ButtonGoToCheck_Click; + // + // buttonCreateCompany + // + buttonCreateCompany.Location = new Point(6, 314); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(177, 23); + buttonCreateCompany.TabIndex = 7; + 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, 19); + panelStorage.Name = "panelStorage"; + panelStorage.Size = new Size(189, 260); + panelStorage.TabIndex = 7; + // + // buttonCollectionDel + // + buttonCollectionDel.Location = new Point(7, 226); + buttonCollectionDel.Name = "buttonCollectionDel"; + buttonCollectionDel.Size = new Size(173, 23); + buttonCollectionDel.TabIndex = 6; + buttonCollectionDel.Text = "Удалить коллекцию"; + buttonCollectionDel.UseVisualStyleBackColor = true; + buttonCollectionDel.Click += ButtonCollectionDel_Click; + // + // listBoxCollection + // + listBoxCollection.FormattingEnabled = true; + listBoxCollection.ItemHeight = 15; + listBoxCollection.Location = new Point(7, 113); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(173, 109); + listBoxCollection.TabIndex = 5; + // + // buttonCollectionAdd + // + buttonCollectionAdd.Location = new Point(7, 81); + buttonCollectionAdd.Name = "buttonCollectionAdd"; + buttonCollectionAdd.Size = new Size(174, 25); + buttonCollectionAdd.TabIndex = 4; + buttonCollectionAdd.Text = "Добавить коллекцию"; + buttonCollectionAdd.UseVisualStyleBackColor = true; + buttonCollectionAdd.Click += ButtonCollectionAdd_Click; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(114, 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(6, 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(181, 23); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(40, 9); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(122, 15); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции"; // // comboBoxSelectorCompany // @@ -129,7 +245,7 @@ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(6, 22); + comboBoxSelectorCompany.Location = new Point(6, 285); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(178, 23); comboBoxSelectorCompany.TabIndex = 0; @@ -140,7 +256,7 @@ pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 0); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(686, 513); + pictureBox.Size = new Size(686, 558); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // @@ -148,13 +264,16 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(881, 513); + ClientSize = new Size(881, 558); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Name = "FormPlaneCollection"; Text = "Коллекция самолётов"; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); + panelStorage.ResumeLayout(false); + panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); ResumeLayout(false); } @@ -170,5 +289,15 @@ private MaskedTextBox maskedTextBox; private Button buttonGoToCheck; private Button buttonRefresh; + private Panel panelStorage; + private Label labelCollectionName; + private TextBox textBoxCollectionName; + private RadioButton radioButtonMassive; + private RadioButton radioButtonList; + private Button buttonCollectionAdd; + private ListBox listBoxCollection; + private Button buttonCollectionDel; + private Button buttonCreateCompany; + private Panel panelCompanyTools; } } \ No newline at end of file diff --git a/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs index c6e665a..f82c901 100644 --- a/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs +++ b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs @@ -17,6 +17,11 @@ namespace ProjectAirPlane; /// public partial class FormPlaneCollection : Form { + /// + /// Хранилише коллекций + /// + private readonly StorageCollection _storageCollection; + /// /// Компания /// @@ -28,6 +33,7 @@ public partial class FormPlaneCollection : Form public FormPlaneCollection() { InitializeComponent(); + _storageCollection = new(); } /// @@ -37,12 +43,7 @@ public partial class FormPlaneCollection : Form /// private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { - switch (comboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new PlaneSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); - break; - } + panelCompanyTools.Enabled = false; } /// @@ -101,12 +102,12 @@ public partial class FormPlaneCollection : Form return color; } private void ButtonAddPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane)); - - + + private void ButtonAddAirPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirPlane)); - + private void MaskedTextBox_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) { @@ -176,5 +177,100 @@ public partial class FormPlaneCollection : 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); + 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 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 PlaneSharingService(pictureBox.Width, pictureBox.Height, collection); + break; + } + + panelCompanyTools.Enabled = true; + RerfreshListBoxItems(); + } } + -- 2.25.1 From 8a9fad5616c79949b5c0d3afd016f73bb2e5237b Mon Sep 17 00:00:00 2001 From: alhimek17 Date: Sun, 21 Apr 2024 20:34:24 +0400 Subject: [PATCH 2/2] =?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=20(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs index 5b24d56..30a6002 100644 --- a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs +++ b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs @@ -33,7 +33,7 @@ public class DrawningAirPlane : DrawningPlane return; } Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityPlane.BodyColor); + Brush additionalBrush = new SolidBrush(airPlane.AdditionalColor); if (airPlane.Chassi) { -- 2.25.1