изменено по использование встроенного делегата
This commit is contained in:
parent
0d7e4052f5
commit
6b9a17243f
@ -44,6 +44,10 @@ public partial class FormLocomotiveCollection : Form
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
|
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if(_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
FormLocomotiveConfig form = new();
|
FormLocomotiveConfig form = new();
|
||||||
// TODO передать метод
|
// TODO передать метод
|
||||||
form.AddEvent(SetLocomotive);
|
form.AddEvent(SetLocomotive);
|
||||||
|
@ -16,7 +16,7 @@ public partial class FormLocomotiveConfig : Form
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Событие для передачи объекта
|
/// Событие для передачи объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private event LocomotiveDelegate? LocomotiveDelegate;
|
private event Action<DrawningLocomotive>? LocomotiveDelegate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -34,15 +34,13 @@ public partial class FormLocomotiveConfig : Form
|
|||||||
panelBlue.MouseDown += Panel_MouseDown;
|
panelBlue.MouseDown += Panel_MouseDown;
|
||||||
|
|
||||||
buttonCancel.Click += (events, e) => Close();
|
buttonCancel.Click += (events, e) => Close();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Привязка внешнего метода к событию
|
/// Привязка внешнего метода к событию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="locomotiveDelegate"></param>
|
/// <param name="locomotiveDelegate"></param>
|
||||||
public void AddEvent(LocomotiveDelegate locomotiveDelegate)
|
public void AddEvent(Action<DrawningLocomotive> locomotiveDelegate)
|
||||||
{
|
{
|
||||||
LocomotiveDelegate += locomotiveDelegate;
|
LocomotiveDelegate += locomotiveDelegate;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user