Compare commits
No commits in common. "3d056750c8f9464086549ce4d9b5e27bd8d3e4c5" and "29edab25335ce2589d7a4649c38b20aa7cc4a69d" have entirely different histories.
3d056750c8
...
29edab2533
@ -1,18 +0,0 @@
|
|||||||
namespace ProjectLocomotive.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
public enum CollectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Неопределено
|
|
||||||
/// </summary>
|
|
||||||
None = 0,
|
|
||||||
/// <summary>
|
|
||||||
/// Массив
|
|
||||||
/// </summary>
|
|
||||||
Massive = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Список
|
|
||||||
/// </summary>
|
|
||||||
List = 2
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
namespace ProjectLocomotive.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Параметризованный набор объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,7 +22,7 @@ namespace ProjectLocomotive.CollectionGenericObjects
|
|||||||
int width = _pictureWidth / _placeSizeWidth;
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
Pen pen = new(Color.Black, 2);
|
Pen pen = new(Color.Black, 2);
|
||||||
for (int i = 0; i < width + 1; i++)
|
for (int i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < height + 1; ++j)
|
for (int j = 0; j < height + 1; ++j)
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ namespace ProjectLocomotive.CollectionGenericObjects
|
|||||||
int width = _pictureWidth / _placeSizeWidth;
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
|
||||||
int curWidth = 2;
|
int curWidth = 0;
|
||||||
int curHeight = 0;
|
int curHeight = 0;
|
||||||
|
|
||||||
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
||||||
@ -47,11 +47,11 @@ namespace ProjectLocomotive.CollectionGenericObjects
|
|||||||
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 10);
|
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curWidth > width - 2)
|
if (curWidth < width - 1)
|
||||||
curWidth--;
|
curWidth++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
curWidth = 2;
|
curWidth = 0;
|
||||||
curHeight ++;
|
curHeight ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
namespace ProjectLocomotive.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
// Класс-хранилище коллекций
|
|
||||||
/// </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,237 +29,63 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
buttonCreateCompany = new Button();
|
|
||||||
panelStorage = new Panel();
|
|
||||||
buttonCollectionDel = new Button();
|
|
||||||
listBoxCollection = new ListBox();
|
|
||||||
buttonCollecctionAdd = new Button();
|
|
||||||
radioButtonList = new RadioButton();
|
|
||||||
radioButtonMassive = new RadioButton();
|
|
||||||
textBoxCollectionName = new TextBox();
|
|
||||||
labelCollectionName = new Label();
|
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
|
||||||
panelCompanyTools = new Panel();
|
|
||||||
ButtonAddLocomotive = new Button();
|
|
||||||
ButtonAddTLocomotive = new Button();
|
|
||||||
buttonRefresh = new Button();
|
|
||||||
ButtonRemoveLocomotive = new Button();
|
|
||||||
maskedTextBoxPosision = new MaskedTextBox();
|
maskedTextBoxPosision = new MaskedTextBox();
|
||||||
|
buttonRefresh = new Button();
|
||||||
buttonGetToTest = new Button();
|
buttonGetToTest = new Button();
|
||||||
|
ButtonRemoveLocomotive = new Button();
|
||||||
|
ButtonAddTLocomotive = new Button();
|
||||||
|
ButtonAddLocomotive = new Button();
|
||||||
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
pictureBoxLocomotive = new PictureBox();
|
pictureBoxLocomotive = new PictureBox();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
panelStorage.SuspendLayout();
|
|
||||||
panelCompanyTools.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
groupBoxTools.Controls.Add(buttonCreateCompany);
|
groupBoxTools.Controls.Add(maskedTextBoxPosision);
|
||||||
groupBoxTools.Controls.Add(panelStorage);
|
groupBoxTools.Controls.Add(buttonRefresh);
|
||||||
|
groupBoxTools.Controls.Add(buttonGetToTest);
|
||||||
|
groupBoxTools.Controls.Add(ButtonRemoveLocomotive);
|
||||||
|
groupBoxTools.Controls.Add(ButtonAddTLocomotive);
|
||||||
|
groupBoxTools.Controls.Add(ButtonAddLocomotive);
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBoxTools.Controls.Add(panelCompanyTools);
|
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(536, 0);
|
groupBoxTools.Location = new Point(522, 0);
|
||||||
groupBoxTools.Margin = new Padding(3, 2, 3, 2);
|
groupBoxTools.Margin = new Padding(3, 2, 3, 2);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Padding = new Padding(3, 2, 3, 2);
|
groupBoxTools.Padding = new Padding(3, 2, 3, 2);
|
||||||
groupBoxTools.Size = new Size(215, 490);
|
groupBoxTools.Size = new Size(194, 430);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "инструменты";
|
groupBoxTools.Text = "инструменты";
|
||||||
//
|
//
|
||||||
// buttonCreateCompany
|
// maskedTextBoxPosision
|
||||||
//
|
//
|
||||||
buttonCreateCompany.Location = new Point(18, 259);
|
maskedTextBoxPosision.Location = new Point(18, 172);
|
||||||
buttonCreateCompany.Margin = new Padding(3, 2, 3, 2);
|
maskedTextBoxPosision.Margin = new Padding(3, 2, 3, 2);
|
||||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
maskedTextBoxPosision.Mask = "00";
|
||||||
buttonCreateCompany.Size = new Size(163, 20);
|
maskedTextBoxPosision.Name = "maskedTextBoxPosision";
|
||||||
buttonCreateCompany.TabIndex = 7;
|
maskedTextBoxPosision.Size = new Size(163, 23);
|
||||||
buttonCreateCompany.Text = "Создать компанию";
|
maskedTextBoxPosision.TabIndex = 2;
|
||||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
maskedTextBoxPosision.ValidatingType = typeof(int);
|
||||||
buttonCreateCompany.Click += ButtonCreateCompany_Click;
|
|
||||||
//
|
|
||||||
// panelStorage
|
|
||||||
//
|
|
||||||
panelStorage.Controls.Add(buttonCollectionDel);
|
|
||||||
panelStorage.Controls.Add(listBoxCollection);
|
|
||||||
panelStorage.Controls.Add(buttonCollecctionAdd);
|
|
||||||
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, 18);
|
|
||||||
panelStorage.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
panelStorage.Name = "panelStorage";
|
|
||||||
panelStorage.Size = new Size(209, 212);
|
|
||||||
panelStorage.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// buttonCollectionDel
|
|
||||||
//
|
|
||||||
buttonCollectionDel.Location = new Point(15, 185);
|
|
||||||
buttonCollectionDel.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
|
||||||
buttonCollectionDel.Size = new Size(163, 20);
|
|
||||||
buttonCollectionDel.TabIndex = 6;
|
|
||||||
buttonCollectionDel.Text = "Удалить коллекцию";
|
|
||||||
buttonCollectionDel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCollectionDel.Click += ButtonCollectionDel_Click;
|
|
||||||
//
|
|
||||||
// listBoxCollection
|
|
||||||
//
|
|
||||||
listBoxCollection.FormattingEnabled = true;
|
|
||||||
listBoxCollection.ItemHeight = 15;
|
|
||||||
listBoxCollection.Location = new Point(15, 103);
|
|
||||||
listBoxCollection.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
listBoxCollection.Name = "listBoxCollection";
|
|
||||||
listBoxCollection.Size = new Size(163, 79);
|
|
||||||
listBoxCollection.TabIndex = 5;
|
|
||||||
listBoxCollection.SelectedIndexChanged += listBoxCollection_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// buttonCollecctionAdd
|
|
||||||
//
|
|
||||||
buttonCollecctionAdd.Location = new Point(15, 78);
|
|
||||||
buttonCollecctionAdd.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCollecctionAdd.Name = "buttonCollecctionAdd";
|
|
||||||
buttonCollecctionAdd.Size = new Size(163, 20);
|
|
||||||
buttonCollecctionAdd.TabIndex = 4;
|
|
||||||
buttonCollecctionAdd.Text = "Добавить коллекцию";
|
|
||||||
buttonCollecctionAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonCollecctionAdd.Click += ButtonCollecctionAdd_Click;
|
|
||||||
//
|
|
||||||
// radioButtonList
|
|
||||||
//
|
|
||||||
radioButtonList.AutoSize = true;
|
|
||||||
radioButtonList.Location = new Point(108, 56);
|
|
||||||
radioButtonList.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
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(15, 56);
|
|
||||||
radioButtonMassive.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
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(15, 24);
|
|
||||||
textBoxCollectionName.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
|
||||||
textBoxCollectionName.Size = new Size(163, 23);
|
|
||||||
textBoxCollectionName.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// labelCollectionName
|
|
||||||
//
|
|
||||||
labelCollectionName.AutoSize = true;
|
|
||||||
labelCollectionName.Location = new Point(23, 7);
|
|
||||||
labelCollectionName.Name = "labelCollectionName";
|
|
||||||
labelCollectionName.Size = new Size(122, 15);
|
|
||||||
labelCollectionName.TabIndex = 0;
|
|
||||||
labelCollectionName.Text = "Название коллекции";
|
|
||||||
//
|
|
||||||
// comboBoxSelectorCompany
|
|
||||||
//
|
|
||||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
|
||||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
|
||||||
comboBoxSelectorCompany.Location = new Point(18, 233);
|
|
||||||
comboBoxSelectorCompany.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
|
||||||
comboBoxSelectorCompany.Size = new Size(163, 23);
|
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
|
|
||||||
//
|
|
||||||
// panelCompanyTools
|
|
||||||
//
|
|
||||||
panelCompanyTools.Controls.Add(ButtonAddLocomotive);
|
|
||||||
panelCompanyTools.Controls.Add(ButtonAddTLocomotive);
|
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
|
||||||
panelCompanyTools.Controls.Add(ButtonRemoveLocomotive);
|
|
||||||
panelCompanyTools.Controls.Add(maskedTextBoxPosision);
|
|
||||||
panelCompanyTools.Controls.Add(buttonGetToTest);
|
|
||||||
panelCompanyTools.Enabled = false;
|
|
||||||
panelCompanyTools.Location = new Point(3, 284);
|
|
||||||
panelCompanyTools.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
|
||||||
panelCompanyTools.Size = new Size(189, 206);
|
|
||||||
panelCompanyTools.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// ButtonAddLocomotive
|
|
||||||
//
|
|
||||||
ButtonAddLocomotive.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
ButtonAddLocomotive.BackgroundImageLayout = ImageLayout.Center;
|
|
||||||
ButtonAddLocomotive.Location = new Point(16, 2);
|
|
||||||
ButtonAddLocomotive.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
ButtonAddLocomotive.Name = "ButtonAddLocomotive";
|
|
||||||
ButtonAddLocomotive.Size = new Size(163, 30);
|
|
||||||
ButtonAddLocomotive.TabIndex = 1;
|
|
||||||
ButtonAddLocomotive.Text = "добваление поезда";
|
|
||||||
ButtonAddLocomotive.UseVisualStyleBackColor = true;
|
|
||||||
ButtonAddLocomotive.Click += ButtonAddLocomotive_Click;
|
|
||||||
//
|
|
||||||
// ButtonAddTLocomotive
|
|
||||||
//
|
|
||||||
ButtonAddTLocomotive.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
ButtonAddTLocomotive.Location = new Point(16, 37);
|
|
||||||
ButtonAddTLocomotive.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
ButtonAddTLocomotive.Name = "ButtonAddTLocomotive";
|
|
||||||
ButtonAddTLocomotive.Size = new Size(163, 38);
|
|
||||||
ButtonAddTLocomotive.TabIndex = 2;
|
|
||||||
ButtonAddTLocomotive.Text = "добваление тепловоза";
|
|
||||||
ButtonAddTLocomotive.UseVisualStyleBackColor = true;
|
|
||||||
ButtonAddTLocomotive.Click += ButtonAddTLocomotive_Click;
|
|
||||||
//
|
//
|
||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonRefresh.Location = new Point(16, 170);
|
buttonRefresh.Location = new Point(18, 359);
|
||||||
buttonRefresh.Margin = new Padding(3, 2, 3, 2);
|
buttonRefresh.Margin = new Padding(3, 2, 3, 2);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(163, 31);
|
buttonRefresh.Size = new Size(163, 30);
|
||||||
buttonRefresh.TabIndex = 5;
|
buttonRefresh.TabIndex = 5;
|
||||||
buttonRefresh.Text = "обновить";
|
buttonRefresh.Text = "обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
//
|
//
|
||||||
// ButtonRemoveLocomotive
|
|
||||||
//
|
|
||||||
ButtonRemoveLocomotive.Anchor = AnchorStyles.Right;
|
|
||||||
ButtonRemoveLocomotive.Location = new Point(16, 104);
|
|
||||||
ButtonRemoveLocomotive.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive";
|
|
||||||
ButtonRemoveLocomotive.Size = new Size(163, 30);
|
|
||||||
ButtonRemoveLocomotive.TabIndex = 3;
|
|
||||||
ButtonRemoveLocomotive.Text = "удалить поезд";
|
|
||||||
ButtonRemoveLocomotive.UseVisualStyleBackColor = true;
|
|
||||||
ButtonRemoveLocomotive.Click += ButtonRemoveLocomotive_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosision
|
|
||||||
//
|
|
||||||
maskedTextBoxPosision.Location = new Point(15, 79);
|
|
||||||
maskedTextBoxPosision.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
maskedTextBoxPosision.Mask = "00";
|
|
||||||
maskedTextBoxPosision.Name = "maskedTextBoxPosision";
|
|
||||||
maskedTextBoxPosision.Size = new Size(164, 23);
|
|
||||||
maskedTextBoxPosision.TabIndex = 2;
|
|
||||||
maskedTextBoxPosision.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// buttonGetToTest
|
// buttonGetToTest
|
||||||
//
|
//
|
||||||
buttonGetToTest.Anchor = AnchorStyles.Right;
|
buttonGetToTest.Anchor = AnchorStyles.Right;
|
||||||
buttonGetToTest.Location = new Point(16, 138);
|
buttonGetToTest.Location = new Point(18, 274);
|
||||||
buttonGetToTest.Margin = new Padding(3, 2, 3, 2);
|
buttonGetToTest.Margin = new Padding(3, 2, 3, 2);
|
||||||
buttonGetToTest.Name = "buttonGetToTest";
|
buttonGetToTest.Name = "buttonGetToTest";
|
||||||
buttonGetToTest.Size = new Size(163, 30);
|
buttonGetToTest.Size = new Size(163, 30);
|
||||||
@ -268,13 +94,62 @@
|
|||||||
buttonGetToTest.UseVisualStyleBackColor = true;
|
buttonGetToTest.UseVisualStyleBackColor = true;
|
||||||
buttonGetToTest.Click += ButtonGetToTest_Click;
|
buttonGetToTest.Click += ButtonGetToTest_Click;
|
||||||
//
|
//
|
||||||
|
// ButtonRemoveLocomotive
|
||||||
|
//
|
||||||
|
ButtonRemoveLocomotive.Anchor = AnchorStyles.Right;
|
||||||
|
ButtonRemoveLocomotive.Location = new Point(18, 203);
|
||||||
|
ButtonRemoveLocomotive.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive";
|
||||||
|
ButtonRemoveLocomotive.Size = new Size(163, 30);
|
||||||
|
ButtonRemoveLocomotive.TabIndex = 3;
|
||||||
|
ButtonRemoveLocomotive.Text = "удалить поезд";
|
||||||
|
ButtonRemoveLocomotive.UseVisualStyleBackColor = true;
|
||||||
|
ButtonRemoveLocomotive.Click += ButtonRemoveLocomotive_Click;
|
||||||
|
//
|
||||||
|
// ButtonAddTLocomotive
|
||||||
|
//
|
||||||
|
ButtonAddTLocomotive.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
ButtonAddTLocomotive.Location = new Point(18, 114);
|
||||||
|
ButtonAddTLocomotive.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonAddTLocomotive.Name = "ButtonAddTLocomotive";
|
||||||
|
ButtonAddTLocomotive.Size = new Size(163, 38);
|
||||||
|
ButtonAddTLocomotive.TabIndex = 2;
|
||||||
|
ButtonAddTLocomotive.Text = "добваление тепловоза";
|
||||||
|
ButtonAddTLocomotive.UseVisualStyleBackColor = true;
|
||||||
|
ButtonAddTLocomotive.Click += ButtonAddTLocomotive_Click;
|
||||||
|
//
|
||||||
|
// ButtonAddLocomotive
|
||||||
|
//
|
||||||
|
ButtonAddLocomotive.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
ButtonAddLocomotive.BackgroundImageLayout = ImageLayout.Center;
|
||||||
|
ButtonAddLocomotive.Location = new Point(18, 80);
|
||||||
|
ButtonAddLocomotive.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonAddLocomotive.Name = "ButtonAddLocomotive";
|
||||||
|
ButtonAddLocomotive.Size = new Size(163, 30);
|
||||||
|
ButtonAddLocomotive.TabIndex = 1;
|
||||||
|
ButtonAddLocomotive.Text = "добваление поезда";
|
||||||
|
ButtonAddLocomotive.UseVisualStyleBackColor = true;
|
||||||
|
ButtonAddLocomotive.Click += ButtonAddLocomotive_Click;
|
||||||
|
//
|
||||||
|
// comboBoxSelectorCompany
|
||||||
|
//
|
||||||
|
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||||
|
comboBoxSelectorCompany.Items.AddRange(new object[] { "хранилище" });
|
||||||
|
comboBoxSelectorCompany.Location = new Point(18, 20);
|
||||||
|
comboBoxSelectorCompany.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
|
comboBoxSelectorCompany.Size = new Size(163, 23);
|
||||||
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
|
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
|
||||||
|
//
|
||||||
// pictureBoxLocomotive
|
// pictureBoxLocomotive
|
||||||
//
|
//
|
||||||
pictureBoxLocomotive.Dock = DockStyle.Fill;
|
pictureBoxLocomotive.Dock = DockStyle.Fill;
|
||||||
pictureBoxLocomotive.Location = new Point(0, 0);
|
pictureBoxLocomotive.Location = new Point(0, 0);
|
||||||
pictureBoxLocomotive.Margin = new Padding(3, 2, 3, 2);
|
pictureBoxLocomotive.Margin = new Padding(3, 2, 3, 2);
|
||||||
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
||||||
pictureBoxLocomotive.Size = new Size(536, 490);
|
pictureBoxLocomotive.Size = new Size(522, 430);
|
||||||
pictureBoxLocomotive.TabIndex = 1;
|
pictureBoxLocomotive.TabIndex = 1;
|
||||||
pictureBoxLocomotive.TabStop = false;
|
pictureBoxLocomotive.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -282,17 +157,14 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(751, 490);
|
ClientSize = new Size(716, 430);
|
||||||
Controls.Add(pictureBoxLocomotive);
|
Controls.Add(pictureBoxLocomotive);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
Name = "FormLocomotivesCollection";
|
Name = "FormLocomotivesCollection";
|
||||||
Text = "FormLocomotivesCollection";
|
Text = "FormLocomotivesCollection";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
panelStorage.ResumeLayout(false);
|
groupBoxTools.PerformLayout();
|
||||||
panelStorage.PerformLayout();
|
|
||||||
panelCompanyTools.ResumeLayout(false);
|
|
||||||
panelCompanyTools.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
@ -308,15 +180,5 @@
|
|||||||
private Button buttonGetToTest;
|
private Button buttonGetToTest;
|
||||||
private PictureBox pictureBoxLocomotive;
|
private PictureBox pictureBoxLocomotive;
|
||||||
private MaskedTextBox maskedTextBoxPosision;
|
private MaskedTextBox maskedTextBoxPosision;
|
||||||
private Panel panelStorage;
|
|
||||||
private TextBox textBoxCollectionName;
|
|
||||||
private Label labelCollectionName;
|
|
||||||
private ListBox listBoxCollection;
|
|
||||||
private Button buttonCollecctionAdd;
|
|
||||||
private RadioButton radioButtonList;
|
|
||||||
private RadioButton radioButtonMassive;
|
|
||||||
private Button buttonCreateCompany;
|
|
||||||
private Button buttonCollectionDel;
|
|
||||||
private Panel panelCompanyTools;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,23 +5,16 @@ namespace ProjectLocomotive
|
|||||||
{
|
{
|
||||||
public partial class FormLocomotivesCollection : Form
|
public partial class FormLocomotivesCollection : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Хранилише коллекций
|
|
||||||
/// </summary>
|
|
||||||
private readonly StorageCollection<DrawningLocomotive> _storageCollection;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Компания
|
/// Компания
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AbstractCompany? _company = null;
|
private AbstractCompany? _company = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormLocomotivesCollection()
|
public FormLocomotivesCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_storageCollection = new();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -31,7 +24,13 @@ namespace ProjectLocomotive
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
|
private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
panelCompanyTools.Enabled = false;
|
switch (comboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "хранилище":
|
||||||
|
_company = new LocomotiveDockingService(pictureBoxLocomotive.Width,
|
||||||
|
pictureBoxLocomotive.Height, new MassiveGenericObjects<DrawningLocomotive>());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -52,22 +51,23 @@ namespace ProjectLocomotive
|
|||||||
drawningLocomotive = new DrawningLocomotive(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
|
drawningLocomotive = new DrawningLocomotive(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
|
||||||
break;
|
break;
|
||||||
case nameof(DrawningTLocomotive):
|
case nameof(DrawningTLocomotive):
|
||||||
// TODO вызов диалогового окна для выбора цвета
|
|
||||||
drawningLocomotive = new DrawningTLocomotive(random.Next(100, 300), random.Next(1000, 3000),
|
drawningLocomotive = new DrawningTLocomotive(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
GetColor(random), GetColor(random),
|
GetColor(random),
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
GetColor(random),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_company + drawningLocomotive != -1)
|
if (_company + drawningLocomotive != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("объект добавлен");
|
||||||
pictureBoxLocomotive.Image = _company.Show();
|
pictureBoxLocomotive.Image = _company.Show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("не удалось добавить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,100 +164,6 @@ namespace ProjectLocomotive
|
|||||||
pictureBoxLocomotive.Image = _company.Show();
|
pictureBoxLocomotive.Image = _company.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCollecctionAdd_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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <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<DrawningLocomotive>? collection =
|
|
||||||
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция не проинициализирована");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (comboBoxSelectorCompany.Text)
|
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new LocomotiveDockingService(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height, collection);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
panelCompanyTools.Enabled = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void listBoxCollection_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user