Исправлен делегат и cancel

This commit is contained in:
nikos77781 2024-04-22 17:53:15 +04:00
parent 5dfd8684dd
commit bc218c4adf
3 changed files with 5 additions and 16 deletions

View File

@ -1,10 +0,0 @@
using Excavator.Drawnings;
namespace Excavator;
/// <summary>
/// Делегат передачи объекта класса-прорисовки
/// </summary>
/// <param name="excavator"></param>
public delegate void ExcavatorDelegate(DrawningSimpleExcavator excavator);

View File

@ -35,7 +35,7 @@ public partial class FormExcavatorCollection : Form
return; return;
} }
FormExcavatorConfig form = new(); FormExcavatorConfig form = new();
form.ExcavatorDelegate += SetExcavator; form._excavatorDelegate += SetExcavator;
form.Show(); form.Show();
} }

View File

@ -1,6 +1,5 @@
using Excavator.Drawnings; using Excavator.Drawnings;
using Excavator.Entities; using Excavator.Entities;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
namespace Excavator; namespace Excavator;
/// <summary> /// <summary>
@ -13,7 +12,7 @@ public partial class FormExcavatorConfig : Form
/// <summary> /// <summary>
/// Событие для передачи объекта /// Событие для передачи объекта
/// </summary> /// </summary>
public event ExcavatorDelegate? ExcavatorDelegate; public event Action<DrawningSimpleExcavator>? _excavatorDelegate;
public FormExcavatorConfig() public FormExcavatorConfig()
{ {
@ -35,9 +34,9 @@ public partial class FormExcavatorConfig : Form
/// Привязка внешнего метода к событию /// Привязка внешнего метода к событию
/// </summary> /// </summary>
/// <param name="truckDelegate"></param> /// <param name="truckDelegate"></param>
public void AddEvent(ExcavatorDelegate excavatorDelegate) public void AddEvent(Action<DrawningSimpleExcavator>? excavatorDelegate)
{ {
ExcavatorDelegate += excavatorDelegate; _excavatorDelegate += excavatorDelegate;
} }
/// <summary> /// <summary>
@ -108,7 +107,7 @@ public partial class FormExcavatorConfig : Form
{ {
if (_excavator != null) if (_excavator != null)
{ {
ExcavatorDelegate?.Invoke(_excavator); _excavatorDelegate?.Invoke(_excavator);
Close(); Close();
} }
} }