well done man
This commit is contained in:
parent
c692d3f3e6
commit
9c107b27a0
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectDumpTruck.CollectionGenericObject;
|
||||||
|
|
||||||
|
public enum CollectionType
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Неопределено
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Массив
|
||||||
|
/// </summary>
|
||||||
|
Massive = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Список
|
||||||
|
/// </summary>
|
||||||
|
List = 2
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectDumpTruck.CollectionGenericObject;
|
||||||
|
|
||||||
|
public class ListGenericObjects<T> : ICollectionGenericObject<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)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _collection[position];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj)
|
||||||
|
{
|
||||||
|
if (Count == _maxCount)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_collection.Add(obj);
|
||||||
|
return _collection.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj, int position)
|
||||||
|
{
|
||||||
|
if (Count == _maxCount || position < 0 || position > Count)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_collection.Insert(position, obj);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position > Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
T? obj = _collection[position];
|
||||||
|
_collection.RemoveAt(position);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectDumpTruck.CollectionGenericObject;
|
||||||
|
|
||||||
|
public class StorageCollection<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь (хранилище) с коллекциями
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, ICollectionGenericObject<T>> _storages;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий коллекций
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _storages.Keys.ToList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public StorageCollection()
|
||||||
|
{
|
||||||
|
_storages = new Dictionary<string, ICollectionGenericObject<T>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление коллекции в хранилище
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <param name="collectionType">Тип коллекции</param>
|
||||||
|
public void AddCollection(string name, CollectionType collectionType)
|
||||||
|
{
|
||||||
|
if (name == null || _storages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectionType == CollectionType.Massive)
|
||||||
|
{
|
||||||
|
_storages.Add(name, new MassiveGenericObjects<T>());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectionType == CollectionType.List)
|
||||||
|
{
|
||||||
|
_storages.Add(name, new ListGenericObjects<T>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
public void DelCollection(string name)
|
||||||
|
{
|
||||||
|
if (name == null || !_storages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_storages.Remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ICollectionGenericObject<T>? this[string name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_storages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return _storages[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -29,27 +29,36 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
buttonAddTruck = new Button();
|
panelStorage = new Panel();
|
||||||
buttonRefresh = new Button();
|
buttonCollectionDel = new Button();
|
||||||
maskedTextBoxPosition = new MaskedTextBox();
|
buttonCollectionAdd = new Button();
|
||||||
buttonGoToCheck = new Button();
|
listBoxCollection = new ListBox();
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
radioButtonList = new RadioButton();
|
||||||
buttonRemoveTruck = new Button();
|
radioButtonMassive = new RadioButton();
|
||||||
|
textBoxCollectionName = new TextBox();
|
||||||
|
labelCollectionName = new Label();
|
||||||
|
buttonCompanyCreate = new Button();
|
||||||
|
panelCompanyTools = new Panel();
|
||||||
buttonAddDumpTruck = new Button();
|
buttonAddDumpTruck = new Button();
|
||||||
|
buttonAddTruck = new Button();
|
||||||
|
buttonRemoveTruck = new Button();
|
||||||
|
buttonRefresh = new Button();
|
||||||
|
buttonGoToCheck = new Button();
|
||||||
|
maskedTextBoxPosition = new MaskedTextBox();
|
||||||
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
|
panelStorage.SuspendLayout();
|
||||||
|
panelCompanyTools.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
groupBoxTools.Controls.Add(buttonAddTruck);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(buttonRefresh);
|
groupBoxTools.Controls.Add(buttonCompanyCreate);
|
||||||
groupBoxTools.Controls.Add(maskedTextBoxPosition);
|
groupBoxTools.Controls.Add(panelCompanyTools);
|
||||||
groupBoxTools.Controls.Add(buttonGoToCheck);
|
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBoxTools.Controls.Add(buttonRemoveTruck);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddDumpTruck);
|
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(888, 0);
|
groupBoxTools.Location = new Point(888, 0);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
@ -58,59 +67,132 @@
|
|||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// panelStorage
|
||||||
|
//
|
||||||
|
panelStorage.Controls.Add(buttonCollectionDel);
|
||||||
|
panelStorage.Controls.Add(buttonCollectionAdd);
|
||||||
|
panelStorage.Controls.Add(listBoxCollection);
|
||||||
|
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(232, 274);
|
||||||
|
panelStorage.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// buttonCollectionDel
|
||||||
|
//
|
||||||
|
buttonCollectionDel.Location = new Point(0, 226);
|
||||||
|
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||||
|
buttonCollectionDel.Size = new Size(226, 35);
|
||||||
|
buttonCollectionDel.TabIndex = 13;
|
||||||
|
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||||
|
buttonCollectionDel.Click += ButtonCollectionDel_Click;
|
||||||
|
//
|
||||||
|
// buttonCollectionAdd
|
||||||
|
//
|
||||||
|
buttonCollectionAdd.Location = new Point(3, 95);
|
||||||
|
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||||
|
buttonCollectionAdd.Size = new Size(226, 35);
|
||||||
|
buttonCollectionAdd.TabIndex = 12;
|
||||||
|
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||||
|
buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
|
||||||
|
//
|
||||||
|
// listBoxCollection
|
||||||
|
//
|
||||||
|
listBoxCollection.FormattingEnabled = true;
|
||||||
|
listBoxCollection.ItemHeight = 20;
|
||||||
|
listBoxCollection.Location = new Point(3, 136);
|
||||||
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
|
listBoxCollection.Size = new Size(226, 84);
|
||||||
|
listBoxCollection.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// radioButtonList
|
||||||
|
//
|
||||||
|
radioButtonList.AutoSize = true;
|
||||||
|
radioButtonList.Location = new Point(124, 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(27, 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(3, 32);
|
||||||
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
|
textBoxCollectionName.Size = new Size(226, 27);
|
||||||
|
textBoxCollectionName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCollectionName
|
||||||
|
//
|
||||||
|
labelCollectionName.AutoSize = true;
|
||||||
|
labelCollectionName.Location = new Point(39, 9);
|
||||||
|
labelCollectionName.Name = "labelCollectionName";
|
||||||
|
labelCollectionName.Size = new Size(155, 20);
|
||||||
|
labelCollectionName.TabIndex = 0;
|
||||||
|
labelCollectionName.Text = "Название коллекции";
|
||||||
|
//
|
||||||
|
// buttonCompanyCreate
|
||||||
|
//
|
||||||
|
buttonCompanyCreate.Location = new Point(6, 337);
|
||||||
|
buttonCompanyCreate.Name = "buttonCompanyCreate";
|
||||||
|
buttonCompanyCreate.Size = new Size(226, 42);
|
||||||
|
buttonCompanyCreate.TabIndex = 11;
|
||||||
|
buttonCompanyCreate.Text = "Создание компанию\r\n";
|
||||||
|
buttonCompanyCreate.Click += ButtonCompanyCreate_Click;
|
||||||
|
//
|
||||||
|
// panelCompanyTools
|
||||||
|
//
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddDumpTruck);
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddTruck);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRemoveTruck);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
|
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
||||||
|
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||||
|
panelCompanyTools.Enabled = false;
|
||||||
|
panelCompanyTools.Location = new Point(3, 385);
|
||||||
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
|
panelCompanyTools.Size = new Size(232, 300);
|
||||||
|
panelCompanyTools.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// buttonAddDumpTruck
|
||||||
|
//
|
||||||
|
buttonAddDumpTruck.Location = new Point(3, 51);
|
||||||
|
buttonAddDumpTruck.Name = "buttonAddDumpTruck";
|
||||||
|
buttonAddDumpTruck.Size = new Size(226, 48);
|
||||||
|
buttonAddDumpTruck.TabIndex = 2;
|
||||||
|
buttonAddDumpTruck.Text = "Добавление самосвала";
|
||||||
|
buttonAddDumpTruck.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddDumpTruck.Click += ButtonAddDumpTruck_Click;
|
||||||
|
//
|
||||||
// buttonAddTruck
|
// buttonAddTruck
|
||||||
//
|
//
|
||||||
buttonAddTruck.Location = new Point(6, 140);
|
buttonAddTruck.Location = new Point(3, 3);
|
||||||
buttonAddTruck.Name = "buttonAddTruck";
|
buttonAddTruck.Name = "buttonAddTruck";
|
||||||
buttonAddTruck.Size = new Size(226, 42);
|
buttonAddTruck.Size = new Size(226, 42);
|
||||||
buttonAddTruck.TabIndex = 0;
|
buttonAddTruck.TabIndex = 0;
|
||||||
buttonAddTruck.Text = "Добваление грузовика";
|
buttonAddTruck.Text = "Добваление грузовика";
|
||||||
buttonAddTruck.Click += ButtonAddTruck_Click;
|
buttonAddTruck.Click += ButtonAddTruck_Click;
|
||||||
//
|
//
|
||||||
// buttonRefresh
|
|
||||||
//
|
|
||||||
buttonRefresh.Location = new Point(6, 634);
|
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
|
||||||
buttonRefresh.Size = new Size(226, 48);
|
|
||||||
buttonRefresh.TabIndex = 6;
|
|
||||||
buttonRefresh.Text = "Обновить";
|
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
|
||||||
//
|
|
||||||
maskedTextBoxPosition.Location = new Point(6, 269);
|
|
||||||
maskedTextBoxPosition.Mask = "00";
|
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
|
||||||
maskedTextBoxPosition.Size = new Size(226, 27);
|
|
||||||
maskedTextBoxPosition.TabIndex = 3;
|
|
||||||
maskedTextBoxPosition.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// buttonGoToCheck
|
|
||||||
//
|
|
||||||
buttonGoToCheck.Location = new Point(6, 438);
|
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
|
||||||
buttonGoToCheck.Size = new Size(226, 48);
|
|
||||||
buttonGoToCheck.TabIndex = 5;
|
|
||||||
buttonGoToCheck.Text = "Передать на тест";
|
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
|
||||||
buttonGoToCheck.Click += ButtonGoToCheck_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(6, 26);
|
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
|
||||||
comboBoxSelectorCompany.Size = new Size(226, 28);
|
|
||||||
comboBoxSelectorCompany.TabIndex = 9;
|
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += СomboBoxSelectorCompany_SelectedIndexChanged_1;
|
|
||||||
//
|
|
||||||
// buttonRemoveTruck
|
// buttonRemoveTruck
|
||||||
//
|
//
|
||||||
buttonRemoveTruck.Location = new Point(6, 302);
|
buttonRemoveTruck.Location = new Point(3, 138);
|
||||||
buttonRemoveTruck.Name = "buttonRemoveTruck";
|
buttonRemoveTruck.Name = "buttonRemoveTruck";
|
||||||
buttonRemoveTruck.Size = new Size(226, 48);
|
buttonRemoveTruck.Size = new Size(226, 48);
|
||||||
buttonRemoveTruck.TabIndex = 4;
|
buttonRemoveTruck.TabIndex = 4;
|
||||||
@ -118,15 +200,46 @@
|
|||||||
buttonRemoveTruck.UseVisualStyleBackColor = true;
|
buttonRemoveTruck.UseVisualStyleBackColor = true;
|
||||||
buttonRemoveTruck.Click += ButtonRemoveTruck_Click;
|
buttonRemoveTruck.Click += ButtonRemoveTruck_Click;
|
||||||
//
|
//
|
||||||
// buttonAddDumpTruck
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonAddDumpTruck.Location = new Point(6, 188);
|
buttonRefresh.Location = new Point(3, 246);
|
||||||
buttonAddDumpTruck.Name = "buttonAddDumpTruck";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonAddDumpTruck.Size = new Size(226, 48);
|
buttonRefresh.Size = new Size(226, 48);
|
||||||
buttonAddDumpTruck.TabIndex = 2;
|
buttonRefresh.TabIndex = 6;
|
||||||
buttonAddDumpTruck.Text = "Добавление самосвала";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonAddDumpTruck.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
buttonAddDumpTruck.Click += ButtonAddDumpTruck_Click;
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
|
//
|
||||||
|
// buttonGoToCheck
|
||||||
|
//
|
||||||
|
buttonGoToCheck.Location = new Point(3, 192);
|
||||||
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
|
buttonGoToCheck.Size = new Size(226, 48);
|
||||||
|
buttonGoToCheck.TabIndex = 5;
|
||||||
|
buttonGoToCheck.Text = "Передать на тест";
|
||||||
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
maskedTextBoxPosition.Location = new Point(3, 105);
|
||||||
|
maskedTextBoxPosition.Mask = "00";
|
||||||
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
maskedTextBoxPosition.Size = new Size(226, 27);
|
||||||
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
|
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// 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, 303);
|
||||||
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
|
comboBoxSelectorCompany.Size = new Size(226, 28);
|
||||||
|
comboBoxSelectorCompany.TabIndex = 9;
|
||||||
|
comboBoxSelectorCompany.SelectedIndexChanged += СomboBoxSelectorCompany_SelectedIndexChanged_1;
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
@ -147,7 +260,10 @@
|
|||||||
Name = "FormTruckCollection";
|
Name = "FormTruckCollection";
|
||||||
Text = "Коллекция грузовиков";
|
Text = "Коллекция грузовиков";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
groupBoxTools.PerformLayout();
|
panelStorage.ResumeLayout(false);
|
||||||
|
panelStorage.PerformLayout();
|
||||||
|
panelCompanyTools.ResumeLayout(false);
|
||||||
|
panelCompanyTools.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
@ -163,5 +279,15 @@
|
|||||||
private Button buttonRefresh;
|
private Button buttonRefresh;
|
||||||
private ComboBox comboBoxSelectorCompany;
|
private ComboBox comboBoxSelectorCompany;
|
||||||
private Button buttonAddTruck;
|
private Button buttonAddTruck;
|
||||||
|
private Panel panelCompanyTools;
|
||||||
|
private Button buttonCompanyCreate;
|
||||||
|
private Panel panelStorage;
|
||||||
|
private Button buttonCollectionAdd;
|
||||||
|
private ListBox listBoxCollection;
|
||||||
|
private RadioButton radioButtonList;
|
||||||
|
private RadioButton radioButtonMassive;
|
||||||
|
private TextBox textBoxCollectionName;
|
||||||
|
private Label labelCollectionName;
|
||||||
|
private Button buttonCollectionDel;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,6 +19,12 @@ namespace ProjectDumpTruck;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FormTruckCollection : Form
|
public partial class FormTruckCollection : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Хранилище коллекций
|
||||||
|
/// </summary>
|
||||||
|
private readonly StorageCollection<DrawningTruck> _storageCollection;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Компания
|
/// Компания
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -30,6 +36,7 @@ public partial class FormTruckCollection : Form
|
|||||||
public FormTruckCollection()
|
public FormTruckCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_storageCollection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -39,12 +46,7 @@ public partial class FormTruckCollection : Form
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void СomboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
|
private void СomboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (comboBoxSelectorCompany.Text)
|
panelCompanyTools.Enabled = false;
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new Autopark(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningTruck>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -192,7 +194,81 @@ public partial class FormTruckCollection : Form
|
|||||||
pictureBox.Image = _company.Show();
|
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);
|
||||||
|
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.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show("Вы уверены, что хотите удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||||
|
RefreshListBoxItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCompanyCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICollectionGenericObject<DrawningTruck>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (collection == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не проинициализирована");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (comboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new Autopark(pictureBox.Width, pictureBox.Height, collection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
panelCompanyTools.Enabled = true;
|
||||||
|
RefreshListBoxItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user