From 358c3795cd5c0e809f9205cee77441eaea5710e2 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:40:23 +0400 Subject: [PATCH 1/2] Lab03 --- .../DrawningObjects/DrawningMonorail.cs | 4 + ...1.Designer.cs => FormMonorail.Designer.cs} | 28 +++- .../Monorail/{Form1.cs => FormMonorail.cs} | 46 ++++-- .../{Form1.resx => FormMonorail.resx} | 0 .../FormMonorailCollection.Designer.cs | 138 ++++++++++++++++++ Monorail/Monorail/FormMonorailCollection.cs | 75 ++++++++++ Monorail/Monorail/FormMonorailCollection.resx | 120 +++++++++++++++ .../Generics/MonorailsGenericCollection.cs | 103 +++++++++++++ Monorail/Monorail/Generics/SetGeneric.cs | 95 ++++++++++++ Monorail/Monorail/Program.cs | 2 +- 10 files changed, 593 insertions(+), 18 deletions(-) rename Monorail/Monorail/{Form1.Designer.cs => FormMonorail.Designer.cs} (89%) rename Monorail/Monorail/{Form1.cs => FormMonorail.cs} (70%) rename Monorail/Monorail/{Form1.resx => FormMonorail.resx} (100%) create mode 100644 Monorail/Monorail/FormMonorailCollection.Designer.cs create mode 100644 Monorail/Monorail/FormMonorailCollection.cs create mode 100644 Monorail/Monorail/FormMonorailCollection.resx create mode 100644 Monorail/Monorail/Generics/MonorailsGenericCollection.cs create mode 100644 Monorail/Monorail/Generics/SetGeneric.cs diff --git a/Monorail/Monorail/DrawningObjects/DrawningMonorail.cs b/Monorail/Monorail/DrawningObjects/DrawningMonorail.cs index 4375cc0..bc1de36 100644 --- a/Monorail/Monorail/DrawningObjects/DrawningMonorail.cs +++ b/Monorail/Monorail/DrawningObjects/DrawningMonorail.cs @@ -4,12 +4,16 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Monorail.Entities; +using Monorail.MovementStrategy; namespace Monorail.DrawningObjects { public class DrawningMonorail { public EntityMonorail? EntityMonorail { get; protected set; } + + public IMoveableObject GetMoveableObject => new DrawningObjectMonorail(this); + private int _pictureWidth; private int _pictureHeight; protected int _startPosX; diff --git a/Monorail/Monorail/Form1.Designer.cs b/Monorail/Monorail/FormMonorail.Designer.cs similarity index 89% rename from Monorail/Monorail/Form1.Designer.cs rename to Monorail/Monorail/FormMonorail.Designer.cs index 4c002a3..a2eec03 100644 --- a/Monorail/Monorail/Form1.Designer.cs +++ b/Monorail/Monorail/FormMonorail.Designer.cs @@ -1,6 +1,6 @@ namespace Monorail { - partial class MonoRail + partial class FormMonorail { /// /// Required designer variable. @@ -37,6 +37,7 @@ ButtonCreateSecondMonorail = new Button(); buttonStep = new Button(); comboBoxStrategy = new ComboBox(); + button1 = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxMonorail).BeginInit(); SuspendLayout(); // @@ -56,7 +57,7 @@ buttonUp.BackColor = SystemColors.Info; buttonUp.BackgroundImage = Properties.Resources.upper_arrow; buttonUp.BackgroundImageLayout = ImageLayout.Zoom; - buttonUp.Location = new Point(790, 355); + buttonUp.Location = new Point(784, 355); buttonUp.Name = "buttonUp"; buttonUp.Size = new Size(40, 40); buttonUp.TabIndex = 6; @@ -69,7 +70,7 @@ buttonLeft.BackColor = SystemColors.Info; buttonLeft.BackgroundImage = Properties.Resources.left_arrow; buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; - buttonLeft.Location = new Point(744, 401); + buttonLeft.Location = new Point(738, 401); buttonLeft.Name = "buttonLeft"; buttonLeft.Size = new Size(40, 40); buttonLeft.TabIndex = 10; @@ -82,7 +83,7 @@ buttonDown.BackColor = SystemColors.Info; buttonDown.BackgroundImage = Properties.Resources.down_arrow; buttonDown.BackgroundImageLayout = ImageLayout.Zoom; - buttonDown.Location = new Point(790, 401); + buttonDown.Location = new Point(784, 401); buttonDown.Name = "buttonDown"; buttonDown.Size = new Size(40, 40); buttonDown.TabIndex = 9; @@ -95,7 +96,7 @@ buttonRight.BackColor = SystemColors.Info; buttonRight.BackgroundImage = Properties.Resources.right_arrow; buttonRight.BackgroundImageLayout = ImageLayout.Zoom; - buttonRight.Location = new Point(836, 401); + buttonRight.Location = new Point(830, 401); buttonRight.Name = "buttonRight"; buttonRight.Size = new Size(40, 40); buttonRight.TabIndex = 8; @@ -146,12 +147,24 @@ comboBoxStrategy.Size = new Size(151, 28); comboBoxStrategy.TabIndex = 19; // - // MonoRail + // button1 + // + button1.BackColor = SystemColors.Info; + button1.Location = new Point(710, 88); + button1.Name = "button1"; + button1.Size = new Size(166, 40); + button1.TabIndex = 23; + button1.Text = "Выбрать Монорельс"; + button1.UseVisualStyleBackColor = false; + button1.Click += ButtonSelectMonorail_Click; + // + // FormMonorail // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; BackColor = SystemColors.ControlDarkDark; ClientSize = new Size(882, 453); + Controls.Add(button1); Controls.Add(ButtonCreateMonorail); Controls.Add(ButtonCreateSecondMonorail); Controls.Add(buttonStep); @@ -161,7 +174,7 @@ Controls.Add(buttonRight); Controls.Add(buttonUp); Controls.Add(pictureBoxMonorail); - Name = "MonoRail"; + Name = "FormMonorail"; StartPosition = FormStartPosition.CenterScreen; Text = "Monorail"; ((System.ComponentModel.ISupportInitialize)pictureBoxMonorail).EndInit(); @@ -180,5 +193,6 @@ private Button ButtonCreateSecondMonorail; private Button buttonStep; private ComboBox comboBoxStrategy; + private Button button1; } } \ No newline at end of file diff --git a/Monorail/Monorail/Form1.cs b/Monorail/Monorail/FormMonorail.cs similarity index 70% rename from Monorail/Monorail/Form1.cs rename to Monorail/Monorail/FormMonorail.cs index 58f7888..3e9165e 100644 --- a/Monorail/Monorail/Form1.cs +++ b/Monorail/Monorail/FormMonorail.cs @@ -1,17 +1,21 @@ using Monorail.DrawningObjects; using Monorail.MovementStrategy; +using System.Drawing; namespace Monorail { - public partial class MonoRail : Form + public partial class FormMonorail : Form { private DrawningMonorail? _drawningMonorail; private AbstractStrategy? _abstractStrategy; + public DrawningMonorail? SelectedMonorail { get; private set; } - public MonoRail() + public FormMonorail() { InitializeComponent(); + _abstractStrategy = null; + SelectedMonorail = null; } private void Draw() { @@ -29,13 +33,24 @@ namespace Monorail private void ButtonCreateSecondMonorail_Click(object sender, EventArgs e) { Random random = new(); + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), + random.Next(0, 256)); + ColorDialog dialog1 = new(); + if (dialog1.ShowDialog() == DialogResult.OK) + { + color = dialog1.Color; + } + + Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), + random.Next(0, 256)); + ColorDialog dialog2 = new(); + if (dialog2.ShowDialog() == DialogResult.OK) + { + dopColor = dialog2.Color; + } _drawningMonorail = new DrawningSecondMonorail(random.Next(100, 300), - random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), - random.Next(0, 256)), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), - random.Next(0, 256)), + random.Next(1000, 3000), color, dopColor, true, true, pictureBoxMonorail.Width, pictureBoxMonorail.Height); _drawningMonorail.SetPosition(random.Next(10, 100), random.Next(10, @@ -45,9 +60,16 @@ namespace Monorail private void ButtonCreateMonorail_Click(object sender, EventArgs e) { Random random = new(); + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), + random.Next(0, 256)); + ColorDialog dialog1 = new(); + if (dialog1.ShowDialog() == DialogResult.OK) + { + color = dialog1.Color; + } + _drawningMonorail = new DrawningMonorail(random.Next(100, 300), - random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), - random.Next(0, 256)), pictureBoxMonorail.Width, pictureBoxMonorail.Height); + random.Next(1000, 3000), color, pictureBoxMonorail.Width, pictureBoxMonorail.Height); _drawningMonorail.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } @@ -97,7 +119,6 @@ namespace Monorail _abstractStrategy.SetData(new DrawningObjectMonorail(_drawningMonorail), pictureBoxMonorail.Width, pictureBoxMonorail.Height); - //comboBoxStrategy.Enabled = false; } if (_abstractStrategy == null) { @@ -111,5 +132,10 @@ namespace Monorail _abstractStrategy = null; } } + private void ButtonSelectMonorail_Click(object sender, EventArgs e) + { + SelectedMonorail = _drawningMonorail; + DialogResult = DialogResult.OK; + } } } \ No newline at end of file diff --git a/Monorail/Monorail/Form1.resx b/Monorail/Monorail/FormMonorail.resx similarity index 100% rename from Monorail/Monorail/Form1.resx rename to Monorail/Monorail/FormMonorail.resx diff --git a/Monorail/Monorail/FormMonorailCollection.Designer.cs b/Monorail/Monorail/FormMonorailCollection.Designer.cs new file mode 100644 index 0000000..67ab749 --- /dev/null +++ b/Monorail/Monorail/FormMonorailCollection.Designer.cs @@ -0,0 +1,138 @@ +namespace Monorail +{ + partial class FormMonorailCollection + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + pictureBoxCollection = new PictureBox(); + panel1 = new Panel(); + maskedTextBoxNumber = new TextBox(); + buttonRefreshCol = new Button(); + buttonDelMonorail = new Button(); + buttonAddMonorail = new Button(); + label1 = new Label(); + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // pictureBoxCollection + // + pictureBoxCollection.Location = new Point(5, -1); + pictureBoxCollection.Name = "pictureBoxCollection"; + pictureBoxCollection.Size = new Size(931, 454); + pictureBoxCollection.TabIndex = 5; + pictureBoxCollection.TabStop = false; + // + // panel1 + // + panel1.BackColor = SystemColors.Info; + panel1.Controls.Add(maskedTextBoxNumber); + panel1.Controls.Add(buttonRefreshCol); + panel1.Controls.Add(buttonDelMonorail); + panel1.Controls.Add(buttonAddMonorail); + panel1.Controls.Add(label1); + panel1.Location = new Point(942, 12); + panel1.Name = "panel1"; + panel1.Size = new Size(190, 429); + panel1.TabIndex = 4; + // + // maskedTextBoxNumber + // + maskedTextBoxNumber.Location = new Point(29, 109); + maskedTextBoxNumber.Name = "maskedTextBoxNumber"; + 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(12, 237); + buttonRefreshCol.Name = "buttonRefreshCol"; + buttonRefreshCol.Size = new Size(166, 41); + buttonRefreshCol.TabIndex = 3; + buttonRefreshCol.Text = "Обновить коллекцию"; + buttonRefreshCol.UseVisualStyleBackColor = true; + buttonRefreshCol.Click += ButtonRefreshCollection_Click; + // + // buttonDelMonorail + // + buttonDelMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); + buttonDelMonorail.Location = new Point(12, 174); + buttonDelMonorail.Name = "buttonDelMonorail"; + buttonDelMonorail.Size = new Size(166, 41); + buttonDelMonorail.TabIndex = 2; + buttonDelMonorail.Text = "Удалить монорельс"; + buttonDelMonorail.UseVisualStyleBackColor = true; + buttonDelMonorail.Click += ButtonRemoveMonorail_Click; + // + // buttonAddMonorail + // + buttonAddMonorail.Font = new Font("Segoe UI", 7.8F, FontStyle.Regular, GraphicsUnit.Point); + buttonAddMonorail.Location = new Point(12, 29); + buttonAddMonorail.Name = "buttonAddMonorail"; + buttonAddMonorail.Size = new Size(166, 41); + buttonAddMonorail.TabIndex = 1; + buttonAddMonorail.Text = "Добавить монорельс"; + buttonAddMonorail.UseVisualStyleBackColor = true; + buttonAddMonorail.Click += ButtonAddMonorail_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(3, -3); + label1.Name = "label1"; + label1.Size = new Size(103, 20); + label1.TabIndex = 0; + label1.Text = "Инструменты"; + // + // FormMonorailCollection + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = SystemColors.ControlDarkDark; + ClientSize = new Size(1144, 453); + Controls.Add(pictureBoxCollection); + Controls.Add(panel1); + Name = "FormMonorailCollection"; + Text = "Набор Монорельсов"; + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); + panel1.ResumeLayout(false); + panel1.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxCollection; + private Panel panel1; + private Button buttonRefreshCol; + private Button buttonDelMonorail; + private Button buttonAddMonorail; + private Label label1; + private TextBox maskedTextBoxNumber; + } +} \ No newline at end of file diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs new file mode 100644 index 0000000..7aba1a5 --- /dev/null +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Monorail.DrawningObjects; +using Monorail.Generics; +using Monorail.MovementStrategy; + +namespace Monorail +{ + public partial class FormMonorailCollection : Form + { + private readonly MonorailsGenericCollection _monorails; + + public FormMonorailCollection() + { + InitializeComponent(); + _monorails = new MonorailsGenericCollection + (pictureBoxCollection.Width, pictureBoxCollection.Height); + } + private void ButtonAddMonorail_Click(object sender, EventArgs e) + { + FormMonorail form = new(); + + if (form.ShowDialog() == DialogResult.OK) + { + if (_monorails + form.SelectedMonorail) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = _monorails.ShowMonorails(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + private void ButtonRemoveMonorail_Click(object sender, EventArgs e) + { + if (MessageBox.Show("Удалить объект?", "Удаление", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos; + if (maskedTextBoxNumber.Text == "") + { + MessageBox.Show("Введите позицию элемента выше"); + return; + } + else + { + pos = Convert.ToInt32(maskedTextBoxNumber.Text); + } + if (_monorails - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBoxCollection.Image = _monorails.ShowMonorails(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + private void ButtonRefreshCollection_Click(object sender, EventArgs e) + { + pictureBoxCollection.Image = _monorails.ShowMonorails(); + } + } +} diff --git a/Monorail/Monorail/FormMonorailCollection.resx b/Monorail/Monorail/FormMonorailCollection.resx new file mode 100644 index 0000000..a395bff --- /dev/null +++ b/Monorail/Monorail/FormMonorailCollection.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Monorail/Monorail/Generics/MonorailsGenericCollection.cs b/Monorail/Monorail/Generics/MonorailsGenericCollection.cs new file mode 100644 index 0000000..0850b17 --- /dev/null +++ b/Monorail/Monorail/Generics/MonorailsGenericCollection.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Monorail.DrawningObjects; +using Monorail.MovementStrategy; +namespace Monorail.Generics +{ + internal class MonorailsGenericCollection + where T: DrawningMonorail + where U : IMoveableObject + { + private readonly int _pictureWidth; + private readonly int _pictureHeight; + private readonly int _placeSizeWidth = 295; + private readonly int _placeSizeHeight = 65; + private readonly SetGeneric _collection; + public MonorailsGenericCollection(int picWidth, int picHeight) + { + int width = picWidth / _placeSizeWidth; + int height = picHeight / _placeSizeHeight; + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _collection = new SetGeneric(width * height); + } + public static int operator +(MonorailsGenericCollection collect, T? obj) + { + if (obj == null) + { + return -1; + } + return collect._collection.Insert(obj); + } + public static bool operator -(MonorailsGenericCollection collect, int pos) + { + T? obj = collect._collection.Get(pos); + if (obj != null) + { + return collect._collection.Remove(pos); + } + return false; + } + public U? GetU(int pos) + { + return (U?)_collection.Get(pos)?.GetMoveableObject; + } + public Bitmap ShowMonorails() + { + Bitmap bmp = new(_pictureWidth, _pictureHeight); + Graphics gr = Graphics.FromImage(bmp); + DrawBackground(gr); + DrawObjects(gr); + return bmp; + } + private void DrawBackground(Graphics g) + { + Pen pen = new(Color.Black, 3); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + { + for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) + {//линия рамзетки места + g.DrawLine(pen, i * _placeSizeWidth, j * + _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2 + 20, j * + _placeSizeHeight); + } + g.DrawLine(pen, i * _placeSizeWidth, 0, i * + _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); + } + } + private void DrawObjects(Graphics g) + { + int indexPlaces = 0; + int j = _pictureHeight / _placeSizeHeight - 1; + int ind = 0; + for (int i = 0; i < _collection.Count; i++) + { + + // TODO получение объекта + DrawningMonorail? _monorail = _collection.Get(indexPlaces); + indexPlaces++; + + if (_monorail != null) + { + // TODO установка позиции + _monorail.SetPosition(ind * _placeSizeWidth, j * _placeSizeHeight); + // TODO прорисовка объекта + _monorail.DrawTransport(g); + } + if(ind == _pictureWidth / _placeSizeWidth - 1) + { + ind = 0; + j--; + } + else + { + ind++; + } + } + } + } +} \ No newline at end of file diff --git a/Monorail/Monorail/Generics/SetGeneric.cs b/Monorail/Monorail/Generics/SetGeneric.cs new file mode 100644 index 0000000..2391130 --- /dev/null +++ b/Monorail/Monorail/Generics/SetGeneric.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Monorail.Generics +{ + internal class SetGeneric + where T : class + { + private readonly T?[] _places; + public int Count => _places.Length; + public SetGeneric(int count) + { + _places = new T?[count]; + } + public int Insert(T monorail) + { + if (monorail == null) + { + return -1; + } + + for (int i = Count-1; i != 0; i--) + { + _places[i] = _places[i - 1]; + } + _places[0] = monorail; + + return 0; + } + public bool Insert(T monorail, int position) + { + // TODO проверка позиции + if (position >= Count) + { + return false; + } + // TODO проверка, что элемент массива по этой позиции пустой, если нет, то + // проверка, что после вставляемого элемента в массиве есть пустой элемент + // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента + if (_places[position] != null) + { + for(int i = position + 1; i= Count) + { + return false; + } + // TODO удаление объекта из массива, присвоив элементу массива значение null + if (_places[position] != null) + { + _places[position] = null; + return true; + } + else + { + return false; + } + } + public T? Get(int position) + { + // TODO проверка позиции + if(position >= Count) + { + return null; + } + return _places[position]; + } + + } +} diff --git a/Monorail/Monorail/Program.cs b/Monorail/Monorail/Program.cs index 720f936..411e9f6 100644 --- a/Monorail/Monorail/Program.cs +++ b/Monorail/Monorail/Program.cs @@ -11,7 +11,7 @@ namespace Monorail // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new MonoRail()); + Application.Run(new FormMonorailCollection()); } } } \ No newline at end of file -- 2.25.1 From 5c2d3d046549aa40aaf6eb1991d4f26660c3dde0 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:41:39 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Monorail/Monorail/FormMonorailCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 7aba1a5..3c840fb 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -29,7 +29,7 @@ namespace Monorail if (form.ShowDialog() == DialogResult.OK) { - if (_monorails + form.SelectedMonorail) + if (_monorails + form.SelectedMonorail != -1) { MessageBox.Show("Объект добавлен"); pictureBoxCollection.Image = _monorails.ShowMonorails(); -- 2.25.1