diff --git a/Bus/Bus/DrawingBus.cs b/Bus/Bus/DrawingBus.cs index f8924a1..4a13fe0 100644 --- a/Bus/Bus/DrawingBus.cs +++ b/Bus/Bus/DrawingBus.cs @@ -1,4 +1,4 @@ -using System; +using Bus; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs index 0150735..acc98b1 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs @@ -80,7 +80,7 @@ namespace Bus private void ButtonAddBus_Click(object sender, EventArgs e) { - if (_mapBusCollectionGeneric == null) + if (listBoxMaps.SelectedIndex == -1) { return; } @@ -94,11 +94,10 @@ namespace Bus } DrawingObjectBus bus = new(form.SelectedBus); - - if (_mapBusCollectionGeneric + bus != -1) + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + bus != -1) { MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { @@ -109,20 +108,27 @@ namespace Bus private void ButtonRemoveBus_Click(object sender, EventArgs e) { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) { return; } + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } + int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_mapBusCollectionGeneric - pos != null) + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) { MessageBox.Show("Объект удален"); - pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else {