Борюсь с конфликтами
This commit is contained in:
parent
ad565c92f3
commit
f51c2c348f
@ -47,7 +47,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
}
|
}
|
||||||
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
||||||
{
|
{
|
||||||
return company.arr?.Remove(position) ?? null;
|
return company.arr?.Remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawningTrackedVehicle? GetRandomObject()
|
public DrawningTrackedVehicle? GetRandomObject()
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
namespace HoistingCrane.CollectionGenericObjects
|
||||||
|
{
|
||||||
|
public enum CollectionType
|
||||||
|
{
|
||||||
|
None = 0, Massive = 1, List = 2
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,6 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetObjectsPosition()
|
protected override void SetObjectsPosition()
|
||||||
{
|
{
|
||||||
int countWidth = pictureWidth / _placeSizeWidth;
|
int countWidth = pictureWidth / _placeSizeWidth;
|
||||||
|
@ -30,6 +30,11 @@
|
|||||||
/// <param name="position"></param>
|
/// <param name="position"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
T? Remove(int position);
|
T? Remove(int position);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объекта коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
T? Get(int position);
|
T? Get(int position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.CodeDom.Compiler;
|
||||||
|
using System.Windows.Forms.VisualStyles;
|
||||||
|
|
||||||
|
namespace HoistingCrane.CollectionGenericObjects
|
||||||
|
{
|
||||||
|
public class ListGenericObjects<T> : ICollectionGenericObjects<T> where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Список объектов, которые храним
|
||||||
|
/// </summary>
|
||||||
|
readonly List<T> list;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public ListGenericObjects()
|
||||||
|
{
|
||||||
|
list = new List<T>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Максимально допустимое число объектов в списке
|
||||||
|
/// </summary>
|
||||||
|
private int _maxCount;
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get { return list.Count; }
|
||||||
|
}
|
||||||
|
public int SetMaxCount
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(value > 0)
|
||||||
|
{
|
||||||
|
_maxCount = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Get(int position)
|
||||||
|
{
|
||||||
|
if (position >= Count || position < 0) return null;
|
||||||
|
return list[position];
|
||||||
|
}
|
||||||
|
public int Insert(T obj)
|
||||||
|
{
|
||||||
|
if (Count == _maxCount)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
list.Add(obj);
|
||||||
|
return Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj, int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count || Count == _maxCount)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
list.Insert(position, obj);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
public T? Remove(int position)
|
||||||
|
{
|
||||||
|
if(position >= 0 && position < list.Count)
|
||||||
|
{
|
||||||
|
T? temp = list[position];
|
||||||
|
list.RemoveAt(position);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -45,28 +45,33 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
|
|
||||||
public int Insert(T obj, int position)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
//todo Проверка позиции
|
|
||||||
if (position < 0 || position > Count)
|
if (position < 0 || position >= Count)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int copyPos = position - 1;
|
||||||
|
|
||||||
|
while (position < Count)
|
||||||
|
{
|
||||||
if (arr[position] == null)
|
if (arr[position] == null)
|
||||||
{
|
{
|
||||||
arr[position] = obj;
|
arr[position] = obj;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
else
|
position++;
|
||||||
{
|
|
||||||
if (Insert(obj, position + 1) != -1)
|
|
||||||
{
|
|
||||||
return position;
|
|
||||||
}
|
}
|
||||||
if (Insert(obj, position - 1) != -1)
|
while (copyPos > 0)
|
||||||
{
|
{
|
||||||
return position;
|
if (arr[copyPos] == null)
|
||||||
|
{
|
||||||
|
arr[copyPos] = obj;
|
||||||
|
return copyPos;
|
||||||
}
|
}
|
||||||
|
copyPos--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
namespace HoistingCrane.CollectionGenericObjects
|
||||||
|
{
|
||||||
|
public class StorageCollection<T> where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь (хранилище) с коллекциями
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, ICollectionGenericObjects<T>> dict;
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий коллекций
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => dict.Keys.ToList();
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public StorageCollection()
|
||||||
|
{
|
||||||
|
dict = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление коллекции в хранилище
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <param name="collectionType">тип коллекции</param>
|
||||||
|
public void AddCollection(string name, CollectionType collectionType)
|
||||||
|
{
|
||||||
|
if (dict.ContainsKey(name)) return;
|
||||||
|
if (collectionType == CollectionType.None) return;
|
||||||
|
else if (collectionType == CollectionType.Massive)
|
||||||
|
dict[name] = new MassivGenericObjects<T>();
|
||||||
|
else if (collectionType == CollectionType.List)
|
||||||
|
dict[name] = new ListGenericObjects<T>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
public void DelCollection(string name)
|
||||||
|
{
|
||||||
|
if(Keys.Contains(name))
|
||||||
|
{
|
||||||
|
dict.Remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ICollectionGenericObjects<T>? this[string name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (dict.ContainsKey(name))
|
||||||
|
return dict[name];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,63 +29,119 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
buttonGoToChek = new Button();
|
buttonCreateCompany = new Button();
|
||||||
|
panelCompanyTool = new Panel();
|
||||||
buttonRefresh = new Button();
|
buttonRefresh = new Button();
|
||||||
|
buttonGoToChek = new Button();
|
||||||
|
buttonCreateHoistingCrane = new Button();
|
||||||
|
buttonCreateTrackedVehicle = new Button();
|
||||||
buttonDeleteCar = new Button();
|
buttonDeleteCar = new Button();
|
||||||
maskedTextBox = new MaskedTextBox();
|
maskedTextBox = new MaskedTextBox();
|
||||||
|
panelStorage = new Panel();
|
||||||
|
buttonDeleteCollection = new Button();
|
||||||
|
listBoxCollection = new ListBox();
|
||||||
|
buttonCollectionAdd = new Button();
|
||||||
|
radioButtonList = new RadioButton();
|
||||||
|
radioButtonMassive = new RadioButton();
|
||||||
|
textBoxCollectionName = new TextBox();
|
||||||
|
labelCollectionName = new Label();
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
buttonCreateTrackedVehicle = new Button();
|
|
||||||
buttonCreateHoistingCrane = new Button();
|
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
|
panelCompanyTool.SuspendLayout();
|
||||||
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
groupBoxTools.Controls.Add(buttonGoToChek);
|
groupBoxTools.Controls.Add(buttonCreateCompany);
|
||||||
groupBoxTools.Controls.Add(buttonRefresh);
|
groupBoxTools.Controls.Add(panelCompanyTool);
|
||||||
groupBoxTools.Controls.Add(buttonDeleteCar);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(maskedTextBox);
|
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBoxTools.Controls.Add(buttonCreateTrackedVehicle);
|
|
||||||
groupBoxTools.Controls.Add(buttonCreateHoistingCrane);
|
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(716, 0);
|
groupBoxTools.Location = new Point(759, 0);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(210, 450);
|
groupBoxTools.Size = new Size(214, 509);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// buttonGoToChek
|
// buttonCreateCompany
|
||||||
//
|
//
|
||||||
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonCreateCompany.Location = new Point(12, 288);
|
||||||
buttonGoToChek.Location = new Point(12, 298);
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
buttonGoToChek.Name = "buttonGoToChek";
|
buttonCreateCompany.Size = new Size(196, 23);
|
||||||
buttonGoToChek.Size = new Size(192, 34);
|
buttonCreateCompany.TabIndex = 7;
|
||||||
buttonGoToChek.TabIndex = 6;
|
buttonCreateCompany.Text = "Создать компанию";
|
||||||
buttonGoToChek.Text = "Передать на тесты";
|
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||||
buttonGoToChek.UseVisualStyleBackColor = true;
|
buttonCreateCompany.Click += buttonCreateCompany_Click;
|
||||||
buttonGoToChek.Click += buttonGoToChek_Click;
|
//
|
||||||
|
// panelCompanyTool
|
||||||
|
//
|
||||||
|
panelCompanyTool.Anchor = AnchorStyles.None;
|
||||||
|
panelCompanyTool.Controls.Add(buttonRefresh);
|
||||||
|
panelCompanyTool.Controls.Add(buttonGoToChek);
|
||||||
|
panelCompanyTool.Controls.Add(buttonCreateHoistingCrane);
|
||||||
|
panelCompanyTool.Controls.Add(buttonCreateTrackedVehicle);
|
||||||
|
panelCompanyTool.Controls.Add(buttonDeleteCar);
|
||||||
|
panelCompanyTool.Controls.Add(maskedTextBox);
|
||||||
|
panelCompanyTool.Enabled = false;
|
||||||
|
panelCompanyTool.Location = new Point(3, 317);
|
||||||
|
panelCompanyTool.Name = "panelCompanyTool";
|
||||||
|
panelCompanyTool.Size = new Size(208, 238);
|
||||||
|
panelCompanyTool.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRefresh.Location = new Point(12, 375);
|
buttonRefresh.Location = new Point(9, 159);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(192, 34);
|
buttonRefresh.Size = new Size(196, 27);
|
||||||
buttonRefresh.TabIndex = 5;
|
buttonRefresh.TabIndex = 5;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += buttonRefresh_Click;
|
buttonRefresh.Click += buttonRefresh_Click;
|
||||||
//
|
//
|
||||||
|
// buttonGoToChek
|
||||||
|
//
|
||||||
|
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonGoToChek.Location = new Point(9, 119);
|
||||||
|
buttonGoToChek.Name = "buttonGoToChek";
|
||||||
|
buttonGoToChek.Size = new Size(196, 24);
|
||||||
|
buttonGoToChek.TabIndex = 6;
|
||||||
|
buttonGoToChek.Text = "Передать на тесты";
|
||||||
|
buttonGoToChek.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToChek.Click += buttonGoToChek_Click;
|
||||||
|
//
|
||||||
|
// buttonCreateHoistingCrane
|
||||||
|
//
|
||||||
|
buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonCreateHoistingCrane.Location = new Point(9, 3);
|
||||||
|
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
|
||||||
|
buttonCreateHoistingCrane.Size = new Size(196, 22);
|
||||||
|
buttonCreateHoistingCrane.TabIndex = 0;
|
||||||
|
buttonCreateHoistingCrane.Text = "Добавить подъемный кран";
|
||||||
|
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
|
||||||
|
//
|
||||||
|
// buttonCreateTrackedVehicle
|
||||||
|
//
|
||||||
|
buttonCreateTrackedVehicle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonCreateTrackedVehicle.Location = new Point(9, 31);
|
||||||
|
buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle";
|
||||||
|
buttonCreateTrackedVehicle.Size = new Size(196, 24);
|
||||||
|
buttonCreateTrackedVehicle.TabIndex = 1;
|
||||||
|
buttonCreateTrackedVehicle.Text = "Добавить гусеничную машину";
|
||||||
|
buttonCreateTrackedVehicle.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateTrackedVehicle.Click += buttonCreateTrackedVehicle_Click;
|
||||||
|
//
|
||||||
// buttonDeleteCar
|
// buttonDeleteCar
|
||||||
//
|
//
|
||||||
buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonDeleteCar.Location = new Point(12, 233);
|
buttonDeleteCar.Location = new Point(9, 90);
|
||||||
buttonDeleteCar.Name = "buttonDeleteCar";
|
buttonDeleteCar.Name = "buttonDeleteCar";
|
||||||
buttonDeleteCar.Size = new Size(192, 34);
|
buttonDeleteCar.Size = new Size(196, 23);
|
||||||
buttonDeleteCar.TabIndex = 4;
|
buttonDeleteCar.TabIndex = 4;
|
||||||
buttonDeleteCar.Text = "Удалить автомобиль";
|
buttonDeleteCar.Text = "Удалить автомобиль";
|
||||||
buttonDeleteCar.UseVisualStyleBackColor = true;
|
buttonDeleteCar.UseVisualStyleBackColor = true;
|
||||||
@ -94,52 +150,112 @@
|
|||||||
// maskedTextBox
|
// maskedTextBox
|
||||||
//
|
//
|
||||||
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
maskedTextBox.Location = new Point(12, 204);
|
maskedTextBox.Location = new Point(9, 61);
|
||||||
maskedTextBox.Mask = "00";
|
maskedTextBox.Mask = "00";
|
||||||
maskedTextBox.Name = "maskedTextBox";
|
maskedTextBox.Name = "maskedTextBox";
|
||||||
maskedTextBox.Size = new Size(192, 23);
|
maskedTextBox.Size = new Size(196, 23);
|
||||||
maskedTextBox.TabIndex = 3;
|
maskedTextBox.TabIndex = 3;
|
||||||
//
|
//
|
||||||
|
// panelStorage
|
||||||
|
//
|
||||||
|
panelStorage.Controls.Add(buttonDeleteCollection);
|
||||||
|
panelStorage.Controls.Add(listBoxCollection);
|
||||||
|
panelStorage.Controls.Add(buttonCollectionAdd);
|
||||||
|
panelStorage.Controls.Add(radioButtonList);
|
||||||
|
panelStorage.Controls.Add(radioButtonMassive);
|
||||||
|
panelStorage.Controls.Add(textBoxCollectionName);
|
||||||
|
panelStorage.Controls.Add(labelCollectionName);
|
||||||
|
panelStorage.Dock = DockStyle.Top;
|
||||||
|
panelStorage.Location = new Point(3, 19);
|
||||||
|
panelStorage.Name = "panelStorage";
|
||||||
|
panelStorage.Size = new Size(208, 229);
|
||||||
|
panelStorage.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonDeleteCollection
|
||||||
|
//
|
||||||
|
buttonDeleteCollection.Location = new Point(9, 199);
|
||||||
|
buttonDeleteCollection.Name = "buttonDeleteCollection";
|
||||||
|
buttonDeleteCollection.Size = new Size(192, 27);
|
||||||
|
buttonDeleteCollection.TabIndex = 6;
|
||||||
|
buttonDeleteCollection.Text = "Удалить коллекцию";
|
||||||
|
buttonDeleteCollection.UseVisualStyleBackColor = true;
|
||||||
|
buttonDeleteCollection.Click += buttonDeleteCollection_Click;
|
||||||
|
//
|
||||||
|
// listBoxCollection
|
||||||
|
//
|
||||||
|
listBoxCollection.FormattingEnabled = true;
|
||||||
|
listBoxCollection.ItemHeight = 15;
|
||||||
|
listBoxCollection.Location = new Point(9, 118);
|
||||||
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
|
listBoxCollection.Size = new Size(192, 79);
|
||||||
|
listBoxCollection.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonCollectionAdd
|
||||||
|
//
|
||||||
|
buttonCollectionAdd.Location = new Point(9, 81);
|
||||||
|
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||||
|
buttonCollectionAdd.Size = new Size(192, 23);
|
||||||
|
buttonCollectionAdd.TabIndex = 4;
|
||||||
|
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||||
|
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonCollectionAdd.Click += buttonCollectionAdd_Click;
|
||||||
|
//
|
||||||
|
// radioButtonList
|
||||||
|
//
|
||||||
|
radioButtonList.AutoSize = true;
|
||||||
|
radioButtonList.Location = new Point(128, 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(18, 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(9, 18);
|
||||||
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
|
textBoxCollectionName.Size = new Size(192, 23);
|
||||||
|
textBoxCollectionName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCollectionName
|
||||||
|
//
|
||||||
|
labelCollectionName.AutoSize = true;
|
||||||
|
labelCollectionName.Location = new Point(35, 0);
|
||||||
|
labelCollectionName.Name = "labelCollectionName";
|
||||||
|
labelCollectionName.Size = new Size(125, 15);
|
||||||
|
labelCollectionName.TabIndex = 0;
|
||||||
|
labelCollectionName.Text = "Название коллекции:";
|
||||||
|
//
|
||||||
// comboBoxSelectorCompany
|
// comboBoxSelectorCompany
|
||||||
//
|
//
|
||||||
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
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, 28);
|
comboBoxSelectorCompany.Location = new Point(12, 259);
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
comboBoxSelectorCompany.Size = new Size(192, 23);
|
comboBoxSelectorCompany.Size = new Size(196, 23);
|
||||||
comboBoxSelectorCompany.TabIndex = 2;
|
comboBoxSelectorCompany.TabIndex = 2;
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
|
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
//
|
|
||||||
// buttonCreateTrackedVehicle
|
|
||||||
//
|
|
||||||
buttonCreateTrackedVehicle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonCreateTrackedVehicle.Location = new Point(12, 129);
|
|
||||||
buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle";
|
|
||||||
buttonCreateTrackedVehicle.Size = new Size(192, 34);
|
|
||||||
buttonCreateTrackedVehicle.TabIndex = 1;
|
|
||||||
buttonCreateTrackedVehicle.Text = "Добавить гусеничную машину";
|
|
||||||
buttonCreateTrackedVehicle.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateTrackedVehicle.Click += buttonCreateTrackedVehicle_Click;
|
|
||||||
//
|
|
||||||
// buttonCreateHoistingCrane
|
|
||||||
//
|
|
||||||
buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonCreateHoistingCrane.Location = new Point(12, 89);
|
|
||||||
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
|
|
||||||
buttonCreateHoistingCrane.Size = new Size(192, 34);
|
|
||||||
buttonCreateHoistingCrane.TabIndex = 0;
|
|
||||||
buttonCreateHoistingCrane.Text = "Добавить подъемный кран";
|
|
||||||
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
|
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 0);
|
pictureBox.Location = new Point(0, 0);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(716, 450);
|
pictureBox.Size = new Size(759, 509);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -147,13 +263,16 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(926, 450);
|
ClientSize = new Size(973, 509);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Name = "FormCarCollection";
|
Name = "FormCarCollection";
|
||||||
Text = "FormCarCollections";
|
Text = "FormCarCollections";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
groupBoxTools.PerformLayout();
|
panelCompanyTool.ResumeLayout(false);
|
||||||
|
panelCompanyTool.PerformLayout();
|
||||||
|
panelStorage.ResumeLayout(false);
|
||||||
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
@ -169,5 +288,15 @@
|
|||||||
private MaskedTextBox maskedTextBox;
|
private MaskedTextBox maskedTextBox;
|
||||||
private PictureBox pictureBox;
|
private PictureBox pictureBox;
|
||||||
private Button buttonGoToChek;
|
private Button buttonGoToChek;
|
||||||
|
private Panel panelStorage;
|
||||||
|
private RadioButton radioButtonList;
|
||||||
|
private RadioButton radioButtonMassive;
|
||||||
|
private TextBox textBoxCollectionName;
|
||||||
|
private Label labelCollectionName;
|
||||||
|
private Button buttonCreateCompany;
|
||||||
|
private Button buttonDeleteCollection;
|
||||||
|
private ListBox listBoxCollection;
|
||||||
|
private Button buttonCollectionAdd;
|
||||||
|
private Panel panelCompanyTool;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,20 +4,19 @@ namespace HoistingCrane
|
|||||||
{
|
{
|
||||||
public partial class FormCarCollection : Form
|
public partial class FormCarCollection : Form
|
||||||
{
|
{
|
||||||
private AbstractCompany? _company;
|
private AbstractCompany? _company = null;
|
||||||
|
|
||||||
|
private readonly StorageCollection<DrawningTrackedVehicle> _storageCollection;
|
||||||
|
|
||||||
public FormCarCollection()
|
public FormCarCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_storageCollection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
|
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (comboBoxSelectorCompany.Text)
|
panelCompanyTool.Enabled = false;
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new Garage(pictureBox.Width, pictureBox.Height, new MassivGenericObjects<DrawningTrackedVehicle>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateObject(string type)
|
private void CreateObject(string type)
|
||||||
@ -27,7 +26,6 @@ namespace HoistingCrane
|
|||||||
Random rand = new();
|
Random rand = new();
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|
||||||
case nameof(DrawningHoistingCrane):
|
case nameof(DrawningHoistingCrane):
|
||||||
drawning = new DrawningHoistingCrane(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand), GetColor(rand), true, true);
|
drawning = new DrawningHoistingCrane(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand), GetColor(rand), true, true);
|
||||||
break;
|
break;
|
||||||
@ -48,7 +46,6 @@ namespace HoistingCrane
|
|||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color GetColor(Random random)
|
private static Color GetColor(Random random)
|
||||||
{
|
{
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
@ -59,13 +56,10 @@ namespace HoistingCrane
|
|||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane));
|
private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane));
|
||||||
|
|
||||||
|
|
||||||
private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle));
|
private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle));
|
||||||
|
|
||||||
|
|
||||||
private void buttonDeleteCar_Click(object sender, EventArgs e)
|
private void buttonDeleteCar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -88,13 +82,11 @@ namespace HoistingCrane
|
|||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null) return;
|
if (_company == null) return;
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonGoToChek_Click(object sender, EventArgs e)
|
private void buttonGoToChek_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null) return;
|
if (_company == null) return;
|
||||||
@ -112,7 +104,85 @@ namespace HoistingCrane
|
|||||||
SetCar = car
|
SetCar = car
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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();
|
||||||
|
}
|
||||||
|
private void buttonDeleteCollection_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// TODO прописать логику удаления элемента из коллекции
|
||||||
|
// нужно убедиться, что есть выбранная коллекция
|
||||||
|
// спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись
|
||||||
|
// удалить и обновить ListBox
|
||||||
|
|
||||||
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
private void buttonCreateCompany_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ICollectionGenericObjects<DrawningTrackedVehicle>? 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;
|
||||||
|
}
|
||||||
|
panelCompanyTool.Enabled = true;
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user