diff --git a/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs b/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs index e821865..cbf17ab 100644 --- a/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs +++ b/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs @@ -88,24 +88,27 @@ namespace WarmlyShip } private void ButtonAddShip_Click(object sender, EventArgs e) + { + FormShipConfig formShipConfig = new(); + formShipConfig.AddEvent(AddShip); + formShipConfig.Show(); + } + + private void AddShip(DrawingWarmlyShip ship) { if (listBoxMaps.SelectedIndex == -1) { return; } - FormClass form = new(); - if (form.ShowDialog() == DialogResult.OK) + + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectShip(ship) > -1) { - DrawningObjectShip ship = new(form.SelectedShip); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + ship > -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); } }