diff --git a/WarmlyShip/WarmlyShip/FormLinerConfig.cs b/WarmlyShip/WarmlyShip/FormLinerConfig.cs
index af227ef..dcf9a84 100644
--- a/WarmlyShip/WarmlyShip/FormLinerConfig.cs
+++ b/WarmlyShip/WarmlyShip/FormLinerConfig.cs
@@ -20,6 +20,10 @@ namespace WarmlyShip
///
DrawningShip _ship = null;
///
+ /// Событие
+ ///
+ private event ShipDelegate EventAddShip;
+ ///
/// Конструктор
///
public FormLinerConfig()
@@ -33,6 +37,9 @@ namespace WarmlyShip
panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
+
+ // TODO buttonCancel.Click with lambda
+
}
///
/// Отрисовать машину
@@ -46,6 +53,22 @@ namespace WarmlyShip
pictureBoxObject.Image = bmp;
}
+ ///
+ /// Добавление события
+ ///
+ ///
+ public void AddEvent(ShipDelegate ev)
+ {
+ if (EventAddShip == null)
+ {
+ EventAddShip = new ShipDelegate(ev);
+ }
+ else
+ {
+ EventAddShip += ev;
+ }
+ }
+
///
/// Передаем информацию при нажатии на Label
///
@@ -136,5 +159,16 @@ namespace WarmlyShip
// TODO Call method from object _car if _car is DrawningSportCar and set dop color
}
+ ///
+ /// Добавление машины
+ ///
+ ///
+ ///
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ EventAddShip?.Invoke(_ship);
+ Close();
+ }
+
}
}
diff --git a/WarmlyShip/WarmlyShip/FormMapWithSetWarmlyShip.cs b/WarmlyShip/WarmlyShip/FormMapWithSetWarmlyShip.cs
index 8d0efef..5994928 100644
--- a/WarmlyShip/WarmlyShip/FormMapWithSetWarmlyShip.cs
+++ b/WarmlyShip/WarmlyShip/FormMapWithSetWarmlyShip.cs
@@ -26,13 +26,6 @@ namespace WarmlyShip
///
private readonly MapsCollection _mapsCollection;
-
- /////
- ///// Объект от класса карты с набором объектов
- /////
- //private MapWithSetWarmlyShipGeneric _mapWarmlyShipCollectionGeneric;
-
-
///
/// Конструктор
///
@@ -96,35 +89,6 @@ namespace WarmlyShip
pictureBox1.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
- /////
- ///// Выбор карты
- /////
- /////
- /////
- //private void ComboBoxSelectorShip_SelectedIndexChanged(object sender, EventArgs e)
- //{
- // AbstractMap map = null;
- // switch (comboBoxSelectorMap.Text)
- // {
- // case "Простая карта":
- // map = new SimpleMap();
- // break;
- // case "Море":
- // map = new MyMap();
- // break;
- // }
- // if (map != null)
- // {
- // _mapWarmlyShipCollectionGeneric = new MapWithSetWarmlyShipGeneric(
- // pictureBox1.Width, pictureBox1.Height, map);
- // }
- // else
- // {
- // _mapWarmlyShipCollectionGeneric = null;
- // }
-
- //}
-
///
/// Удаление карты
///
@@ -149,24 +113,9 @@ namespace WarmlyShip
///
private void ButtonAddShip_Click(object sender, EventArgs e)
{
- if (listBoxMaps.SelectedIndex == -1)
- {
- return;
- }
- FormShip form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- DrawningObjectShip ship = new(form.SelectedShip);
- if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + ship!=null)
- {
- MessageBox.Show("Объект добавлен");
- pictureBox1.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
- }
+ var formCarConfig = new FormLinerConfig();
+ // TODO Call method AddEvent from formCarConfig
+ formCarConfig.Show();
}
diff --git a/WarmlyShip/WarmlyShip/ShipDelegate.cs b/WarmlyShip/WarmlyShip/ShipDelegate.cs
new file mode 100644
index 0000000..ac9dcdc
--- /dev/null
+++ b/WarmlyShip/WarmlyShip/ShipDelegate.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WarmlyShip
+{
+ ///
+ /// Делегат для передачи объекта-автомобиля
+ ///
+ ///
+ public delegate void ShipDelegate(DrawningShip Ship);
+
+}