Лаба4

This commit is contained in:
sqdselo 2024-04-14 21:43:46 +04:00
parent 52b3bc2a87
commit 50146d6d1b
4 changed files with 158 additions and 175 deletions

View File

@ -39,12 +39,9 @@ namespace HoistingCrane.CollectionGenericObjects
public T? Get(int position) public T? Get(int position)
{ {
// TODO проверка позиции // TODO проверка позиции
if(position >= 0 && position < _maxCount) if (position >= Count || position < 0) return null;
{
return list[position]; return list[position];
} }
return null;
}
public int Insert(T obj) public int Insert(T obj)
@ -70,10 +67,7 @@ namespace HoistingCrane.CollectionGenericObjects
} }
list.Insert(position, obj); list.Insert(position, obj);
return position; return position;
} }
public T? Remove(int position) public T? Remove(int position)
{ {
// TODO проверка позиции // TODO проверка позиции

View File

@ -69,6 +69,7 @@ namespace HoistingCrane.CollectionGenericObjects
return null; return null;
} }
} }
} }
} }

View File

@ -29,75 +29,118 @@
private void InitializeComponent() private void InitializeComponent()
{ {
groupBoxTools = new GroupBox(); groupBoxTools = new GroupBox();
buttonGoToChek = new Button(); panelCompanyTool = new Panel();
buttonCreateCompany = new Button();
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();
comboBoxSelectorCompany = new ComboBox();
buttonCreateTrackedVehicle = new Button();
buttonCreateHoistingCrane = new Button();
pictureBox = new PictureBox();
panelStorage = new Panel(); panelStorage = new Panel();
labelCollectionName = new Label();
textBoxCollectionName = new TextBox();
radioButtonMassive = new RadioButton();
radioButtonList = new RadioButton();
buttonCollectionAdd = new Button();
listBoxCollection = new ListBox();
buttonDeleteCollection = new Button(); buttonDeleteCollection = new Button();
buttonCreateCompany = new Button(); listBoxCollection = new ListBox();
buttonCollectionAdd = new Button();
radioButtonList = new RadioButton();
radioButtonMassive = new RadioButton();
textBoxCollectionName = new TextBox();
labelCollectionName = new Label();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout(); groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); panelCompanyTool.SuspendLayout();
panelStorage.SuspendLayout(); panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// groupBoxTools // groupBoxTools
// //
groupBoxTools.Controls.Add(buttonCreateCompany); groupBoxTools.Controls.Add(buttonCreateCompany);
groupBoxTools.Controls.Add(panelCompanyTool);
groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(buttonGoToChek);
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonDeleteCar);
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(763, 0); groupBoxTools.Location = new Point(759, 0);
groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(210, 509); groupBoxTools.Size = new Size(214, 509);
groupBoxTools.TabIndex = 0; groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false; groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты"; groupBoxTools.Text = "Инструменты";
// //
// buttonGoToChek // panelCompanyTool
// //
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; panelCompanyTool.Anchor = AnchorStyles.None;
buttonGoToChek.Location = new Point(12, 440); panelCompanyTool.Controls.Add(buttonRefresh);
buttonGoToChek.Name = "buttonGoToChek"; panelCompanyTool.Controls.Add(buttonGoToChek);
buttonGoToChek.Size = new Size(192, 24); panelCompanyTool.Controls.Add(buttonCreateHoistingCrane);
buttonGoToChek.TabIndex = 6; panelCompanyTool.Controls.Add(buttonCreateTrackedVehicle);
buttonGoToChek.Text = "Передать на тесты"; panelCompanyTool.Controls.Add(buttonDeleteCar);
buttonGoToChek.UseVisualStyleBackColor = true; panelCompanyTool.Controls.Add(maskedTextBox);
buttonGoToChek.Click += buttonGoToChek_Click; 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
// //
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(12, 470); buttonRefresh.Location = new Point(9, 159);
buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(192, 27); 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, 411); buttonDeleteCar.Location = new Point(9, 90);
buttonDeleteCar.Name = "buttonDeleteCar"; buttonDeleteCar.Name = "buttonDeleteCar";
buttonDeleteCar.Size = new Size(192, 23); buttonDeleteCar.Size = new Size(196, 23);
buttonDeleteCar.TabIndex = 4; buttonDeleteCar.TabIndex = 4;
buttonDeleteCar.Text = "Удалить автомобиль"; buttonDeleteCar.Text = "Удалить автомобиль";
buttonDeleteCar.UseVisualStyleBackColor = true; buttonDeleteCar.UseVisualStyleBackColor = true;
@ -106,55 +149,12 @@
// maskedTextBox // maskedTextBox
// //
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBox.Location = new Point(12, 382); 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;
// //
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(12, 266);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(192, 23);
comboBoxSelectorCompany.TabIndex = 2;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
//
// buttonCreateTrackedVehicle
//
buttonCreateTrackedVehicle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCreateTrackedVehicle.Location = new Point(12, 352);
buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle";
buttonCreateTrackedVehicle.Size = new Size(192, 24);
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, 324);
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
buttonCreateHoistingCrane.Size = new Size(192, 22);
buttonCreateHoistingCrane.TabIndex = 0;
buttonCreateHoistingCrane.Text = "Добавить подъемный кран";
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(763, 509);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// panelStorage // panelStorage
// //
panelStorage.Controls.Add(buttonDeleteCollection); panelStorage.Controls.Add(buttonDeleteCollection);
@ -167,35 +167,37 @@
panelStorage.Dock = DockStyle.Top; panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 19); panelStorage.Location = new Point(3, 19);
panelStorage.Name = "panelStorage"; panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(204, 229); panelStorage.Size = new Size(208, 229);
panelStorage.TabIndex = 7; panelStorage.TabIndex = 7;
// //
// labelCollectionName // buttonDeleteCollection
// //
labelCollectionName.AutoSize = true; buttonDeleteCollection.Location = new Point(9, 199);
labelCollectionName.Location = new Point(35, 0); buttonDeleteCollection.Name = "buttonDeleteCollection";
labelCollectionName.Name = "labelCollectionName"; buttonDeleteCollection.Size = new Size(192, 27);
labelCollectionName.Size = new Size(135, 15); buttonDeleteCollection.TabIndex = 6;
labelCollectionName.TabIndex = 0; buttonDeleteCollection.Text = "Удалить коллекцию";
labelCollectionName.Text = "Название коллекции:"; buttonDeleteCollection.UseVisualStyleBackColor = true;
buttonDeleteCollection.Click += buttonDeleteCollection_Click;
// //
// textBoxCollectionName // listBoxCollection
// //
textBoxCollectionName.Location = new Point(9, 18); listBoxCollection.FormattingEnabled = true;
textBoxCollectionName.Name = "textBoxCollectionName"; listBoxCollection.ItemHeight = 15;
textBoxCollectionName.Size = new Size(192, 23); listBoxCollection.Location = new Point(9, 118);
textBoxCollectionName.TabIndex = 1; listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(192, 79);
listBoxCollection.TabIndex = 5;
// //
// radioButtonMassive // buttonCollectionAdd
// //
radioButtonMassive.AutoSize = true; buttonCollectionAdd.Location = new Point(9, 81);
radioButtonMassive.Location = new Point(18, 56); buttonCollectionAdd.Name = "buttonCollectionAdd";
radioButtonMassive.Name = "radioButtonMassive"; buttonCollectionAdd.Size = new Size(192, 23);
radioButtonMassive.Size = new Size(69, 19); buttonCollectionAdd.TabIndex = 4;
radioButtonMassive.TabIndex = 2; buttonCollectionAdd.Text = "Добавить коллекцию";
radioButtonMassive.TabStop = true; buttonCollectionAdd.UseVisualStyleBackColor = true;
radioButtonMassive.Text = "Массив"; buttonCollectionAdd.Click += buttonCollectionAdd_Click;
radioButtonMassive.UseVisualStyleBackColor = true;
// //
// radioButtonList // radioButtonList
// //
@ -208,44 +210,53 @@
radioButtonList.Text = "Список"; radioButtonList.Text = "Список";
radioButtonList.UseVisualStyleBackColor = true; radioButtonList.UseVisualStyleBackColor = true;
// //
// buttonCollectionAdd // radioButtonMassive
// //
buttonCollectionAdd.Location = new Point(9, 81); radioButtonMassive.AutoSize = true;
buttonCollectionAdd.Name = "buttonCollectionAdd"; radioButtonMassive.Location = new Point(18, 56);
buttonCollectionAdd.Size = new Size(192, 23); radioButtonMassive.Name = "radioButtonMassive";
buttonCollectionAdd.TabIndex = 4; radioButtonMassive.Size = new Size(69, 19);
buttonCollectionAdd.Text = "Добавить коллекцию"; radioButtonMassive.TabIndex = 2;
buttonCollectionAdd.UseVisualStyleBackColor = true; radioButtonMassive.TabStop = true;
buttonCollectionAdd.Click += buttonCollectionAdd_Click; radioButtonMassive.Text = "Массив";
radioButtonMassive.UseVisualStyleBackColor = true;
// //
// listBoxCollection // textBoxCollectionName
// //
listBoxCollection.FormattingEnabled = true; textBoxCollectionName.Location = new Point(9, 18);
listBoxCollection.ItemHeight = 15; textBoxCollectionName.Name = "textBoxCollectionName";
listBoxCollection.Location = new Point(9, 118); textBoxCollectionName.Size = new Size(192, 23);
listBoxCollection.Name = "listBoxCollection"; textBoxCollectionName.TabIndex = 1;
listBoxCollection.Size = new Size(192, 79);
listBoxCollection.TabIndex = 5;
// //
// buttonDeleteCollection // labelCollectionName
// //
buttonDeleteCollection.Location = new Point(9, 199); labelCollectionName.AutoSize = true;
buttonDeleteCollection.Name = "buttonDeleteCollection"; labelCollectionName.Location = new Point(35, 0);
buttonDeleteCollection.Size = new Size(192, 27); labelCollectionName.Name = "labelCollectionName";
buttonDeleteCollection.TabIndex = 6; labelCollectionName.Size = new Size(135, 15);
buttonDeleteCollection.Text = "Удалить коллекцию"; labelCollectionName.TabIndex = 0;
buttonDeleteCollection.UseVisualStyleBackColor = true; labelCollectionName.Text = "Название коллекции:";
buttonDeleteCollection.Click += buttonDeleteCollection_Click;
// //
// buttonCreateCompany // comboBoxSelectorCompany
// //
buttonCreateCompany.Location = new Point(12, 295); comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCreateCompany.Name = "buttonCreateCompany"; comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
buttonCreateCompany.Size = new Size(192, 23); comboBoxSelectorCompany.FormattingEnabled = true;
buttonCreateCompany.TabIndex = 7; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
buttonCreateCompany.Text = "Создать компанию"; comboBoxSelectorCompany.Location = new Point(12, 259);
buttonCreateCompany.UseVisualStyleBackColor = true; comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
buttonCreateCompany.Click += buttonCreateCompany_Click; comboBoxSelectorCompany.Size = new Size(196, 23);
comboBoxSelectorCompany.TabIndex = 2;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(759, 509);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
// //
// FormCarCollection // FormCarCollection
// //
@ -257,10 +268,11 @@
Name = "FormCarCollection"; Name = "FormCarCollection";
Text = "FormCarCollections"; Text = "FormCarCollections";
groupBoxTools.ResumeLayout(false); groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout(); panelCompanyTool.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); panelCompanyTool.PerformLayout();
panelStorage.ResumeLayout(false); panelStorage.ResumeLayout(false);
panelStorage.PerformLayout(); panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }
@ -284,5 +296,6 @@
private Button buttonDeleteCollection; private Button buttonDeleteCollection;
private ListBox listBoxCollection; private ListBox listBoxCollection;
private Button buttonCollectionAdd; private Button buttonCollectionAdd;
private Panel panelCompanyTool;
} }
} }

