diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.Designer.cs index ff885cb..5590d17 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.Designer.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.Designer.cs @@ -298,8 +298,8 @@ labelAdditionalColor.TabIndex = 10; labelAdditionalColor.Text = "Доп. цвет"; labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; - labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop; - labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter; + labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop; + labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter; // // labelBodyColor // @@ -311,8 +311,8 @@ labelBodyColor.TabIndex = 9; labelBodyColor.Text = "Цвет"; labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; - labelBodyColor.DragDrop += labelBodyColor_DragDrop; - labelBodyColor.DragEnter += labelBodyColor_DragEnter; + labelBodyColor.DragDrop += LabelBodyColor_DragDrop; + labelBodyColor.DragEnter += LabelBodyColor_DragEnter; // // FormAirCraftConfig // diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.cs b/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.cs index 76486fa..89b8aac 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormAirCraftConfig.cs @@ -110,26 +110,26 @@ public partial class FormAirCraftConfig : Form { (sender as Control)?.DoDragDrop((sender as Control)?.BackColor!, DragDropEffects.Move | DragDropEffects.Copy); } - private void labelBodyColor_DragDrop(object sender, DragEventArgs e) + private void LabelBodyColor_DragDrop(object sender, DragEventArgs e) { if (_aircraft == null) return; _aircraft.EntityAirCraft?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); DrawObject(); } - private void labelBodyColor_DragEnter(object sender, DragEventArgs e) + private void LabelBodyColor_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy; + if (_aircraft != null && e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } - private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) + private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e) { - if (_aircraft?.EntityAirCraft is EntityAirFighter _airfighter) - _airfighter?.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); + if (_aircraft != null && _aircraft.EntityAirCraft is EntityAirFighter _airfighter) + _airfighter.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); DrawObject(); } - private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) + private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy; + if (_aircraft != null && e.Data.GetDataPresent(typeof(Color)) && _aircraft.EntityAirCraft is EntityAirFighter) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; }