This commit is contained in:
Darl1ngzxc 2024-06-05 13:22:48 +04:00
parent e971b264e6
commit 84e4affbde
2 changed files with 41 additions and 58 deletions

View File

@ -30,6 +30,8 @@
{
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonSortByColor = new Button();
buttonSortByType = new Button();
buttonAddAirPlane = new Button();
maskedTextBox = new MaskedTextBox();
buttonRefresh = new Button();
@ -52,15 +54,11 @@
loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog();
openFileDialog = new OpenFileDialog();
buttonSortByColor = new Button();
buttonSortByType = new Button();
pictureBox1 = new PictureBox();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
// groupBoxTools
@ -92,6 +90,26 @@
panelCompanyTools.Size = new Size(184, 339);
panelCompanyTools.TabIndex = 8;
//
// buttonSortByColor
//
buttonSortByColor.Location = new Point(6, 295);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(175, 37);
buttonSortByColor.TabIndex = 9;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += buttonSortByColor_Click;
//
// buttonSortByType
//
buttonSortByType.Location = new Point(6, 255);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(175, 38);
buttonSortByType.TabIndex = 8;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += buttonSortByType_Click;
//
// buttonAddAirPlane
//
buttonAddAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -205,7 +223,7 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(88, 72);
radioButtonList.Location = new Point(84, 72);
radioButtonList.Margin = new Padding(3, 2, 3, 2);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19);
@ -305,41 +323,11 @@
//
openFileDialog.Filter = "txt file | *.txt";
//
// buttonSortByColor
//
buttonSortByColor.Location = new Point(6, 295);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(175, 37);
buttonSortByColor.TabIndex = 9;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += buttonSortByColor_Click;
//
// buttonSortByType
//
buttonSortByType.Location = new Point(6, 255);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(175, 38);
buttonSortByType.TabIndex = 8;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += buttonSortByType_Click;
//
// pictureBox1
//
pictureBox1.Dock = DockStyle.Fill;
pictureBox1.Location = new Point(0, 24);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(752, 635);
pictureBox1.TabIndex = 7;
pictureBox1.TabStop = false;
//
// FormAirPlaneCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(960, 659);
Controls.Add(pictureBox1);
Controls.Add(menuStrip);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
@ -354,7 +342,6 @@
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
ResumeLayout(false);
PerformLayout();
}
@ -387,6 +374,5 @@
private OpenFileDialog openFileDialog;
private Button buttonSortByColor;
private Button buttonSortByType;
private PictureBox pictureBox1;
}
}

View File

@ -94,24 +94,11 @@ public partial class FormAirPlaneCollection : Form
MessageBox.Show("В коллекции превышено допустимое количество элементов");
_logger.LogError("Ошибка: {Message}", ex.Message);
}
}
/// <summary>
/// Получение цвета
/// </summary>
/// <param name="random">Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
catch (ObjectIsEqualException ex)
{
color = dialog.Color;
MessageBox.Show("Такой объект уже существует в коллекции");
_logger.LogError("Ошибка: {Message}", ex.Message);
}
return color;
}
/// <summary>
@ -260,12 +247,22 @@ public partial class FormAirPlaneCollection : Form
MessageBox.Show("Коллекция не выбрана");
return;
}
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
try
{
return;
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
RefreshListBoxItems();
_logger.LogInformation("Удалена коллекция: ", listBoxCollection.SelectedItem.ToString());
}
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
RefreshListBoxItems();
catch (Exception ex)
{
_logger.LogError("Ошибка: {Message}", ex.Message);
}
}
/// <summary>
/// Создание компании
@ -349,7 +346,7 @@ public partial class FormAirPlaneCollection : Form
private void buttonSortByType_Click(object sender, EventArgs e)
{
CompareAirPlane(new DrawningAirPlaneCompareByType());
}
private void buttonSortByColor_Click(object sender, EventArgs e)