View File

@ -21,19 +21,12 @@ namespace HoistingCrane
{ {
InitializeComponent(); InitializeComponent();
_storageCollection = new(); _storageCollection = new();
panelCompanyTool.Enabled = false;
} }
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
private void comboBoxSelectorCompany_SelectedIndexChanged_1(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)
{ {
DrawningTrackedVehicle drawning; DrawningTrackedVehicle drawning;
@ -41,7 +34,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;
@ -62,7 +54,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));
@ -73,15 +64,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)
{ {
@ -104,13 +90,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;
@ -128,7 +112,6 @@ namespace HoistingCrane
SetCar = car SetCar = car
}; };
form.ShowDialog(); form.ShowDialog();
} }
/// <summary> /// <summary>
@ -146,10 +129,9 @@ namespace HoistingCrane
} }
} }
} }
private void buttonCollectionAdd_Click(object sender, EventArgs e) private void buttonCollectionAdd_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxCollectionName.Text) ||(!radioButtonList.Checked && !radioButtonMassive.Checked)) if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
{ {
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBox.Show("Не все данные заполнены", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
@ -168,25 +150,18 @@ namespace HoistingCrane
collectionType); collectionType);
RerfreshListBoxItems(); RerfreshListBoxItems();
} }
private void buttonDeleteCollection_Click(object sender, EventArgs e) private void buttonDeleteCollection_Click(object sender, EventArgs e)
{ {
// TODO прописать логику удаления элемента из коллекции
// нужно убедиться, что есть выбранная коллекция
// спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись
// удалить и обновить ListBox
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
{ {
MessageBox.Show("Коллекция не выбрана"); MessageBox.Show("Коллекция не выбрана");
return; return;
} }
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return; return;
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
RerfreshListBoxItems(); RerfreshListBoxItems();
} }
private void buttonCreateCompany_Click(object sender, EventArgs e) private void buttonCreateCompany_Click(object sender, EventArgs e)
{ {
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
@ -206,7 +181,7 @@ namespace HoistingCrane
_company = new Garage(pictureBox.Width, pictureBox.Height, collection); _company = new Garage(pictureBox.Width, pictureBox.Height, collection);
break; break;
} }
panelStorage.Enabled = true; panelCompanyTool.Enabled = true;
RerfreshListBoxItems(); RerfreshListBoxItems();
} }
} }