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(); groupBoxTools = new GroupBox();
panelCompanyTools = new Panel(); panelCompanyTools = new Panel();
buttonSortByColor = new Button();
buttonSortByType = new Button();
buttonAddAirPlane = new Button(); buttonAddAirPlane = new Button();
maskedTextBox = new MaskedTextBox(); maskedTextBox = new MaskedTextBox();
buttonRefresh = new Button(); buttonRefresh = new Button();
@ -52,15 +54,11 @@
loadToolStripMenuItem = new ToolStripMenuItem(); loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog(); saveFileDialog = new SaveFileDialog();
openFileDialog = new OpenFileDialog(); openFileDialog = new OpenFileDialog();
buttonSortByColor = new Button();
buttonSortByType = new Button();
pictureBox1 = new PictureBox();
groupBoxTools.SuspendLayout(); groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout(); panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout(); panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// groupBoxTools // groupBoxTools
@ -92,6 +90,26 @@
panelCompanyTools.Size = new Size(184, 339); panelCompanyTools.Size = new Size(184, 339);
panelCompanyTools.TabIndex = 8; 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
// //
buttonAddAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonAddAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -205,7 +223,7 @@
// radioButtonList // radioButtonList
// //
radioButtonList.AutoSize = true; radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(88, 72); radioButtonList.Location = new Point(84, 72);
radioButtonList.Margin = new Padding(3, 2, 3, 2); radioButtonList.Margin = new Padding(3, 2, 3, 2);
radioButtonList.Name = "radioButtonList"; radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19); radioButtonList.Size = new Size(66, 19);
@ -305,41 +323,11 @@
// //
openFileDialog.Filter = "txt file | *.txt"; 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 // FormAirPlaneCollection
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(960, 659); ClientSize = new Size(960, 659);
Controls.Add(pictureBox1);
Controls.Add(menuStrip); Controls.Add(menuStrip);
Controls.Add(pictureBox); Controls.Add(pictureBox);
Controls.Add(groupBoxTools); Controls.Add(groupBoxTools);
@ -354,7 +342,6 @@
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
menuStrip.ResumeLayout(false); menuStrip.ResumeLayout(false);
menuStrip.PerformLayout(); menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
@ -387,6 +374,5 @@
private OpenFileDialog openFileDialog; private OpenFileDialog openFileDialog;
private Button buttonSortByColor; private Button buttonSortByColor;
private Button buttonSortByType; private Button buttonSortByType;
private PictureBox pictureBox1;
} }
} }

View File

@ -94,24 +94,11 @@ public partial class FormAirPlaneCollection : Form
MessageBox.Show("В коллекции превышено допустимое количество элементов"); MessageBox.Show("В коллекции превышено допустимое количество элементов");
_logger.LogError("Ошибка: {Message}", ex.Message); _logger.LogError("Ошибка: {Message}", ex.Message);
} }
catch (ObjectIsEqualException ex)
}
/// <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)
{ {
color = dialog.Color; MessageBox.Show("Такой объект уже существует в коллекции");
_logger.LogError("Ошибка: {Message}", ex.Message);
} }
return color;
} }
/// <summary> /// <summary>
@ -260,12 +247,22 @@ public partial class FormAirPlaneCollection : Form
MessageBox.Show("Коллекция не выбрана"); MessageBox.Show("Коллекция не выбрана");
return; 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()); catch (Exception ex)
RefreshListBoxItems(); {
_logger.LogError("Ошибка: {Message}", ex.Message);
}
} }
/// <summary> /// <summary>
/// Создание компании /// Создание компании
@ -349,7 +346,7 @@ public partial class FormAirPlaneCollection : Form
private void buttonSortByType_Click(object sender, EventArgs e) private void buttonSortByType_Click(object sender, EventArgs e)
{ {
CompareAirPlane(new DrawningAirPlaneCompareByType());
} }
private void buttonSortByColor_Click(object sender, EventArgs e) private void buttonSortByColor_Click(object sender, EventArgs e)