diff --git a/ProjectSportCar/ProjectSportCar/FormPlanConfig.Designer.cs b/ProjectSportCar/ProjectSportCar/FormPlanConfig.Designer.cs index e7bd48b..5819661 100644 --- a/ProjectSportCar/ProjectSportCar/FormPlanConfig.Designer.cs +++ b/ProjectSportCar/ProjectSportCar/FormPlanConfig.Designer.cs @@ -293,7 +293,7 @@ labelAdditionalColor.Text = "Доп. цвет"; labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop; - labelAdditionalColor.DragEnter += LabelAdditionalColor_DragDrop; + labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter; // // labelBodyColor // diff --git a/ProjectSportCar/ProjectSportCar/FormPlanConfig.cs b/ProjectSportCar/ProjectSportCar/FormPlanConfig.cs index ec5fdfb..f4527b9 100644 --- a/ProjectSportCar/ProjectSportCar/FormPlanConfig.cs +++ b/ProjectSportCar/ProjectSportCar/FormPlanConfig.cs @@ -10,7 +10,7 @@ public partial class FormPlanConfig : Form /// /// Объект - прорисовка самолёта /// - private Drawningplane _plane=null; + private Drawningplane _plane = null; private event Action? PlaneDelegate; /// @@ -32,7 +32,7 @@ public partial class FormPlanConfig : Form } /// - /// Привязка внешнего метода к событию + /// Привязка внешнего метода к событию вопрос 2.............................................................................. /// public void AddEvent(Action planeDelegate) { @@ -133,11 +133,11 @@ public partial class FormPlanConfig : Form /// /// /// - 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; + } + } + } } diff --git a/ProjectSportCar/ProjectSportCar/FormPlaneCollection.cs b/ProjectSportCar/ProjectSportCar/FormPlaneCollection.cs index d6e05fe..30bf074 100644 --- a/ProjectSportCar/ProjectSportCar/FormPlaneCollection.cs +++ b/ProjectSportCar/ProjectSportCar/FormPlaneCollection.cs @@ -39,13 +39,13 @@ public partial class FormPlaneCollection : Form /// /// /// - 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); ////////////////////////////// }