PIBD-13_Marinenkova_V.A._LabWork04_Base #4
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAccordionBus.CollectionGenericObjects;
|
||||
|
||||
public enum CollectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Неопределено
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Массив
|
||||
/// </summary>
|
||||
Massive = 1,
|
||||
/// <summary>
|
||||
/// Список
|
||||
/// </summary>
|
||||
List = 2
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAccordionBus.CollectionGenericObjects;
|
||||
|
||||
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T?> _collection;
|
||||
|
||||
private int _maxCount;
|
||||
public int MaxCount => _maxCount;
|
||||
|
||||
public int Count => throw new NotImplementedException();
|
||||
|
||||
public int SetMaxCount { set => throw new NotImplementedException(); }
|
||||
|
||||
public T? Get(int position)
|
||||
{
|
||||
if (position < 0 || position >= _collection.Count || _collection == null || _collection.Count == 0) return null;
|
||||
|
||||
return _collection[position];
|
||||
}
|
||||
|
||||
public int Insert(T obj)
|
||||
{
|
||||
if (_collection == null || _collection.Count == _maxCount) return -1;
|
||||
|
||||
_collection.Add(obj);
|
||||
return _collection.Count - 1;
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
if (_collection == null || position < 0 || position > _maxCount) return -1;
|
||||
|
||||
_collection.Insert(position, obj);
|
||||
return position;
|
||||
}
|
||||
|
||||
public T? Remove(int position)
|
||||
{
|
||||
if (_collection == null || position < 0 || position >= _collection.Count) return null;
|
||||
|
||||
T? obj = _collection[position];
|
||||
_collection[position] = null;
|
||||
return obj;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAccordionBus.CollectionGenericObjects;
|
||||
|
||||
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) || name == "") return;
|
||||
|
||||
if (collectionType == CollectionType.Massive)
|
||||
{
|
||||
_storages[name] = new MassiveGenericObjects<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_storages[name] = new ListGenericObjects<T>();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление коллекции
|
||||
/// </summary>
|
||||
/// <param name="name">Название коллекции</param>
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
// TODO Прописать логику для удаления коллекции
|
||||
_storages.Remove(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Доступ к коллекции
|
||||
/// </summary>
|
||||
/// <param name="name">Название коллекции</param>
|
||||
/// <returns></returns>
|
||||
public ICollectionGenericObjects<T>? this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения объекта
|
||||
if (name == "")
|
||||
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _storages[name];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -29,63 +29,63 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
buttonRefresh = new Button();
|
||||
buttonGoToCheck = new Button();
|
||||
panelCompanyTools = new Panel();
|
||||
buttonDeleteBus = new Button();
|
||||
maskedTextBox = new MaskedTextBox();
|
||||
buttonAddAccordionBus = new Button();
|
||||
buttonRefresh = new Button();
|
||||
buttonGoToCheck = new Button();
|
||||
buttonAddBus = new Button();
|
||||
panelStorage = new Panel();
|
||||
buttonCollectionDel = new Button();
|
||||
listBoxCollection = new ListBox();
|
||||
buttonCollectionAdd = new Button();
|
||||
buttonCreateCompany = new Button();
|
||||
radioButtonList = new RadioButton();
|
||||
radioButtonMassive = new RadioButton();
|
||||
textBoxCollectionName = new TextBox();
|
||||
comboBoxSelectorCompany = new ComboBox();
|
||||
labelCollectionName = new Label();
|
||||
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(buttonDeleteBus);
|
||||
groupBoxTools.Controls.Add(maskedTextBox);
|
||||
groupBoxTools.Controls.Add(buttonAddAccordionBus);
|
||||
groupBoxTools.Controls.Add(buttonAddBus);
|
||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||
groupBoxTools.Controls.Add(panelCompanyTools);
|
||||
groupBoxTools.Controls.Add(panelStorage);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(625, 0);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(175, 450);
|
||||
groupBoxTools.Size = new Size(175, 510);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonRefresh
|
||||
// panelCompanyTools
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(6, 393);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(163, 33);
|
||||
buttonRefresh.TabIndex = 7;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToCheck.Location = new Point(6, 327);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(163, 33);
|
||||
buttonGoToCheck.TabIndex = 6;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
buttonGoToCheck.Click += buttonGoToCheck_Click;
|
||||
panelCompanyTools.Controls.Add(buttonDeleteBus);
|
||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||
panelCompanyTools.Controls.Add(buttonAddAccordionBus);
|
||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||
panelCompanyTools.Controls.Add(buttonAddBus);
|
||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||
panelCompanyTools.Enabled = false;
|
||||
panelCompanyTools.Location = new Point(3, 316);
|
||||
panelCompanyTools.Name = "panelCompanyTools";
|
||||
panelCompanyTools.Size = new Size(169, 191);
|
||||
panelCompanyTools.TabIndex = 10;
|
||||
//
|
||||
// buttonDeleteBus
|
||||
//
|
||||
buttonDeleteBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonDeleteBus.Location = new Point(6, 269);
|
||||
buttonDeleteBus.Location = new Point(6, 109);
|
||||
buttonDeleteBus.Name = "buttonDeleteBus";
|
||||
buttonDeleteBus.Size = new Size(163, 33);
|
||||
buttonDeleteBus.Size = new Size(160, 23);
|
||||
buttonDeleteBus.TabIndex = 5;
|
||||
buttonDeleteBus.Text = "Удаление автобуса";
|
||||
buttonDeleteBus.UseVisualStyleBackColor = true;
|
||||
@ -94,53 +94,172 @@
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
maskedTextBox.Location = new Point(6, 219);
|
||||
maskedTextBox.Location = new Point(6, 80);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(163, 23);
|
||||
maskedTextBox.Size = new Size(160, 23);
|
||||
maskedTextBox.TabIndex = 5;
|
||||
maskedTextBox.ValidatingType = typeof(int);
|
||||
maskedTextBox.MaskInputRejected += maskedTextBox_MaskInputRejected;
|
||||
//
|
||||
// buttonAddAccordionBus
|
||||
//
|
||||
buttonAddAccordionBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonAddAccordionBus.Location = new Point(6, 141);
|
||||
buttonAddAccordionBus.Location = new Point(6, 36);
|
||||
buttonAddAccordionBus.Name = "buttonAddAccordionBus";
|
||||
buttonAddAccordionBus.Size = new Size(163, 45);
|
||||
buttonAddAccordionBus.Size = new Size(160, 38);
|
||||
buttonAddAccordionBus.TabIndex = 3;
|
||||
buttonAddAccordionBus.Text = "Добавление автобуса-гармошки";
|
||||
buttonAddAccordionBus.UseVisualStyleBackColor = true;
|
||||
buttonAddAccordionBus.Click += buttonAddAccordionBus_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(6, 167);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(160, 21);
|
||||
buttonRefresh.TabIndex = 7;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToCheck.Location = new Point(6, 138);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(160, 23);
|
||||
buttonGoToCheck.TabIndex = 6;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
buttonGoToCheck.Click += buttonGoToCheck_Click;
|
||||
//
|
||||
// buttonAddBus
|
||||
//
|
||||
buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonAddBus.Location = new Point(6, 90);
|
||||
buttonAddBus.Location = new Point(6, 3);
|
||||
buttonAddBus.Name = "buttonAddBus";
|
||||
buttonAddBus.Size = new Size(163, 45);
|
||||
buttonAddBus.Size = new Size(160, 27);
|
||||
buttonAddBus.TabIndex = 2;
|
||||
buttonAddBus.Text = "Добавление автобуса";
|
||||
buttonAddBus.UseVisualStyleBackColor = true;
|
||||
buttonAddBus.Click += buttonAddBus_Click;
|
||||
//
|
||||
// panelStorage
|
||||
//
|
||||
panelStorage.Controls.Add(buttonCollectionDel);
|
||||
panelStorage.Controls.Add(listBoxCollection);
|
||||
panelStorage.Controls.Add(buttonCollectionAdd);
|
||||
panelStorage.Controls.Add(buttonCreateCompany);
|
||||
panelStorage.Controls.Add(radioButtonList);
|
||||
panelStorage.Controls.Add(radioButtonMassive);
|
||||
panelStorage.Controls.Add(textBoxCollectionName);
|
||||
panelStorage.Controls.Add(comboBoxSelectorCompany);
|
||||
panelStorage.Controls.Add(labelCollectionName);
|
||||
panelStorage.Dock = DockStyle.Top;
|
||||
panelStorage.Location = new Point(3, 19);
|
||||
panelStorage.Name = "panelStorage";
|
||||
panelStorage.Size = new Size(169, 291);
|
||||
panelStorage.TabIndex = 8;
|
||||
//
|
||||
// buttonCollectionDel
|
||||
//
|
||||
buttonCollectionDel.Location = new Point(6, 198);
|
||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||
buttonCollectionDel.Size = new Size(160, 23);
|
||||
buttonCollectionDel.TabIndex = 6;
|
||||
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||
buttonCollectionDel.Click += buttonCollectionDel_Click;
|
||||
//
|
||||
// listBoxCollection
|
||||
//
|
||||
listBoxCollection.FormattingEnabled = true;
|
||||
listBoxCollection.ItemHeight = 15;
|
||||
listBoxCollection.Location = new Point(6, 113);
|
||||
listBoxCollection.Name = "listBoxCollection";
|
||||
listBoxCollection.Size = new Size(160, 79);
|
||||
listBoxCollection.TabIndex = 5;
|
||||
//
|
||||
// buttonCollectionAdd
|
||||
//
|
||||
buttonCollectionAdd.Location = new Point(3, 81);
|
||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||
buttonCollectionAdd.Size = new Size(163, 23);
|
||||
buttonCollectionAdd.TabIndex = 4;
|
||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||
buttonCollectionAdd.Click += buttonCollectionAdd_Click;
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonCreateCompany.Location = new Point(6, 256);
|
||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||
buttonCreateCompany.Size = new Size(160, 23);
|
||||
buttonCreateCompany.TabIndex = 9;
|
||||
buttonCreateCompany.Text = "Создать компанию";
|
||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||
buttonCreateCompany.Click += buttonCreateCompany_Click;
|
||||
//
|
||||
// radioButtonList
|
||||
//
|
||||
radioButtonList.AutoSize = true;
|
||||
radioButtonList.Location = new Point(93, 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(6, 27);
|
||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||
textBoxCollectionName.Size = new Size(160, 23);
|
||||
textBoxCollectionName.TabIndex = 1;
|
||||
//
|
||||
// comboBoxSelectorCompany
|
||||
//
|
||||
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||
comboBoxSelectorCompany.Location = new Point(6, 22);
|
||||
comboBoxSelectorCompany.Location = new Point(6, 227);
|
||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||
comboBoxSelectorCompany.Size = new Size(163, 23);
|
||||
comboBoxSelectorCompany.Size = new Size(160, 23);
|
||||
comboBoxSelectorCompany.TabIndex = 1;
|
||||
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
|
||||
//
|
||||
// labelCollectionName
|
||||
//
|
||||
labelCollectionName.AutoSize = true;
|
||||
labelCollectionName.Location = new Point(24, 9);
|
||||
labelCollectionName.Name = "labelCollectionName";
|
||||
labelCollectionName.Size = new Size(122, 15);
|
||||
labelCollectionName.TabIndex = 0;
|
||||
labelCollectionName.Text = "Название коллекции";
|
||||
labelCollectionName.Click += labelCollectionName_Click;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(625, 450);
|
||||
pictureBox.Size = new Size(625, 510);
|
||||
pictureBox.TabIndex = 4;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
@ -148,13 +267,16 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
ClientSize = new Size(800, 510);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Name = "FormBusCollection";
|
||||
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 +292,15 @@
|
||||
private Button buttonGoToCheck;
|
||||
private Button buttonDeleteBus;
|
||||
private MaskedTextBox maskedTextBox;
|
||||
private Panel panelStorage;
|
||||
private TextBox textBoxCollectionName;
|
||||
private Label labelCollectionName;
|
||||
private Button buttonCollectionAdd;
|
||||
private RadioButton radioButtonList;
|
||||
private RadioButton radioButtonMassive;
|
||||
private ListBox listBoxCollection;
|
||||
private Button buttonCollectionDel;
|
||||
private Button buttonCreateCompany;
|
||||
private Panel panelCompanyTools;
|
||||
}
|
||||
}
|
@ -17,6 +17,11 @@ namespace ProjectAccordionBus;
|
||||
/// </summary>
|
||||
public partial class FormBusCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Хранилише коллекций
|
||||
/// </summary>
|
||||
private readonly StorageCollection<DrawningBus> _storageCollection;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -28,6 +33,7 @@ public partial class FormBusCollection : Form
|
||||
public FormBusCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storageCollection = new();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление улучшенного троллейбуса
|
||||
@ -158,12 +164,95 @@ public partial class FormBusCollection : Form
|
||||
|
||||
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBoxSelectorCompany.Text)
|
||||
panelCompanyTools.Enabled = false;
|
||||
}
|
||||
|
||||
private void maskedTextBox_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
|
||||
eegov
commented
Пустых методов быть не должно Пустых методов быть не должно
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void labelCollectionName_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonCollectionAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
|
||||
{
|
||||
case "Хранилище":
|
||||
_company = new BusSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningBus>());
|
||||
break;
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
CollectionType collectionType = CollectionType.None;
|
||||
if (radioButtonMassive.Checked)
|
||||
{
|
||||
collectionType = CollectionType.Massive;
|
||||
}
|
||||
else if (radioButtonList.Checked)
|
||||
{
|
||||
collectionType = CollectionType.List;
|
||||
}
|
||||
_storageCollection.AddCollection(textBoxCollectionName.Text,
|
||||
collectionType);
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
|
||||
private void RefreshListBoxItems()
|
||||
{
|
||||
listBoxCollection.Items.Clear();
|
||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||
{
|
||||
string? colName = _storageCollection.Keys?[i];
|
||||
if (!string.IsNullOrEmpty(colName))
|
||||
{
|
||||
listBoxCollection.Items.Add(colName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void buttonCollectionDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxCollection.SelectedItem == null) return;
|
||||
|
||||
if (MessageBox.Show("Вы действительно хотите удалить выбранный элемент?",
|
||||
"Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||
RefreshListBoxItems();
|
||||
MessageBox.Show("Компания удалена");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить компанию");
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreateCompany_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxCollection.SelectedIndex < 0)
|
||||
{
|
||||
MessageBox.Show("Компания не выбрана");
|
||||
return;
|
||||
}
|
||||
|
||||
ICollectionGenericObjects<DrawningBus?> collection = _storageCollection[listBoxCollection.SelectedItem?.ToString() ?? string.Empty];
|
||||
if (collection == null)
|
||||
{
|
||||
MessageBox.Show("Компания не инициализирована");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (comboBoxSelectorCompany.Text)
|
||||
{
|
||||
case "Хранилище":
|
||||
_company = new BusSharingService(pictureBox.Width, pictureBox.Height, collection);
|
||||
break;
|
||||
}
|
||||
|
||||
panelCompanyTools.Enabled = true;
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user
Проверка по наличию ключа