Лабораторная работа №4
This commit is contained in:
parent
f0d997122c
commit
6cd1804e9a
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excavator.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public enum CollectionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Неопределено
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Массив
|
||||||
|
/// </summary>
|
||||||
|
Massive = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Список
|
||||||
|
/// </summary>
|
||||||
|
List = 2
|
||||||
|
}
|
@ -7,6 +7,7 @@ namespace Excavator.CollectionGenericObjects;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Garage : AbstractCompany
|
public class Garage : AbstractCompany
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excavator.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Список объектов, которые храним
|
||||||
|
/// </summary>
|
||||||
|
private readonly List<T?> _collection;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Максимально допустимое число объектов в списке
|
||||||
|
/// </summary>
|
||||||
|
public 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 >= Count || position < 0) return null;
|
||||||
|
return _collection[position];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj)
|
||||||
|
{
|
||||||
|
if (Count == _maxCount) return -1;
|
||||||
|
_collection.Add(obj);
|
||||||
|
return Count;
|
||||||
|
}
|
||||||
|
public int Insert(T obj, int position)
|
||||||
|
{
|
||||||
|
if (Count == _maxCount) return -1;
|
||||||
|
if (position >= Count || position < 0) return -1;
|
||||||
|
_collection.Insert(position, obj);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Remove(int position)
|
||||||
|
{
|
||||||
|
if (position >= Count || position < 0) return null;
|
||||||
|
T temp = _collection[position];
|
||||||
|
_collection.RemoveAt(position);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excavator.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)
|
||||||
|
{
|
||||||
|
if (name == null || _storages.ContainsKey(name))
|
||||||
|
return;
|
||||||
|
switch (collectionType)
|
||||||
|
{
|
||||||
|
case CollectionType.None:
|
||||||
|
return;
|
||||||
|
case CollectionType.Massive:
|
||||||
|
_storages[name] = new MassiveGenericObjects<T>();
|
||||||
|
return;
|
||||||
|
case CollectionType.List:
|
||||||
|
_storages[name] = new ListGenericObjects<T>();
|
||||||
|
return;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
public void DelCollection(string name)
|
||||||
|
{
|
||||||
|
if (_storages.ContainsKey(name))
|
||||||
|
_storages.Remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ICollectionGenericObjects<T>? this[string name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_storages.ContainsKey(name))
|
||||||
|
return _storages[name];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
251
Excavator/Excavator/FormExcavatorCollection.Designer.cs
generated
251
Excavator/Excavator/FormExcavatorCollection.Designer.cs
generated
@ -29,28 +29,37 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
buttonRefresh = new Button();
|
buttonCreateCompany = new Button();
|
||||||
buttonGoToCheck = new Button();
|
panelStorage = new Panel();
|
||||||
buttonRemoveExcavator = new Button();
|
buttonCollectionDel = new Button();
|
||||||
maskedTextBoxPosition = new MaskedTextBox();
|
listBoxCollection = new ListBox();
|
||||||
buttonAddExcavator = new Button();
|
buttonCollectionAdd = new Button();
|
||||||
buttonAddSimpleExcavator = new Button();
|
radioButtonList = new RadioButton();
|
||||||
|
radioButtonMassive = new RadioButton();
|
||||||
|
labelCollectionName = new Label();
|
||||||
|
textBoxCollectionName = new TextBox();
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
|
panelCompanyTools = new Panel();
|
||||||
|
buttonGoToCheck = new Button();
|
||||||
|
buttonAddSimpleExcavator = new Button();
|
||||||
|
buttonAddExcavator = new Button();
|
||||||
|
maskedTextBoxPosition = new MaskedTextBox();
|
||||||
|
buttonRemoveExcavator = new Button();
|
||||||
|
buttonRefresh = new Button();
|
||||||
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.Anchor = AnchorStyles.Right;
|
groupBoxTools.Anchor = AnchorStyles.Right;
|
||||||
groupBoxTools.Controls.Add(buttonRefresh);
|
groupBoxTools.Controls.Add(buttonCreateCompany);
|
||||||
groupBoxTools.Controls.Add(buttonGoToCheck);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(buttonRemoveExcavator);
|
|
||||||
groupBoxTools.Controls.Add(maskedTextBoxPosition);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddExcavator);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddSimpleExcavator);
|
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
|
groupBoxTools.Controls.Add(panelCompanyTools);
|
||||||
groupBoxTools.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point);
|
groupBoxTools.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
groupBoxTools.Location = new Point(855, 1);
|
groupBoxTools.Location = new Point(855, 1);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
@ -59,64 +68,97 @@
|
|||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// buttonRefresh
|
// buttonCreateCompany
|
||||||
//
|
//
|
||||||
buttonRefresh.Location = new Point(6, 473);
|
buttonCreateCompany.Location = new Point(9, 325);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
buttonRefresh.Size = new Size(200, 49);
|
buttonCreateCompany.Size = new Size(191, 34);
|
||||||
buttonRefresh.TabIndex = 6;
|
buttonCreateCompany.TabIndex = 7;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonCreateCompany.Text = "Создать компанию";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
buttonCreateCompany.Click += buttonCreateCompany_Click;
|
||||||
//
|
//
|
||||||
// buttonGoToCheck
|
// panelStorage
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Location = new Point(6, 379);
|
panelStorage.Controls.Add(buttonCollectionDel);
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
panelStorage.Controls.Add(listBoxCollection);
|
||||||
buttonGoToCheck.Size = new Size(200, 49);
|
panelStorage.Controls.Add(buttonCollectionAdd);
|
||||||
buttonGoToCheck.TabIndex = 5;
|
panelStorage.Controls.Add(radioButtonList);
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
panelStorage.Controls.Add(radioButtonMassive);
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
panelStorage.Controls.Add(labelCollectionName);
|
||||||
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
panelStorage.Controls.Add(textBoxCollectionName);
|
||||||
|
panelStorage.Location = new Point(6, 23);
|
||||||
|
panelStorage.Name = "panelStorage";
|
||||||
|
panelStorage.Size = new Size(200, 269);
|
||||||
|
panelStorage.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// buttonRemoveExcavator
|
// buttonCollectionDel
|
||||||
//
|
//
|
||||||
buttonRemoveExcavator.Location = new Point(6, 273);
|
buttonCollectionDel.Location = new Point(6, 231);
|
||||||
buttonRemoveExcavator.Name = "buttonRemoveExcavator";
|
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||||
buttonRemoveExcavator.Size = new Size(200, 49);
|
buttonCollectionDel.Size = new Size(191, 38);
|
||||||
buttonRemoveExcavator.TabIndex = 4;
|
buttonCollectionDel.TabIndex = 6;
|
||||||
buttonRemoveExcavator.Text = "Удалить экскаватор";
|
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||||
buttonRemoveExcavator.UseVisualStyleBackColor = true;
|
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||||
buttonRemoveExcavator.Click += ButtonRemoveExcavator_Click;
|
buttonCollectionDel.Click += buttonCollectionDel_Click;
|
||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// listBoxCollection
|
||||||
//
|
//
|
||||||
maskedTextBoxPosition.Location = new Point(12, 244);
|
listBoxCollection.FormattingEnabled = true;
|
||||||
maskedTextBoxPosition.Mask = "00";
|
listBoxCollection.Location = new Point(6, 121);
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
maskedTextBoxPosition.Size = new Size(194, 20);
|
listBoxCollection.Size = new Size(191, 108);
|
||||||
maskedTextBoxPosition.TabIndex = 3;
|
listBoxCollection.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// buttonAddExcavator
|
// buttonCollectionAdd
|
||||||
//
|
//
|
||||||
buttonAddExcavator.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonCollectionAdd.Location = new Point(6, 72);
|
||||||
buttonAddExcavator.Location = new Point(6, 145);
|
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||||
buttonAddExcavator.Name = "buttonAddExcavator";
|
buttonCollectionAdd.Size = new Size(191, 38);
|
||||||
buttonAddExcavator.Size = new Size(200, 52);
|
buttonCollectionAdd.TabIndex = 4;
|
||||||
buttonAddExcavator.TabIndex = 2;
|
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||||
buttonAddExcavator.Text = "Добавить экскаватор с обвесами";
|
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAddExcavator.UseVisualStyleBackColor = true;
|
buttonCollectionAdd.Click += buttonCollectionAdd_Click;
|
||||||
buttonAddExcavator.Click += ButtonAddExcavator_Click;
|
|
||||||
//
|
//
|
||||||
// buttonAddSimpleExcavator
|
// radioButtonList
|
||||||
//
|
//
|
||||||
buttonAddSimpleExcavator.Location = new Point(6, 87);
|
radioButtonList.AutoSize = true;
|
||||||
buttonAddSimpleExcavator.Name = "buttonAddSimpleExcavator";
|
radioButtonList.Location = new Point(117, 49);
|
||||||
buttonAddSimpleExcavator.Size = new Size(200, 52);
|
radioButtonList.Name = "radioButtonList";
|
||||||
buttonAddSimpleExcavator.TabIndex = 1;
|
radioButtonList.Size = new Size(62, 17);
|
||||||
buttonAddSimpleExcavator.Text = "Добавить экскаватор";
|
radioButtonList.TabIndex = 3;
|
||||||
buttonAddSimpleExcavator.UseVisualStyleBackColor = true;
|
radioButtonList.TabStop = true;
|
||||||
buttonAddSimpleExcavator.Click += ButtonAddSimleExcavator_Click;
|
radioButtonList.Text = "Список";
|
||||||
|
radioButtonList.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// radioButtonMassive
|
||||||
|
//
|
||||||
|
radioButtonMassive.AutoSize = true;
|
||||||
|
radioButtonMassive.Location = new Point(19, 49);
|
||||||
|
radioButtonMassive.Name = "radioButtonMassive";
|
||||||
|
radioButtonMassive.Size = new Size(64, 17);
|
||||||
|
radioButtonMassive.TabIndex = 2;
|
||||||
|
radioButtonMassive.TabStop = true;
|
||||||
|
radioButtonMassive.Text = "Массив";
|
||||||
|
radioButtonMassive.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// labelCollectionName
|
||||||
|
//
|
||||||
|
labelCollectionName.AutoSize = true;
|
||||||
|
labelCollectionName.Location = new Point(46, 7);
|
||||||
|
labelCollectionName.Name = "labelCollectionName";
|
||||||
|
labelCollectionName.Size = new Size(117, 13);
|
||||||
|
labelCollectionName.TabIndex = 1;
|
||||||
|
labelCollectionName.Text = "Название коллекции:";
|
||||||
|
labelCollectionName.Click += labelCollectionName_Click;
|
||||||
|
//
|
||||||
|
// textBoxCollectionName
|
||||||
|
//
|
||||||
|
textBoxCollectionName.Location = new Point(6, 23);
|
||||||
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
|
textBoxCollectionName.Size = new Size(191, 20);
|
||||||
|
textBoxCollectionName.TabIndex = 0;
|
||||||
|
textBoxCollectionName.TextChanged += textBoxCollectionName_TextChanged;
|
||||||
//
|
//
|
||||||
// comboBoxSelectorCompany
|
// comboBoxSelectorCompany
|
||||||
//
|
//
|
||||||
@ -124,12 +166,84 @@
|
|||||||
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(12, 22);
|
comboBoxSelectorCompany.Location = new Point(9, 298);
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
comboBoxSelectorCompany.Size = new Size(194, 21);
|
comboBoxSelectorCompany.Size = new Size(191, 21);
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
|
// panelCompanyTools
|
||||||
|
//
|
||||||
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddSimpleExcavator);
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddExcavator);
|
||||||
|
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRemoveExcavator);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
|
panelCompanyTools.Location = new Point(6, 365);
|
||||||
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
|
panelCompanyTools.Size = new Size(200, 263);
|
||||||
|
panelCompanyTools.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonGoToCheck
|
||||||
|
//
|
||||||
|
buttonGoToCheck.Location = new Point(6, 164);
|
||||||
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
|
buttonGoToCheck.Size = new Size(191, 42);
|
||||||
|
buttonGoToCheck.TabIndex = 5;
|
||||||
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||||
|
//
|
||||||
|
// buttonAddSimpleExcavator
|
||||||
|
//
|
||||||
|
buttonAddSimpleExcavator.Location = new Point(3, 3);
|
||||||
|
buttonAddSimpleExcavator.Name = "buttonAddSimpleExcavator";
|
||||||
|
buttonAddSimpleExcavator.Size = new Size(191, 35);
|
||||||
|
buttonAddSimpleExcavator.TabIndex = 1;
|
||||||
|
buttonAddSimpleExcavator.Text = "Добавить экскаватор";
|
||||||
|
buttonAddSimpleExcavator.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddSimpleExcavator.Click += ButtonAddSimleExcavator_Click;
|
||||||
|
//
|
||||||
|
// buttonAddExcavator
|
||||||
|
//
|
||||||
|
buttonAddExcavator.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddExcavator.Location = new Point(3, 44);
|
||||||
|
buttonAddExcavator.Name = "buttonAddExcavator";
|
||||||
|
buttonAddExcavator.Size = new Size(191, 41);
|
||||||
|
buttonAddExcavator.TabIndex = 2;
|
||||||
|
buttonAddExcavator.Text = "Добавить экскаватор с обвесами";
|
||||||
|
buttonAddExcavator.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddExcavator.Click += ButtonAddExcavator_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
maskedTextBoxPosition.Location = new Point(3, 91);
|
||||||
|
maskedTextBoxPosition.Mask = "00";
|
||||||
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
maskedTextBoxPosition.Size = new Size(191, 20);
|
||||||
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonRemoveExcavator
|
||||||
|
//
|
||||||
|
buttonRemoveExcavator.Location = new Point(6, 117);
|
||||||
|
buttonRemoveExcavator.Name = "buttonRemoveExcavator";
|
||||||
|
buttonRemoveExcavator.Size = new Size(191, 41);
|
||||||
|
buttonRemoveExcavator.TabIndex = 4;
|
||||||
|
buttonRemoveExcavator.Text = "Удалить экскаватор";
|
||||||
|
buttonRemoveExcavator.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemoveExcavator.Click += ButtonRemoveExcavator_Click;
|
||||||
|
//
|
||||||
|
// buttonRefresh
|
||||||
|
//
|
||||||
|
buttonRefresh.Location = new Point(6, 212);
|
||||||
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
|
buttonRefresh.Size = new Size(191, 41);
|
||||||
|
buttonRefresh.TabIndex = 6;
|
||||||
|
buttonRefresh.Text = "Обновить";
|
||||||
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.AccessibleRole = AccessibleRole.None;
|
pictureBox.AccessibleRole = AccessibleRole.None;
|
||||||
@ -152,7 +266,10 @@
|
|||||||
Name = "FormExcavatorCollection";
|
Name = "FormExcavatorCollection";
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -168,5 +285,15 @@
|
|||||||
private Button buttonRemoveExcavator;
|
private Button buttonRemoveExcavator;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
private Button buttonRefresh;
|
private Button buttonRefresh;
|
||||||
|
private Panel panelStorage;
|
||||||
|
private Panel panelCompanyTools;
|
||||||
|
private TextBox textBoxCollectionName;
|
||||||
|
private Label labelCollectionName;
|
||||||
|
private Button buttonCollectionAdd;
|
||||||
|
private RadioButton radioButtonList;
|
||||||
|
private RadioButton radioButtonMassive;
|
||||||
|
private ListBox listBoxCollection;
|
||||||
|
private Button buttonCollectionDel;
|
||||||
|
private Button buttonCreateCompany;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,25 +1,22 @@
|
|||||||
using Excavator.CollectionGenericObjects;
|
using Excavator.CollectionGenericObjects;
|
||||||
using Excavator.Drawnings;
|
using Excavator.Drawnings;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Excavator;
|
namespace Excavator;
|
||||||
|
|
||||||
public partial class FormExcavatorCollection : Form
|
public partial class FormExcavatorCollection : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Хранилище коллекций
|
||||||
|
/// </summary>
|
||||||
|
private readonly StorageCollection<DrawningSimpleExcavator> _storageCollection;
|
||||||
|
|
||||||
private AbstractCompany? _company = null;
|
private AbstractCompany? _company = null;
|
||||||
|
|
||||||
public FormExcavatorCollection()
|
public FormExcavatorCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_storageCollection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBox_Click(object sender, EventArgs e)
|
private void pictureBox_Click(object sender, EventArgs e)
|
||||||
@ -28,12 +25,7 @@ public partial class FormExcavatorCollection : Form
|
|||||||
}
|
}
|
||||||
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 Garage(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningSimpleExcavator>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void CreateObject(string type)
|
private void CreateObject(string type)
|
||||||
{
|
{
|
||||||
@ -155,4 +147,99 @@ public partial class FormExcavatorCollection : Form
|
|||||||
|
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void textBoxCollectionName_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelCollectionName_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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<DrawningSimpleExcavator>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (collection == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не проинициализирована");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (comboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new Garage(pictureBox.Width, pictureBox.Height, collection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
panelCompanyTools.Enabled = true;
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user