diff --git a/Monorail/Monorail/FormMonorailCollection.Designer.cs b/Monorail/Monorail/FormMonorailCollection.Designer.cs index 4360181..edf4e46 100644 --- a/Monorail/Monorail/FormMonorailCollection.Designer.cs +++ b/Monorail/Monorail/FormMonorailCollection.Designer.cs @@ -57,10 +57,9 @@ // // pictureBoxCollection // - pictureBoxCollection.Location = new Point(6, 39); - pictureBoxCollection.Margin = new Padding(4); + pictureBoxCollection.Location = new Point(5, 31); pictureBoxCollection.Name = "pictureBoxCollection"; - pictureBoxCollection.Size = new Size(1271, 606); + pictureBoxCollection.Size = new Size(1017, 485); pictureBoxCollection.TabIndex = 5; pictureBoxCollection.TabStop = false; // @@ -75,33 +74,32 @@ panel1.Controls.Add(buttonDelMonorail); panel1.Controls.Add(buttonAddMonorail); panel1.Controls.Add(label1); - panel1.Location = new Point(1281, -1); - panel1.Margin = new Padding(4); + panel1.Location = new Point(1025, -1); panel1.Name = "panel1"; - panel1.Size = new Size(255, 646); + panel1.Size = new Size(204, 517); panel1.TabIndex = 4; // // ButtonSortByColor // ButtonSortByColor.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); - ButtonSortByColor.Location = new Point(15, 366); - ButtonSortByColor.Margin = new Padding(4); + ButtonSortByColor.Location = new Point(12, 293); ButtonSortByColor.Name = "ButtonSortByColor"; - ButtonSortByColor.Size = new Size(224, 51); + ButtonSortByColor.Size = new Size(179, 41); ButtonSortByColor.TabIndex = 9; ButtonSortByColor.Text = "Сортировка по цвету"; ButtonSortByColor.UseVisualStyleBackColor = true; + ButtonSortByColor.Click += ButtonSortByColor_Click; // // ButtonSortByType // ButtonSortByType.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); - ButtonSortByType.Location = new Point(15, 307); - ButtonSortByType.Margin = new Padding(4); + ButtonSortByType.Location = new Point(12, 246); ButtonSortByType.Name = "ButtonSortByType"; - ButtonSortByType.Size = new Size(224, 51); + ButtonSortByType.Size = new Size(179, 41); ButtonSortByType.TabIndex = 8; ButtonSortByType.Text = "Сортировка по типу"; ButtonSortByType.UseVisualStyleBackColor = true; + ButtonSortByType.Click += ButtonSortByType_Click; // // panel2 // @@ -110,48 +108,43 @@ panel2.Controls.Add(textBoxStorageName); panel2.Controls.Add(button1); panel2.Controls.Add(ButtonAddObject); - panel2.Location = new Point(15, 25); - panel2.Margin = new Padding(4); + panel2.Location = new Point(12, 20); panel2.Name = "panel2"; - panel2.Size = new Size(224, 261); + panel2.Size = new Size(179, 209); panel2.TabIndex = 7; // // label2 // label2.AutoSize = true; - label2.Location = new Point(4, -4); - label2.Margin = new Padding(4, 0, 4, 0); + label2.Location = new Point(3, -3); label2.Name = "label2"; - label2.Size = new Size(79, 25); + label2.Size = new Size(66, 20); label2.TabIndex = 8; label2.Text = "Наборы"; // // listBoxStorages // listBoxStorages.FormattingEnabled = true; - listBoxStorages.ItemHeight = 25; - listBoxStorages.Location = new Point(21, 106); - listBoxStorages.Margin = new Padding(4); + listBoxStorages.ItemHeight = 20; + listBoxStorages.Location = new Point(17, 85); listBoxStorages.Name = "listBoxStorages"; - listBoxStorages.Size = new Size(179, 104); + listBoxStorages.Size = new Size(144, 84); listBoxStorages.TabIndex = 9; listBoxStorages.Click += ListBoxObjects_SelectedIndexChanged; // // textBoxStorageName // - textBoxStorageName.Location = new Point(21, 25); - textBoxStorageName.Margin = new Padding(4); + textBoxStorageName.Location = new Point(17, 20); textBoxStorageName.Name = "textBoxStorageName"; - textBoxStorageName.Size = new Size(178, 31); + textBoxStorageName.Size = new Size(143, 27); textBoxStorageName.TabIndex = 8; // // button1 // button1.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); - button1.Location = new Point(20, 218); - button1.Margin = new Padding(4); + button1.Location = new Point(16, 174); button1.Name = "button1"; - button1.Size = new Size(179, 33); + button1.Size = new Size(143, 26); button1.TabIndex = 5; button1.Text = "Удалить набор"; button1.UseVisualStyleBackColor = true; @@ -160,10 +153,9 @@ // ButtonAddObject // ButtonAddObject.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); - ButtonAddObject.Location = new Point(22, 64); - ButtonAddObject.Margin = new Padding(4); + ButtonAddObject.Location = new Point(18, 51); ButtonAddObject.Name = "ButtonAddObject"; - ButtonAddObject.Size = new Size(179, 34); + ButtonAddObject.Size = new Size(143, 27); ButtonAddObject.TabIndex = 6; ButtonAddObject.Text = "Добавить набор"; ButtonAddObject.UseVisualStyleBackColor = true; @@ -171,19 +163,17 @@ // // maskedTextBoxNumber // - maskedTextBoxNumber.Location = new Point(37, 484); - maskedTextBoxNumber.Margin = new Padding(4); + maskedTextBoxNumber.Location = new Point(30, 387); maskedTextBoxNumber.Name = "maskedTextBoxNumber"; - maskedTextBoxNumber.Size = new Size(155, 31); + maskedTextBoxNumber.Size = new Size(125, 27); maskedTextBoxNumber.TabIndex = 4; // // buttonRefreshCol // buttonRefreshCol.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); - buttonRefreshCol.Location = new Point(15, 582); - buttonRefreshCol.Margin = new Padding(4); + buttonRefreshCol.Location = new Point(12, 466); buttonRefreshCol.Name = "buttonRefreshCol"; - buttonRefreshCol.Size = new Size(224, 51); + buttonRefreshCol.Size = new Size(179, 41); buttonRefreshCol.TabIndex = 3; buttonRefreshCol.Text = "Обновить коллекцию"; buttonRefreshCol.UseVisualStyleBackColor = true; @@ -192,10 +182,9 @@ // buttonDelMonorail // buttonDelMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); - buttonDelMonorail.Location = new Point(15, 523); - buttonDelMonorail.Margin = new Padding(4); + buttonDelMonorail.Location = new Point(12, 418); buttonDelMonorail.Name = "buttonDelMonorail"; - buttonDelMonorail.Size = new Size(224, 51); + buttonDelMonorail.Size = new Size(179, 41); buttonDelMonorail.TabIndex = 2; buttonDelMonorail.Text = "Удалить монорельс"; buttonDelMonorail.UseVisualStyleBackColor = true; @@ -204,10 +193,9 @@ // buttonAddMonorail // buttonAddMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); - buttonAddMonorail.Location = new Point(15, 425); - buttonAddMonorail.Margin = new Padding(4); + buttonAddMonorail.Location = new Point(12, 340); buttonAddMonorail.Name = "buttonAddMonorail"; - buttonAddMonorail.Size = new Size(224, 51); + buttonAddMonorail.Size = new Size(179, 41); buttonAddMonorail.TabIndex = 1; buttonAddMonorail.Text = "Добавить монорельс"; buttonAddMonorail.UseVisualStyleBackColor = true; @@ -216,10 +204,9 @@ // label1 // label1.AutoSize = true; - label1.Location = new Point(4, -4); - label1.Margin = new Padding(4, 0, 4, 0); + label1.Location = new Point(3, -3); label1.Name = "label1"; - label1.Size = new Size(122, 25); + label1.Size = new Size(103, 20); label1.TabIndex = 0; label1.Text = "Инструменты"; // @@ -229,8 +216,7 @@ menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; - menuStrip1.Padding = new Padding(8, 2, 0, 2); - menuStrip1.Size = new Size(1535, 33); + menuStrip1.Size = new Size(1228, 28); menuStrip1.TabIndex = 6; menuStrip1.Text = "menuStrip1"; // @@ -238,20 +224,20 @@ // файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сохранитьToolStripMenuItem, загрузитьToolStripMenuItem }); файлToolStripMenuItem.Name = "файлToolStripMenuItem"; - файлToolStripMenuItem.Size = new Size(69, 29); + файлToolStripMenuItem.Size = new Size(59, 24); файлToolStripMenuItem.Text = "Файл"; // // сохранитьToolStripMenuItem // сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem"; - сохранитьToolStripMenuItem.Size = new Size(200, 34); + сохранитьToolStripMenuItem.Size = new Size(166, 26); сохранитьToolStripMenuItem.Text = "Сохранить"; сохранитьToolStripMenuItem.Click += SaveToolStripMenuItem_Click; // // загрузитьToolStripMenuItem // загрузитьToolStripMenuItem.Name = "загрузитьToolStripMenuItem"; - загрузитьToolStripMenuItem.Size = new Size(200, 34); + загрузитьToolStripMenuItem.Size = new Size(166, 26); загрузитьToolStripMenuItem.Text = "Загрузить"; загрузитьToolStripMenuItem.Click += LoadToolStripMenuItem_Click; // @@ -267,15 +253,14 @@ // // FormMonorailCollection // - AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; BackColor = SystemColors.ControlDarkDark; - ClientSize = new Size(1535, 648); + ClientSize = new Size(1228, 518); Controls.Add(pictureBoxCollection); Controls.Add(panel1); Controls.Add(menuStrip1); MainMenuStrip = menuStrip1; - Margin = new Padding(4); Name = "FormMonorailCollection"; Text = "Набор Монорельсов"; ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 1cc0e1c..d04844e 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -154,6 +154,12 @@ EventArgs e) MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.LogWarning(ex.Message); } + catch (ArgumentException) + { + MessageBox.Show("Такой монорельс уже существует", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogWarning("Такой монорельс уже существует"); + } } private void ButtonRemoveMonorail_Click(object sender, EventArgs e) diff --git a/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs b/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs index 5457224..f67ae2a 100644 --- a/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs +++ b/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs @@ -17,7 +17,6 @@ namespace Monorail.Generics } public bool Equals(MonorailsCollectionInfo? other) { - // TODO прописать логику сравнения по свойству Name return Name == other?.Name; throw new NotImplementedException(); } @@ -25,9 +24,5 @@ namespace Monorail.Generics { return Name.GetHashCode(); } - public override string ToString() - { - return "Object: " + Name; - } } } diff --git a/Monorail/Monorail/Generics/MonorailsGenericStorage.cs b/Monorail/Monorail/Generics/MonorailsGenericStorage.cs index 98a2089..3d2e305 100644 --- a/Monorail/Monorail/Generics/MonorailsGenericStorage.cs +++ b/Monorail/Monorail/Generics/MonorailsGenericStorage.cs @@ -75,7 +75,7 @@ namespace Monorail.Generics { records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); } - data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); + data.AppendLine($"{record.Key.Name}{_separatorForKeyValue}{records}"); } if (data.Length == 0) {