Исправлен делегат и 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;
}
FormExcavatorConfig form = new();
form.ExcavatorDelegate += SetExcavator;
form._excavatorDelegate += SetExcavator;
form.Show();
}

View File

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