Лаб 4
This commit is contained in:
parent
535a8b9a9c
commit
c1e3ede3b6
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAiroplane.CollectionGenericObjects;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Тип коллекции
|
||||||
|
/// </summary>
|
||||||
|
public enum CollectionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Неопределено
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Массив
|
||||||
|
/// </summary>
|
||||||
|
Massive = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Список
|
||||||
|
/// </summary>
|
||||||
|
List = 2
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
namespace ProjectAiroplane.CollectionGenericObjects;
|
||||||
|
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 (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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
namespace ProjectAiroplane.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 (_storages.ContainsKey(name)) return;
|
||||||
|
if (collectionType == CollectionType.None) return;
|
||||||
|
else if (collectionType == CollectionType.Massive)
|
||||||
|
_storages[name] = new MassiveGenericObjects<T>();
|
||||||
|
else if (collectionType == CollectionType.List)
|
||||||
|
_storages[name] = new ListGenericObjects<T>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
public void DelCollection(string name)
|
||||||
|
{
|
||||||
|
// TODO Прописать логику для удаления коллекции
|
||||||
|
if (_storages.ContainsKey(name))
|
||||||
|
_storages.Remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ICollectionGenericObjects<T> this[string name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// TODO Продумать логику получения объекта
|
||||||
|
if (_storages.ContainsKey(name))
|
||||||
|
return _storages[name];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,15 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
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();
|
buttonReFresh = new Button();
|
||||||
buttonGoToCheck = new Button();
|
buttonGoToCheck = new Button();
|
||||||
buttonDelPlane = new Button();
|
buttonDelPlane = new Button();
|
||||||
@ -37,18 +46,18 @@
|
|||||||
buttonAddPlane = new Button();
|
buttonAddPlane = new Button();
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
|
panelCompanyTools = new Panel();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
panelCompanyTools.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
groupBoxTools.Controls.Add(buttonReFresh);
|
groupBoxTools.Controls.Add(panelCompanyTools);
|
||||||
groupBoxTools.Controls.Add(buttonGoToCheck);
|
groupBoxTools.Controls.Add(buttonCreateCompany);
|
||||||
groupBoxTools.Controls.Add(buttonDelPlane);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(maskedTextBox1);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddAiroplane);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddPlane);
|
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(859, 0);
|
groupBoxTools.Location = new Point(859, 0);
|
||||||
@ -58,20 +67,112 @@
|
|||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// buttonCreateCompany
|
||||||
|
//
|
||||||
|
buttonCreateCompany.Location = new Point(13, 346);
|
||||||
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
|
buttonCreateCompany.Size = new Size(252, 28);
|
||||||
|
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(271, 283);
|
||||||
|
panelStorage.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonCollectionDel
|
||||||
|
//
|
||||||
|
buttonCollectionDel.Location = new Point(10, 239);
|
||||||
|
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||||
|
buttonCollectionDel.Size = new Size(252, 28);
|
||||||
|
buttonCollectionDel.TabIndex = 6;
|
||||||
|
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||||
|
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCollectionDel.Click += ButtonCollectionDel_Click;
|
||||||
|
//
|
||||||
|
// listBoxCollection
|
||||||
|
//
|
||||||
|
listBoxCollection.FormattingEnabled = true;
|
||||||
|
listBoxCollection.ItemHeight = 20;
|
||||||
|
listBoxCollection.Location = new Point(10, 129);
|
||||||
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
|
listBoxCollection.Size = new Size(252, 104);
|
||||||
|
listBoxCollection.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonCollectionAdd
|
||||||
|
//
|
||||||
|
buttonCollectionAdd.Location = new Point(10, 95);
|
||||||
|
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||||
|
buttonCollectionAdd.Size = new Size(252, 28);
|
||||||
|
buttonCollectionAdd.TabIndex = 4;
|
||||||
|
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||||
|
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
|
||||||
|
//
|
||||||
|
// radioButtonList
|
||||||
|
//
|
||||||
|
radioButtonList.AutoSize = true;
|
||||||
|
radioButtonList.Location = new Point(150, 65);
|
||||||
|
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(42, 65);
|
||||||
|
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(10, 32);
|
||||||
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
|
textBoxCollectionName.Size = new Size(252, 27);
|
||||||
|
textBoxCollectionName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCollectionName
|
||||||
|
//
|
||||||
|
labelCollectionName.AutoSize = true;
|
||||||
|
labelCollectionName.Location = new Point(59, 9);
|
||||||
|
labelCollectionName.Name = "labelCollectionName";
|
||||||
|
labelCollectionName.Size = new Size(158, 20);
|
||||||
|
labelCollectionName.TabIndex = 0;
|
||||||
|
labelCollectionName.Text = "Название коллекции:";
|
||||||
|
//
|
||||||
// buttonReFresh
|
// buttonReFresh
|
||||||
//
|
//
|
||||||
buttonReFresh.Location = new Point(13, 536);
|
buttonReFresh.Location = new Point(7, 237);
|
||||||
buttonReFresh.Name = "buttonReFresh";
|
buttonReFresh.Name = "buttonReFresh";
|
||||||
buttonReFresh.Size = new Size(252, 57);
|
buttonReFresh.Size = new Size(252, 40);
|
||||||
buttonReFresh.TabIndex = 6;
|
buttonReFresh.TabIndex = 6;
|
||||||
buttonReFresh.Text = "Обновить";
|
buttonReFresh.Text = "Обновить";
|
||||||
buttonReFresh.UseVisualStyleBackColor = true;
|
buttonReFresh.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// buttonGoToCheck
|
// buttonGoToCheck
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Location = new Point(11, 400);
|
buttonGoToCheck.Location = new Point(7, 189);
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
buttonGoToCheck.Size = new Size(254, 57);
|
buttonGoToCheck.Size = new Size(254, 42);
|
||||||
buttonGoToCheck.TabIndex = 5;
|
buttonGoToCheck.TabIndex = 5;
|
||||||
buttonGoToCheck.Text = "Передать на тест";
|
buttonGoToCheck.Text = "Передать на тест";
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
@ -79,9 +180,9 @@
|
|||||||
//
|
//
|
||||||
// buttonDelPlane
|
// buttonDelPlane
|
||||||
//
|
//
|
||||||
buttonDelPlane.Location = new Point(13, 285);
|
buttonDelPlane.Location = new Point(7, 140);
|
||||||
buttonDelPlane.Name = "buttonDelPlane";
|
buttonDelPlane.Name = "buttonDelPlane";
|
||||||
buttonDelPlane.Size = new Size(252, 57);
|
buttonDelPlane.Size = new Size(254, 43);
|
||||||
buttonDelPlane.TabIndex = 4;
|
buttonDelPlane.TabIndex = 4;
|
||||||
buttonDelPlane.Text = "Удалить самолёт";
|
buttonDelPlane.Text = "Удалить самолёт";
|
||||||
buttonDelPlane.UseVisualStyleBackColor = true;
|
buttonDelPlane.UseVisualStyleBackColor = true;
|
||||||
@ -89,7 +190,7 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBox1
|
// maskedTextBox1
|
||||||
//
|
//
|
||||||
maskedTextBox1.Location = new Point(13, 252);
|
maskedTextBox1.Location = new Point(7, 107);
|
||||||
maskedTextBox1.Mask = "00";
|
maskedTextBox1.Mask = "00";
|
||||||
maskedTextBox1.Name = "maskedTextBox1";
|
maskedTextBox1.Name = "maskedTextBox1";
|
||||||
maskedTextBox1.Size = new Size(252, 27);
|
maskedTextBox1.Size = new Size(252, 27);
|
||||||
@ -98,9 +199,9 @@
|
|||||||
//
|
//
|
||||||
// buttonAddAiroplane
|
// buttonAddAiroplane
|
||||||
//
|
//
|
||||||
buttonAddAiroplane.Location = new Point(13, 153);
|
buttonAddAiroplane.Location = new Point(7, 60);
|
||||||
buttonAddAiroplane.Name = "buttonAddAiroplane";
|
buttonAddAiroplane.Name = "buttonAddAiroplane";
|
||||||
buttonAddAiroplane.Size = new Size(252, 57);
|
buttonAddAiroplane.Size = new Size(252, 41);
|
||||||
buttonAddAiroplane.TabIndex = 2;
|
buttonAddAiroplane.TabIndex = 2;
|
||||||
buttonAddAiroplane.Text = "Добавление самолёта с радаром";
|
buttonAddAiroplane.Text = "Добавление самолёта с радаром";
|
||||||
buttonAddAiroplane.UseVisualStyleBackColor = true;
|
buttonAddAiroplane.UseVisualStyleBackColor = true;
|
||||||
@ -108,9 +209,9 @@
|
|||||||
//
|
//
|
||||||
// buttonAddPlane
|
// buttonAddPlane
|
||||||
//
|
//
|
||||||
buttonAddPlane.Location = new Point(13, 81);
|
buttonAddPlane.Location = new Point(7, 14);
|
||||||
buttonAddPlane.Name = "buttonAddPlane";
|
buttonAddPlane.Name = "buttonAddPlane";
|
||||||
buttonAddPlane.Size = new Size(252, 55);
|
buttonAddPlane.Size = new Size(252, 40);
|
||||||
buttonAddPlane.TabIndex = 1;
|
buttonAddPlane.TabIndex = 1;
|
||||||
buttonAddPlane.Text = "Добавление самолёта";
|
buttonAddPlane.Text = "Добавление самолёта";
|
||||||
buttonAddPlane.UseVisualStyleBackColor = true;
|
buttonAddPlane.UseVisualStyleBackColor = true;
|
||||||
@ -122,7 +223,7 @@
|
|||||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||||
comboBoxSelectorCompany.Location = new Point(13, 31);
|
comboBoxSelectorCompany.Location = new Point(13, 312);
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
comboBoxSelectorCompany.Size = new Size(252, 28);
|
comboBoxSelectorCompany.Size = new Size(252, 28);
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
@ -137,6 +238,20 @@
|
|||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// panelCompanyTools
|
||||||
|
//
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddPlane);
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddAiroplane);
|
||||||
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
|
panelCompanyTools.Controls.Add(buttonDelPlane);
|
||||||
|
panelCompanyTools.Controls.Add(maskedTextBox1);
|
||||||
|
panelCompanyTools.Controls.Add(buttonReFresh);
|
||||||
|
panelCompanyTools.Enabled = false;
|
||||||
|
panelCompanyTools.Location = new Point(9, 380);
|
||||||
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
|
panelCompanyTools.Size = new Size(268, 322);
|
||||||
|
panelCompanyTools.TabIndex = 9;
|
||||||
|
//
|
||||||
// FormPlaneCollection
|
// FormPlaneCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -147,8 +262,11 @@
|
|||||||
Name = "FormPlaneCollection";
|
Name = "FormPlaneCollection";
|
||||||
Text = "Коллекция самолётов";
|
Text = "Коллекция самолётов";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
groupBoxTools.PerformLayout();
|
panelStorage.ResumeLayout(false);
|
||||||
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
panelCompanyTools.ResumeLayout(false);
|
||||||
|
panelCompanyTools.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,5 +281,15 @@
|
|||||||
private MaskedTextBox maskedTextBox1;
|
private MaskedTextBox maskedTextBox1;
|
||||||
private Button buttonReFresh;
|
private Button buttonReFresh;
|
||||||
private Button buttonGoToCheck;
|
private Button buttonGoToCheck;
|
||||||
|
private Panel panelStorage;
|
||||||
|
private RadioButton radioButtonMassive;
|
||||||
|
private TextBox textBoxCollectionName;
|
||||||
|
private Label labelCollectionName;
|
||||||
|
private Button buttonCollectionDel;
|
||||||
|
private ListBox listBoxCollection;
|
||||||
|
private Button buttonCollectionAdd;
|
||||||
|
private RadioButton radioButtonList;
|
||||||
|
private Button buttonCreateCompany;
|
||||||
|
private Panel panelCompanyTools;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,27 +10,29 @@ public partial class FormPlaneCollection : Form
|
|||||||
/// Компания
|
/// Компания
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AbstractCompany? _company = null;
|
private AbstractCompany? _company = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Хранилище коллеций
|
||||||
|
/// </summary>
|
||||||
|
private readonly StorageCollection<Drawningplane> _storageCollection;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormPlaneCollection()
|
public FormPlaneCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_storageCollection = new();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Выбор компании
|
/// Выбор компании
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
|
///
|
||||||
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (comboBoxSelectorCompany.Text)
|
panelCompanyTools.Enabled = false;
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new PlaneSharingService(pictureBox.Width,
|
|
||||||
pictureBox.Height, new MassiveGenericObjects<Drawningplane>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление обычного самолёта
|
/// Добавление обычного самолёта
|
||||||
@ -169,6 +171,99 @@ public partial class FormPlaneCollection : Form
|
|||||||
}
|
}
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCollectionDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// TODO прописать логику удаления элемента из коллекции
|
||||||
|
// нужно убедиться, что есть выбранная коллекция
|
||||||
|
// спросить у пользователя через MessageBox, что он подтверждает, чтохочет удалить запись
|
||||||
|
// удалить и обновить ListBox
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Обновление спсика в listBoxCollection
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать компании
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCreateCompany_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ICollectionGenericObjects<Drawningplane>? 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();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user