diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs index 8784862..e458376 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -30,7 +30,10 @@ namespace HoistingCrane break; case "Вторая карта": map = new SecondMap(); - break; + break; + + + } if (map != null) { @@ -47,24 +50,26 @@ namespace HoistingCrane { if (_mapHoistingCraneCollectionGeneric == null) { - return; - } - FormHoistingCrane form = new(); - if (form.ShowDialog() == DialogResult.OK) + var formHoistingCraneConfig = new FormHoistingCraneConfig(); + formHoistingCraneConfig.AddEvent(AddHoistingCrane); + formHoistingCraneConfig.Show(); + } + private void AddHoistingCrane(DrawingHoistingCrane drawingHoistingCrane) + { + DrawingObjectHoistingCrane hoistingCrane = new DrawingObjectHoistingCrane(drawingHoistingCrane); + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + hoistingCrane != -1) { - DrawingObjectHoistingCrane hoistingCrane = new(form.SelectedHoistingCrane); - if (_mapHoistingCraneCollectionGeneric + hoistingCrane == 1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); } } - + } + } + } private void ButtonRemoveHoistingCrane_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))