PIbd-22. Stroev V.M. Lab Work 08 #10

Closed
StroevVladimir wants to merge 4 commits from Lab08 into Lab07
4 changed files with 46 additions and 60 deletions
Showing only changes of commit a677485840 - Show all commits

View File

@ -57,10 +57,9 @@
// //
// pictureBoxCollection // pictureBoxCollection
// //
pictureBoxCollection.Location = new Point(6, 39); pictureBoxCollection.Location = new Point(5, 31);
pictureBoxCollection.Margin = new Padding(4);
pictureBoxCollection.Name = "pictureBoxCollection"; pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(1271, 606); pictureBoxCollection.Size = new Size(1017, 485);
pictureBoxCollection.TabIndex = 5; pictureBoxCollection.TabIndex = 5;
pictureBoxCollection.TabStop = false; pictureBoxCollection.TabStop = false;
// //
@ -75,33 +74,32 @@
panel1.Controls.Add(buttonDelMonorail); panel1.Controls.Add(buttonDelMonorail);
panel1.Controls.Add(buttonAddMonorail); panel1.Controls.Add(buttonAddMonorail);
panel1.Controls.Add(label1); panel1.Controls.Add(label1);
panel1.Location = new Point(1281, -1); panel1.Location = new Point(1025, -1);
panel1.Margin = new Padding(4);
panel1.Name = "panel1"; panel1.Name = "panel1";
panel1.Size = new Size(255, 646); panel1.Size = new Size(204, 517);
panel1.TabIndex = 4; panel1.TabIndex = 4;
// //
// ButtonSortByColor // ButtonSortByColor
// //
ButtonSortByColor.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); ButtonSortByColor.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point);
ButtonSortByColor.Location = new Point(15, 366); ButtonSortByColor.Location = new Point(12, 293);
ButtonSortByColor.Margin = new Padding(4);
ButtonSortByColor.Name = "ButtonSortByColor"; ButtonSortByColor.Name = "ButtonSortByColor";
ButtonSortByColor.Size = new Size(224, 51); ButtonSortByColor.Size = new Size(179, 41);
ButtonSortByColor.TabIndex = 9; ButtonSortByColor.TabIndex = 9;
ButtonSortByColor.Text = "Сортировка по цвету"; ButtonSortByColor.Text = "Сортировка по цвету";
ButtonSortByColor.UseVisualStyleBackColor = true; ButtonSortByColor.UseVisualStyleBackColor = true;
ButtonSortByColor.Click += ButtonSortByColor_Click;
// //
// ButtonSortByType // ButtonSortByType
// //
ButtonSortByType.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); ButtonSortByType.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point);
ButtonSortByType.Location = new Point(15, 307); ButtonSortByType.Location = new Point(12, 246);
ButtonSortByType.Margin = new Padding(4);
ButtonSortByType.Name = "ButtonSortByType"; ButtonSortByType.Name = "ButtonSortByType";
ButtonSortByType.Size = new Size(224, 51); ButtonSortByType.Size = new Size(179, 41);
ButtonSortByType.TabIndex = 8; ButtonSortByType.TabIndex = 8;
ButtonSortByType.Text = "Сортировка по типу"; ButtonSortByType.Text = "Сортировка по типу";
ButtonSortByType.UseVisualStyleBackColor = true; ButtonSortByType.UseVisualStyleBackColor = true;
ButtonSortByType.Click += ButtonSortByType_Click;
// //
// panel2 // panel2
// //
@ -110,48 +108,43 @@
panel2.Controls.Add(textBoxStorageName); panel2.Controls.Add(textBoxStorageName);
panel2.Controls.Add(button1); panel2.Controls.Add(button1);
panel2.Controls.Add(ButtonAddObject); panel2.Controls.Add(ButtonAddObject);
panel2.Location = new Point(15, 25); panel2.Location = new Point(12, 20);
panel2.Margin = new Padding(4);
panel2.Name = "panel2"; panel2.Name = "panel2";
panel2.Size = new Size(224, 261); panel2.Size = new Size(179, 209);
panel2.TabIndex = 7; panel2.TabIndex = 7;
// //
// label2 // label2
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(4, -4); label2.Location = new Point(3, -3);
label2.Margin = new Padding(4, 0, 4, 0);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(79, 25); label2.Size = new Size(66, 20);
label2.TabIndex = 8; label2.TabIndex = 8;
label2.Text = "Наборы"; label2.Text = "Наборы";
// //
// listBoxStorages // listBoxStorages
// //
listBoxStorages.FormattingEnabled = true; listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 25; listBoxStorages.ItemHeight = 20;
listBoxStorages.Location = new Point(21, 106); listBoxStorages.Location = new Point(17, 85);
listBoxStorages.Margin = new Padding(4);
listBoxStorages.Name = "listBoxStorages"; listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(179, 104); listBoxStorages.Size = new Size(144, 84);
listBoxStorages.TabIndex = 9; listBoxStorages.TabIndex = 9;
listBoxStorages.Click += ListBoxObjects_SelectedIndexChanged; listBoxStorages.Click += ListBoxObjects_SelectedIndexChanged;
// //
// textBoxStorageName // textBoxStorageName
// //
textBoxStorageName.Location = new Point(21, 25); textBoxStorageName.Location = new Point(17, 20);
textBoxStorageName.Margin = new Padding(4);
textBoxStorageName.Name = "textBoxStorageName"; textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(178, 31); textBoxStorageName.Size = new Size(143, 27);
textBoxStorageName.TabIndex = 8; textBoxStorageName.TabIndex = 8;
// //
// button1 // button1
// //
button1.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); button1.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point);
button1.Location = new Point(20, 218); button1.Location = new Point(16, 174);
button1.Margin = new Padding(4);
button1.Name = "button1"; button1.Name = "button1";
button1.Size = new Size(179, 33); button1.Size = new Size(143, 26);
button1.TabIndex = 5; button1.TabIndex = 5;
button1.Text = "Удалить набор"; button1.Text = "Удалить набор";
button1.UseVisualStyleBackColor = true; button1.UseVisualStyleBackColor = true;
@ -160,10 +153,9 @@
// ButtonAddObject // ButtonAddObject
// //
ButtonAddObject.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); ButtonAddObject.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point);
ButtonAddObject.Location = new Point(22, 64); ButtonAddObject.Location = new Point(18, 51);
ButtonAddObject.Margin = new Padding(4);
ButtonAddObject.Name = "ButtonAddObject"; ButtonAddObject.Name = "ButtonAddObject";
ButtonAddObject.Size = new Size(179, 34); ButtonAddObject.Size = new Size(143, 27);
ButtonAddObject.TabIndex = 6; ButtonAddObject.TabIndex = 6;
ButtonAddObject.Text = "Добавить набор"; ButtonAddObject.Text = "Добавить набор";
ButtonAddObject.UseVisualStyleBackColor = true; ButtonAddObject.UseVisualStyleBackColor = true;
@ -171,19 +163,17 @@
// //
// maskedTextBoxNumber // maskedTextBoxNumber
// //
maskedTextBoxNumber.Location = new Point(37, 484); maskedTextBoxNumber.Location = new Point(30, 387);
maskedTextBoxNumber.Margin = new Padding(4);
maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(155, 31); maskedTextBoxNumber.Size = new Size(125, 27);
maskedTextBoxNumber.TabIndex = 4; maskedTextBoxNumber.TabIndex = 4;
// //
// buttonRefreshCol // buttonRefreshCol
// //
buttonRefreshCol.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); buttonRefreshCol.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point);
buttonRefreshCol.Location = new Point(15, 582); buttonRefreshCol.Location = new Point(12, 466);
buttonRefreshCol.Margin = new Padding(4);
buttonRefreshCol.Name = "buttonRefreshCol"; buttonRefreshCol.Name = "buttonRefreshCol";
buttonRefreshCol.Size = new Size(224, 51); buttonRefreshCol.Size = new Size(179, 41);
buttonRefreshCol.TabIndex = 3; buttonRefreshCol.TabIndex = 3;
buttonRefreshCol.Text = "Обновить коллекцию"; buttonRefreshCol.Text = "Обновить коллекцию";
buttonRefreshCol.UseVisualStyleBackColor = true; buttonRefreshCol.UseVisualStyleBackColor = true;
@ -192,10 +182,9 @@
// buttonDelMonorail // buttonDelMonorail
// //
buttonDelMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); buttonDelMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point);
buttonDelMonorail.Location = new Point(15, 523); buttonDelMonorail.Location = new Point(12, 418);
buttonDelMonorail.Margin = new Padding(4);
buttonDelMonorail.Name = "buttonDelMonorail"; buttonDelMonorail.Name = "buttonDelMonorail";
buttonDelMonorail.Size = new Size(224, 51); buttonDelMonorail.Size = new Size(179, 41);
buttonDelMonorail.TabIndex = 2; buttonDelMonorail.TabIndex = 2;
buttonDelMonorail.Text = "Удалить монорельс"; buttonDelMonorail.Text = "Удалить монорельс";
buttonDelMonorail.UseVisualStyleBackColor = true; buttonDelMonorail.UseVisualStyleBackColor = true;
@ -204,10 +193,9 @@
// buttonAddMonorail // buttonAddMonorail
// //
buttonAddMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); buttonAddMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point);
buttonAddMonorail.Location = new Point(15, 425); buttonAddMonorail.Location = new Point(12, 340);
buttonAddMonorail.Margin = new Padding(4);
buttonAddMonorail.Name = "buttonAddMonorail"; buttonAddMonorail.Name = "buttonAddMonorail";
buttonAddMonorail.Size = new Size(224, 51); buttonAddMonorail.Size = new Size(179, 41);
buttonAddMonorail.TabIndex = 1; buttonAddMonorail.TabIndex = 1;
buttonAddMonorail.Text = "Добавить монорельс"; buttonAddMonorail.Text = "Добавить монорельс";
buttonAddMonorail.UseVisualStyleBackColor = true; buttonAddMonorail.UseVisualStyleBackColor = true;
@ -216,10 +204,9 @@
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(4, -4); label1.Location = new Point(3, -3);
label1.Margin = new Padding(4, 0, 4, 0);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(122, 25); label1.Size = new Size(103, 20);
label1.TabIndex = 0; label1.TabIndex = 0;
label1.Text = "Инструменты"; label1.Text = "Инструменты";
// //
@ -229,8 +216,7 @@
menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip1.Location = new Point(0, 0); menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1"; menuStrip1.Name = "menuStrip1";
menuStrip1.Padding = new Padding(8, 2, 0, 2); menuStrip1.Size = new Size(1228, 28);
menuStrip1.Size = new Size(1535, 33);
menuStrip1.TabIndex = 6; menuStrip1.TabIndex = 6;
menuStrip1.Text = "menuStrip1"; menuStrip1.Text = "menuStrip1";
// //
@ -238,20 +224,20 @@
// //
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сохранитьToolStripMenuItem, загрузитьToolStripMenuItem }); файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сохранитьToolStripMenuItem, загрузитьToolStripMenuItem });
файлToolStripMenuItem.Name = айлToolStripMenuItem"; файлToolStripMenuItem.Name = айлToolStripMenuItem";
файлToolStripMenuItem.Size = new Size(69, 29); файлToolStripMenuItem.Size = new Size(59, 24);
файлToolStripMenuItem.Text = "Файл"; файлToolStripMenuItem.Text = "Файл";
// //
// сохранитьToolStripMenuItem // сохранитьToolStripMenuItem
// //
сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem"; сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem";
сохранитьToolStripMenuItem.Size = new Size(200, 34); сохранитьToolStripMenuItem.Size = new Size(166, 26);
сохранитьToolStripMenuItem.Text = "Сохранить"; сохранитьToolStripMenuItem.Text = "Сохранить";
сохранитьToolStripMenuItem.Click += SaveToolStripMenuItem_Click; сохранитьToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
// //
// загрузитьToolStripMenuItem // загрузитьToolStripMenuItem
// //
загрузитьToolStripMenuItem.Name = агрузитьToolStripMenuItem"; загрузитьToolStripMenuItem.Name = агрузитьToolStripMenuItem";
загрузитьToolStripMenuItem.Size = new Size(200, 34); загрузитьToolStripMenuItem.Size = new Size(166, 26);
загрузитьToolStripMenuItem.Text = "Загрузить"; загрузитьToolStripMenuItem.Text = "Загрузить";
загрузитьToolStripMenuItem.Click += LoadToolStripMenuItem_Click; загрузитьToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
// //
@ -267,15 +253,14 @@
// //
// FormMonorailCollection // FormMonorailCollection
// //
AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.ControlDarkDark; BackColor = SystemColors.ControlDarkDark;
ClientSize = new Size(1535, 648); ClientSize = new Size(1228, 518);
Controls.Add(pictureBoxCollection); Controls.Add(pictureBoxCollection);
Controls.Add(panel1); Controls.Add(panel1);
Controls.Add(menuStrip1); Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1; MainMenuStrip = menuStrip1;
Margin = new Padding(4);
Name = "FormMonorailCollection"; Name = "FormMonorailCollection";
Text = "Набор Монорельсов"; Text = "Набор Монорельсов";
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();

View File

@ -154,6 +154,12 @@ EventArgs e)
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogWarning(ex.Message); _logger.LogWarning(ex.Message);
} }
catch (ArgumentException)
{
MessageBox.Show("Такой монорельс уже существует", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogWarning("Такой монорельс уже существует");
}
} }
private void ButtonRemoveMonorail_Click(object sender, EventArgs e) private void ButtonRemoveMonorail_Click(object sender, EventArgs e)

View File

@ -17,7 +17,6 @@ namespace Monorail.Generics
} }
public bool Equals(MonorailsCollectionInfo? other) public bool Equals(MonorailsCollectionInfo? other)
{ {
// TODO прописать логику сравнения по свойству Name
return Name == other?.Name; return Name == other?.Name;
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -25,9 +24,5 @@ namespace Monorail.Generics
{ {
return Name.GetHashCode(); return Name.GetHashCode();
} }
public override string ToString()
{
return "Object: " + Name;
}
} }
} }

View File

@ -75,7 +75,7 @@ namespace Monorail.Generics
{ {
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
} }
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); data.AppendLine($"{record.Key.Name}{_separatorForKeyValue}{records}");
} }
if (data.Length == 0) if (data.Length == 0)
{ {