This commit is contained in:
Aleksandr4350 2024-05-22 22:22:15 +04:00
parent 63a8f431dc
commit cf26999d5d
3 changed files with 22 additions and 7 deletions

View File

@ -293,7 +293,7 @@
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += LabelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
//
// labelBodyColor
//

View File

@ -10,7 +10,7 @@ public partial class FormPlanConfig : Form
/// <summary>
/// Объект - прорисовка самолёта
/// </summary>
private Drawningplane _plane=null;
private Drawningplane _plane = null;
private event Action<Drawningplane>? PlaneDelegate;
/// <summary>
@ -32,7 +32,7 @@ public partial class FormPlanConfig : Form
}
/// <summary>
/// Привязка внешнего метода к событию
/// Привязка внешнего метода к событию вопрос 2..............................................................................
/// </summary>
public void AddEvent(Action<Drawningplane> planeDelegate)
{
@ -133,11 +133,11 @@ public partial class FormPlanConfig : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAdd_Click(object sender, EventArgs e)
private void ButtonAdd_Click(object sender, EventArgs e)// кнопку нажимаем и новый объект передается в форму 2 вопрос............
{
if (_plane != null)
{
PlaneDelegate?.Invoke(_plane);
PlaneDelegate?.Invoke(_plane); //Вызов события, с помощью инвок,
Close();
}
}
@ -155,4 +155,19 @@ public partial class FormPlanConfig : Form
}
DrawObject();
}
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_plane != null && _plane is DrawningAiroplane)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
}

View File

@ -39,13 +39,13 @@ public partial class FormPlaneCollection : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddPlane_Click(object sender, EventArgs e)
private void ButtonAddPlane_Click(object sender, EventArgs e)//вопрос 2 ...........................................................
{
FormPlanConfig form = new();
// TODO передать метод
form.Show();
form.AddEvent(SetPlane);
form.AddEvent(SetPlane); //////////////////////////////
}