diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs b/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs index 8624783..362a990 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs @@ -86,26 +86,8 @@ namespace AirPlaneWithRadar private void ButtonAddPlain_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) - { - return; - } - - FormPlain form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - DrawingObjectPlane plain = new(form.SelectedPlain); - - if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + plain) >= 0) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + var formPlainConfig = new FormPlaneConfig(); + formPlainConfig.Show(); } private void ButtonRemovePlain_Click(object sender, EventArgs e) { diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlaneConfig.cs b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlaneConfig.cs index 71f0a2f..09f136f 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlaneConfig.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlaneConfig.cs @@ -14,7 +14,7 @@ namespace AirPlaneWithRadar { DrawingPlain _Plane = null; - + private event PlainDelegate EventAddPlane; public FormPlaneConfig() { @@ -40,7 +40,17 @@ namespace AirPlaneWithRadar pictureBoxObject.Image = bmp; } - + public void AddEvent(PlainDelegate ev) + { + if (EventAddPlane == null) + { + EventAddPlane = ev; + } + else + { + EventAddPlane += ev; + } + } private void LabelObject_MouseDown(object sender, MouseEventArgs e) { @@ -119,7 +129,11 @@ namespace AirPlaneWithRadar } - + private void ButtonOk_Click(object sender, EventArgs e) + { + EventAddPlane?.Invoke(_Plane); + Close(); + } } } diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/PlainDelegate.cs b/AirPlaneWithRadar/AirPlaneWithRadar/PlainDelegate.cs new file mode 100644 index 0000000..c026b64 --- /dev/null +++ b/AirPlaneWithRadar/AirPlaneWithRadar/PlainDelegate.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirPlaneWithRadar +{ + public delegate void PlainDelegate(DrawingPlain car); +}