Compare commits
No commits in common. "052b9929c1bb5d3c4817bec6d2047e30928bd35c" and "50146d6d1bc99f1ca3bbab090ed99e4edf74ff4a" have entirely different histories.
052b9929c1
...
50146d6d1b
@ -48,7 +48,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
||||
{
|
||||
return company.arr?.Remove(position);
|
||||
return company.arr?.Remove(position) ?? null;
|
||||
}
|
||||
|
||||
public DrawningTrackedVehicle? GetRandomObject()
|
||||
|
@ -18,14 +18,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
Array.Resize(ref arr, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
arr = new T?[value];
|
||||
}
|
||||
arr = new T?[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,7 +33,14 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
|
||||
public int Insert(T obj)
|
||||
{
|
||||
return Insert(obj, 0);
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (arr[i] == null)
|
||||
{
|
||||
return Insert(obj, 0);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
|
@ -27,12 +27,17 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||
// TODO Прописать логику для добавления
|
||||
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>();
|
||||
if (!string.IsNullOrEmpty(name) && !Keys.Contains(name))
|
||||
{
|
||||
if(collectionType == CollectionType.Massive)
|
||||
{
|
||||
dict.Add(name, new MassivGenericObjects<T> ());
|
||||
}
|
||||
if(collectionType == CollectionType.List)
|
||||
{
|
||||
dict.Add(name, new ListGenericObjects<T> ());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление коллекции
|
||||
@ -57,8 +62,10 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения объекта
|
||||
if (dict.ContainsKey(name))
|
||||
return dict[name];
|
||||
if (dict.TryGetValue(name, out ICollectionGenericObjects<T>? result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
buttonCreateCompany = new Button();
|
||||
panelCompanyTool = new Panel();
|
||||
buttonCreateCompany = new Button();
|
||||
buttonRefresh = new Button();
|
||||
buttonGoToChek = new Button();
|
||||
buttonCreateHoistingCrane = new Button();
|
||||
@ -67,16 +67,6 @@
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Location = new Point(12, 288);
|
||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||
buttonCreateCompany.Size = new Size(196, 23);
|
||||
buttonCreateCompany.TabIndex = 7;
|
||||
buttonCreateCompany.Text = "Создать компанию";
|
||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||
buttonCreateCompany.Click += buttonCreateCompany_Click;
|
||||
//
|
||||
// panelCompanyTool
|
||||
//
|
||||
panelCompanyTool.Anchor = AnchorStyles.None;
|
||||
@ -86,12 +76,21 @@
|
||||
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;
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Location = new Point(12, 288);
|
||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||
buttonCreateCompany.Size = new Size(196, 23);
|
||||
buttonCreateCompany.TabIndex = 7;
|
||||
buttonCreateCompany.Text = "Создать компанию";
|
||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||
buttonCreateCompany.Click += buttonCreateCompany_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
@ -205,7 +204,7 @@
|
||||
radioButtonList.AutoSize = true;
|
||||
radioButtonList.Location = new Point(128, 56);
|
||||
radioButtonList.Name = "radioButtonList";
|
||||
radioButtonList.Size = new Size(66, 19);
|
||||
radioButtonList.Size = new Size(67, 19);
|
||||
radioButtonList.TabIndex = 3;
|
||||
radioButtonList.TabStop = true;
|
||||
radioButtonList.Text = "Список";
|
||||
@ -216,7 +215,7 @@
|
||||
radioButtonMassive.AutoSize = true;
|
||||
radioButtonMassive.Location = new Point(18, 56);
|
||||
radioButtonMassive.Name = "radioButtonMassive";
|
||||
radioButtonMassive.Size = new Size(67, 19);
|
||||
radioButtonMassive.Size = new Size(69, 19);
|
||||
radioButtonMassive.TabIndex = 2;
|
||||
radioButtonMassive.TabStop = true;
|
||||
radioButtonMassive.Text = "Массив";
|
||||
@ -234,7 +233,7 @@
|
||||
labelCollectionName.AutoSize = true;
|
||||
labelCollectionName.Location = new Point(35, 0);
|
||||
labelCollectionName.Name = "labelCollectionName";
|
||||
labelCollectionName.Size = new Size(125, 15);
|
||||
labelCollectionName.Size = new Size(135, 15);
|
||||
labelCollectionName.TabIndex = 0;
|
||||
labelCollectionName.Text = "Название коллекции:";
|
||||
//
|
||||
|
@ -1,24 +1,32 @@
|
||||
using HoistingCrane.CollectionGenericObjects;
|
||||
using HoistingCrane.Drawning;
|
||||
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 HoistingCrane
|
||||
{
|
||||
public partial class FormCarCollection : Form
|
||||
{
|
||||
private AbstractCompany? _company = null;
|
||||
private AbstractCompany? _company;
|
||||
|
||||
private readonly StorageCollection<DrawningTrackedVehicle> _storageCollection;
|
||||
|
||||
public FormCarCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storageCollection = new();
|
||||
panelCompanyTool.Enabled = false;
|
||||
}
|
||||
|
||||
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
panelCompanyTool.Enabled = false;
|
||||
}
|
||||
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
DrawningTrackedVehicle drawning;
|
||||
@ -138,26 +146,19 @@ namespace HoistingCrane
|
||||
{
|
||||
collectionType = CollectionType.List;
|
||||
}
|
||||
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
||||
_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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user