diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.Designer.cs b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.Designer.cs index 5424d44..dc44277 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.Designer.cs +++ b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.Designer.cs @@ -29,46 +29,119 @@ private void InitializeComponent() { this.groupBoxTools = new System.Windows.Forms.GroupBox(); + this.groupBoxMaps = new System.Windows.Forms.GroupBox(); + this.listBoxMaps = new System.Windows.Forms.ListBox(); + this.buttonDeleteMap = new System.Windows.Forms.Button(); + this.buttonAddMap = new System.Windows.Forms.Button(); + this.textBoxNewMapName = new System.Windows.Forms.TextBox(); + this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox(); - this.buttonRemoveStorm = new System.Windows.Forms.Button(); + this.buttonRemoveCar = new System.Windows.Forms.Button(); this.buttonShowStorage = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button(); this.buttonUp = new System.Windows.Forms.Button(); this.buttonShowOnMap = new System.Windows.Forms.Button(); - this.buttonAddStorm = new System.Windows.Forms.Button(); - this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); + this.buttonAddCar = new System.Windows.Forms.Button(); this.pictureBox = new System.Windows.Forms.PictureBox(); this.groupBoxTools.SuspendLayout(); + this.groupBoxMaps.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.SuspendLayout(); // // groupBoxTools // + this.groupBoxTools.Controls.Add(this.groupBoxMaps); this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition); - this.groupBoxTools.Controls.Add(this.buttonRemoveStorm); + this.groupBoxTools.Controls.Add(this.buttonRemoveCar); this.groupBoxTools.Controls.Add(this.buttonShowStorage); this.groupBoxTools.Controls.Add(this.buttonDown); this.groupBoxTools.Controls.Add(this.buttonRight); this.groupBoxTools.Controls.Add(this.buttonLeft); this.groupBoxTools.Controls.Add(this.buttonUp); this.groupBoxTools.Controls.Add(this.buttonShowOnMap); - this.groupBoxTools.Controls.Add(this.buttonAddStorm); - this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap); + this.groupBoxTools.Controls.Add(this.buttonAddCar); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Location = new System.Drawing.Point(927, 0); this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBoxTools.Name = "groupBoxTools"; this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBoxTools.Size = new System.Drawing.Size(233, 739); + this.groupBoxTools.Size = new System.Drawing.Size(233, 884); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Инструменты"; // + // groupBoxMaps + // + this.groupBoxMaps.Controls.Add(this.listBoxMaps); + this.groupBoxMaps.Controls.Add(this.buttonDeleteMap); + this.groupBoxMaps.Controls.Add(this.buttonAddMap); + this.groupBoxMaps.Controls.Add(this.textBoxNewMapName); + this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap); + this.groupBoxMaps.Location = new System.Drawing.Point(14, 28); + this.groupBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxMaps.Name = "groupBoxMaps"; + this.groupBoxMaps.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxMaps.Size = new System.Drawing.Size(213, 360); + this.groupBoxMaps.TabIndex = 11; + this.groupBoxMaps.TabStop = false; + this.groupBoxMaps.Text = "Карты"; + // + // listBoxMaps + // + this.listBoxMaps.FormattingEnabled = true; + this.listBoxMaps.ItemHeight = 20; + this.listBoxMaps.Location = new System.Drawing.Point(7, 160); + this.listBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.listBoxMaps.Name = "listBoxMaps"; + this.listBoxMaps.Size = new System.Drawing.Size(198, 144); + this.listBoxMaps.TabIndex = 4; + this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged); + // + // buttonDeleteMap + // + this.buttonDeleteMap.Location = new System.Drawing.Point(7, 313); + this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonDeleteMap.Name = "buttonDeleteMap"; + this.buttonDeleteMap.Size = new System.Drawing.Size(199, 39); + this.buttonDeleteMap.TabIndex = 3; + this.buttonDeleteMap.Text = "Удалить карту"; + this.buttonDeleteMap.UseVisualStyleBackColor = true; + this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click); + // + // buttonAddMap + // + this.buttonAddMap.Location = new System.Drawing.Point(6, 115); + this.buttonAddMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonAddMap.Name = "buttonAddMap"; + this.buttonAddMap.Size = new System.Drawing.Size(200, 37); + this.buttonAddMap.TabIndex = 2; + this.buttonAddMap.Text = "Добавить карту"; + this.buttonAddMap.UseVisualStyleBackColor = true; + this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click); + // + // textBoxNewMapName + // + this.textBoxNewMapName.Location = new System.Drawing.Point(7, 37); + this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.textBoxNewMapName.Name = "textBoxNewMapName"; + this.textBoxNewMapName.Size = new System.Drawing.Size(198, 27); + this.textBoxNewMapName.TabIndex = 1; + // + // comboBoxSelectorMap + // + this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSelectorMap.FormattingEnabled = true; + this.comboBoxSelectorMap.Location = new System.Drawing.Point(7, 76); + this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; + this.comboBoxSelectorMap.Size = new System.Drawing.Size(198, 28); + this.comboBoxSelectorMap.TabIndex = 0; + // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 221); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(21, 511); this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; @@ -76,20 +149,20 @@ this.maskedTextBoxPosition.TabIndex = 2; this.maskedTextBoxPosition.ValidatingType = typeof(int); // - // buttonRemoveStorm + // buttonRemoveCar // - this.buttonRemoveStorm.Location = new System.Drawing.Point(19, 260); - this.buttonRemoveStorm.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonRemoveStorm.Name = "buttonRemoveStorm"; - this.buttonRemoveStorm.Size = new System.Drawing.Size(200, 47); - this.buttonRemoveStorm.TabIndex = 3; - this.buttonRemoveStorm.Text = "Удалить самолёт"; - this.buttonRemoveStorm.UseVisualStyleBackColor = true; - this.buttonRemoveStorm.Click += new System.EventHandler(this.ButtonRemoveStorm_Click); + this.buttonRemoveCar.Location = new System.Drawing.Point(21, 565); + this.buttonRemoveCar.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonRemoveCar.Name = "buttonRemoveCar"; + this.buttonRemoveCar.Size = new System.Drawing.Size(200, 47); + this.buttonRemoveCar.TabIndex = 3; + this.buttonRemoveCar.Text = "Удалить самолёт"; + this.buttonRemoveCar.UseVisualStyleBackColor = true; + this.buttonRemoveCar.Click += new System.EventHandler(this.ButtonRemoveStorm_Click); // // buttonShowStorage // - this.buttonShowStorage.Location = new System.Drawing.Point(19, 383); + this.buttonShowStorage.Location = new System.Drawing.Point(21, 633); this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Size = new System.Drawing.Size(200, 47); @@ -103,7 +176,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(104, 672); + this.buttonDown.Location = new System.Drawing.Point(104, 817); this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(34, 40); @@ -116,7 +189,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(145, 672); + this.buttonRight.Location = new System.Drawing.Point(145, 817); this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(34, 40); @@ -129,7 +202,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(63, 672); + this.buttonLeft.Location = new System.Drawing.Point(63, 817); this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(34, 40); @@ -142,7 +215,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowUp; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(104, 624); + this.buttonUp.Location = new System.Drawing.Point(104, 769); this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(34, 40); @@ -152,7 +225,7 @@ // // buttonShowOnMap // - this.buttonShowOnMap.Location = new System.Drawing.Point(19, 521); + this.buttonShowOnMap.Location = new System.Drawing.Point(21, 700); this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Size = new System.Drawing.Size(200, 47); @@ -161,31 +234,16 @@ this.buttonShowOnMap.UseVisualStyleBackColor = true; this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); // - // buttonAddStorm + // buttonAddCar // - this.buttonAddStorm.Location = new System.Drawing.Point(19, 141); - this.buttonAddStorm.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonAddStorm.Name = "buttonAddStorm"; - this.buttonAddStorm.Size = new System.Drawing.Size(200, 47); - this.buttonAddStorm.TabIndex = 1; - this.buttonAddStorm.Text = "Добавить самолёт"; - this.buttonAddStorm.UseVisualStyleBackColor = true; - this.buttonAddStorm.Click += new System.EventHandler(this.ButtonAddStorm_Click); - // - // comboBoxSelectorMap - // - this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSelectorMap.FormattingEnabled = true; - this.comboBoxSelectorMap.Items.AddRange(new object[] { - "Простая карта", - "Ясное небо", - "Пасмурное небо"}); - this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 43); - this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(199, 28); - this.comboBoxSelectorMap.TabIndex = 0; - this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); + this.buttonAddCar.Location = new System.Drawing.Point(21, 443); + this.buttonAddCar.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonAddCar.Name = "buttonAddCar"; + this.buttonAddCar.Size = new System.Drawing.Size(200, 47); + this.buttonAddCar.TabIndex = 1; + this.buttonAddCar.Text = "Добавить самолёт"; + this.buttonAddCar.UseVisualStyleBackColor = true; + this.buttonAddCar.Click += new System.EventHandler(this.ButtonAddStorm_Click); // // pictureBox // @@ -193,7 +251,7 @@ this.pictureBox.Location = new System.Drawing.Point(0, 0); this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(927, 739); + this.pictureBox.Size = new System.Drawing.Size(927, 884); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // @@ -201,7 +259,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1160, 739); + this.ClientSize = new System.Drawing.Size(1160, 884); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); @@ -209,8 +267,11 @@ this.Text = "Карта с набором объектов"; this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.PerformLayout(); + this.groupBoxMaps.ResumeLayout(false); + this.groupBoxMaps.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.ResumeLayout(false); + } #endregion @@ -218,13 +279,18 @@ private PictureBox pictureBox; private ComboBox comboBoxSelectorMap; private Button buttonShowOnMap; - private Button buttonAddStorm; + private Button buttonAddCar; private Button buttonDown; private Button buttonRight; private Button buttonLeft; private Button buttonUp; private Button buttonShowStorage; - private Button buttonRemoveStorm; + private Button buttonRemoveCar; private MaskedTextBox maskedTextBoxPosition; + private GroupBox groupBoxMaps; + private ListBox listBoxMaps; + private Button buttonDeleteMap; + private Button buttonAddMap; + private TextBox textBoxNewMapName; } } \ No newline at end of file diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.cs b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.cs index 8398f1e..f956c5d 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.cs +++ b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.cs @@ -13,44 +13,30 @@ namespace Stormtrooper public partial class FormMapWithSetStormtroopers : Form { /// - /// Объект от класса карты с набором объектов + /// Словарь для выпадающего списка /// - private MapWithSetStormtroopersGeneric _mapStormtroopersCollectionGeneric; + private readonly Dictionary _mapsDict = new() + { + { "Простая карта", new SimpleMap() }, + {"Ясное небо", new SecondMap() }, + {"Пасмурное небо", new ThirdMap() } + }; + /// + /// Объект от коллекции карт + /// + private readonly MapsCollection _mapsCollection; + /// /// Конструктор /// public FormMapWithSetStormtroopers() { - InitializeComponent(); ; - } - /// - /// Выбор карты - /// - /// - /// - private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) - { - AbstractMap map = null; - switch (comboBoxSelectorMap.Text) + InitializeComponent(); + _mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height); + comboBoxSelectorMap.Items.Clear(); + foreach (var elem in _mapsDict) { - case "Простая карта": - map = new SimpleMap(); - break; - case "Ясное небо": - map = new SecondMap(); - break; - case "Пасмурное небо": - map = new ThirdMap(); - break; - } - if (map != null) - { - _mapStormtroopersCollectionGeneric = new MapWithSetStormtroopersGeneric( - pictureBox.Width, pictureBox.Height, map); - } - else - { - _mapStormtroopersCollectionGeneric = null; + comboBoxSelectorMap.Items.Add(elem.Key); } } /// @@ -60,18 +46,18 @@ namespace Stormtrooper /// private void ButtonAddStorm_Click(object sender, EventArgs e) { - if (_mapStormtroopersCollectionGeneric == null) + if (listBoxMaps.SelectedIndex == -1) { return; } FormStormtrooper form = new(); if (form.ShowDialog() == DialogResult.OK) { - DrawningObjectStorm car = new(form.SelectedStormtrooper); - if ((_mapStormtroopersCollectionGeneric + car) != -1) + DrawningObjectStorm airBomber = new(form.SelectedStormtrooper); + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + airBomber != -1) { MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { @@ -86,6 +72,10 @@ namespace Stormtrooper /// private void ButtonRemoveStorm_Click(object sender, EventArgs e) { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) { return; @@ -95,10 +85,10 @@ namespace Stormtrooper return; } int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if ((_mapStormtroopersCollectionGeneric - pos) != null) + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) { MessageBox.Show("Объект удален"); - pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { @@ -112,11 +102,11 @@ namespace Stormtrooper /// private void ButtonShowStorage_Click(object sender, EventArgs e) { - if (_mapStormtroopersCollectionGeneric == null) + if (listBoxMaps.SelectedIndex == -1) { return; } - pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } /// /// Вывод карты @@ -125,11 +115,11 @@ namespace Stormtrooper /// private void ButtonShowOnMap_Click(object sender, EventArgs e) { - if (_mapStormtroopersCollectionGeneric == null) + if (listBoxMaps.SelectedIndex == -1) { return; } - pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowOnMap(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap(); } /// /// Перемещение @@ -138,10 +128,6 @@ namespace Stormtrooper /// private void ButtonMove_Click(object sender, EventArgs e) { - if (_mapStormtroopersCollectionGeneric == null) - { - return; - } //получаем имя кнопки string name = ((Button)sender)?.Name ?? string.Empty; Direction dir = Direction.None; @@ -160,7 +146,61 @@ namespace Stormtrooper dir = Direction.Right; break; } - pictureBox.Image = _mapStormtroopersCollectionGeneric.MoveObject(dir); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir); + } + + private void ReloadMaps() + { + int index = listBoxMaps.SelectedIndex; + + listBoxMaps.Items.Clear(); + for (int i = 0; i < _mapsCollection.Keys.Count; i++) + { + listBoxMaps.Items.Add(_mapsCollection.Keys[i]); + } + + if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count)) + { + listBoxMaps.SelectedIndex = 0; + } + else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count) + { + listBoxMaps.SelectedIndex = index; + } + } + + private void ButtonAddMap_Click(object sender, EventArgs e) + { + if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text)) + { + MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text)) + { + MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]); + ReloadMaps(); + } + + private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e) + { + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + + private void ButtonDeleteMap_Click(object sender, EventArgs e) + { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + _mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty); + ReloadMaps(); + } } } } diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.resx b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.resx index 1af7de1..f298a7b 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.resx +++ b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.resx @@ -1,64 +1,4 @@ - - - +