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.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop; labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += LabelAdditionalColor_DragDrop; labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
// //
// labelBodyColor // labelBodyColor
// //

View File

@ -32,7 +32,7 @@ public partial class FormPlanConfig : Form
} }
/// <summary> /// <summary>
/// Привязка внешнего метода к событию /// Привязка внешнего метода к событию вопрос 2..............................................................................
/// </summary> /// </summary>
public void AddEvent(Action<Drawningplane> planeDelegate) public void AddEvent(Action<Drawningplane> planeDelegate)
{ {
@ -133,11 +133,11 @@ public partial class FormPlanConfig : Form
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></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) if (_plane != null)
{ {
PlaneDelegate?.Invoke(_plane); PlaneDelegate?.Invoke(_plane); //Вызов события, с помощью инвок,
Close(); Close();
} }
} }
@ -155,4 +155,19 @@ public partial class FormPlanConfig : Form
} }
DrawObject(); 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> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></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(); FormPlanConfig form = new();
// TODO передать метод // TODO передать метод
form.Show(); form.Show();
form.AddEvent(SetPlane); form.AddEvent(SetPlane); //////////////////////////////
} }