изменено по использование встроенного делегата

This commit is contained in:
vkobi 2024-04-23 10:39:23 +04:00
parent 0d7e4052f5
commit 6b9a17243f
2 changed files with 6 additions and 4 deletions

View File

@ -44,6 +44,10 @@ public partial class FormLocomotiveCollection : Form
/// <param name="e"></param>
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
{
if(_company == null)
{
return;
}
FormLocomotiveConfig form = new();
// TODO передать метод
form.AddEvent(SetLocomotive);

View File

@ -16,7 +16,7 @@ public partial class FormLocomotiveConfig : Form
/// <summary>
/// Событие для передачи объекта
/// </summary>
private event LocomotiveDelegate? LocomotiveDelegate;
private event Action<DrawningLocomotive>? LocomotiveDelegate;
/// <summary>
/// Конструктор
@ -34,15 +34,13 @@ public partial class FormLocomotiveConfig : Form
panelBlue.MouseDown += Panel_MouseDown;
buttonCancel.Click += (events, e) => Close();
}
/// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="locomotiveDelegate"></param>
public void AddEvent(LocomotiveDelegate locomotiveDelegate)
public void AddEvent(Action<DrawningLocomotive> locomotiveDelegate)
{
LocomotiveDelegate += locomotiveDelegate;
}