Изменение на встроенный делегат

This commit is contained in:
Evgehil 2024-04-05 10:56:56 +04:00
parent c3388eacb4
commit 6316a59bdd

View File

@ -3,17 +3,20 @@ using Project_airbus.Entities;
namespace Project_airbus; namespace Project_airbus;
/// <summary>
/// Форма конфигурации объекта
/// </summary>
public partial class FormAirplanConfig : Form public partial class FormAirplanConfig : Form
{ {
/// <summary> /// <summary>
/// Объект - прорисовка самолёта /// Объект - прорисовка самолёта
/// </summary> /// </summary>
private DrawingAirplan? _airplan = null; private DrawingAirplan? _airplan;
/// <summary> /// <summary>
/// Событие для передачи объекта /// Событие для передачи объекта
/// </summary> /// </summary>
private event AirplanDelegate? AirplanDelegate; private event Action<DrawingAirplan> _airplanDelegate;
/// <summary> /// <summary>
/// Конструктор /// Конструктор
@ -37,9 +40,9 @@ public partial class FormAirplanConfig : Form
/// Привязка внешнего метода к событию /// Привязка внешнего метода к событию
/// </summary> /// </summary>
/// <param name="airplanDelegate"></param> /// <param name="airplanDelegate"></param>
public void AddEvent(AirplanDelegate airplanDelegate) public void AddEvent(Action<DrawingAirplan> airplanDelegate)
{ {
AirplanDelegate += airplanDelegate; _airplanDelegate += airplanDelegate;
} }
/// <summary> /// <summary>
@ -106,6 +109,11 @@ public partial class FormAirplanConfig : Form
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); (sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
} }
/// <summary>
/// Передача основного цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelBodyColor_DragEnter(object sender, DragEventArgs e) private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data.GetDataPresent(typeof(Color))) if (e.Data.GetDataPresent(typeof(Color)))
@ -117,6 +125,12 @@ public partial class FormAirplanConfig : Form
e.Effect = DragDropEffects.None; e.Effect = DragDropEffects.None;
} }
} }
/// <summary>
/// Прорисовка с основным цветом
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelBodyColor_DragDrop(object sender, DragEventArgs e) private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{ {
if (_airplan != null) if (_airplan != null)
@ -125,6 +139,12 @@ public partial class FormAirplanConfig : Form
DrawObject(); DrawObject();
} }
} }
/// <summary>
/// Передача дополнительного цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{ {
if (_airplan is DrawingAirbus) if (_airplan is DrawingAirbus)
@ -140,6 +160,11 @@ public partial class FormAirplanConfig : Form
} }
} }
/// <summary>
/// Прорисовка с дополнительным цветом
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{ {
if (_airplan?.EntityAirplan is EntityAirbus _airbus) if (_airplan?.EntityAirplan is EntityAirbus _airbus)
@ -158,7 +183,7 @@ public partial class FormAirplanConfig : Form
{ {
if (_airplan != null) if (_airplan != null)
{ {
AirplanDelegate?.Invoke(_airplan); _airplanDelegate?.Invoke(_airplan);
Close(); Close();
} }
} }