Исправление

Привязка внешнего метода к событию
This commit is contained in:
zolotovart 2024-04-23 10:56:17 +03:00
parent 7ecb2de056
commit e482bb84d2

View File

@ -26,7 +26,7 @@ public partial class FormShipConfig : Form
/// <summary>
/// Событие для передачи объекта
/// </summary>
private event ShipDelegate? ShipDelegate;
public event Action<DrawingShip>? _shipDelegate;
/// <summary>
/// Конструктор
/// </summary>
@ -45,12 +45,12 @@ public partial class FormShipConfig : Form
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Привязка внешнего метода и событие
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="shipDelegate"></param>
public void AddEvent(ShipDelegate shipDelegate)
public void AddEvent(Action<DrawingShip>? shipDelegate)
{
ShipDelegate += shipDelegate;
_shipDelegate += shipDelegate;
}
/// <summary>
@ -123,7 +123,7 @@ public partial class FormShipConfig : Form
{
if (_ship != null)
{
ShipDelegate?.Invoke(_ship);
_shipDelegate?.Invoke(_ship);
Close();
}
}