From c578482ba0499b9b4eae1d7c4b026eb66d650cf1 Mon Sep 17 00:00:00 2001 From: Baryshev Dmitry Date: Wed, 17 Apr 2024 12:30:47 +0400 Subject: [PATCH] e boi it works --- .../FormTruckConfig.Designer.cs | 7 ++++-- .../ProjectDumpTruck/FormTruckConfig.cs | 23 ++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.Designer.cs b/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.Designer.cs index b71b8b1..01dd0c4 100644 --- a/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.Designer.cs +++ b/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.Designer.cs @@ -183,6 +183,7 @@ // // panelRed // + panelRed.AllowDrop = true; panelRed.BackColor = Color.Red; panelRed.Location = new Point(15, 26); panelRed.Name = "panelRed"; @@ -312,6 +313,7 @@ // // labelAdditionalColor // + labelAdditionalColor.AllowDrop = true; labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; labelAdditionalColor.Location = new Point(122, 9); labelAdditionalColor.Name = "labelAdditionalColor"; @@ -324,6 +326,7 @@ // // labelBaseColor // + labelBaseColor.AllowDrop = true; labelBaseColor.BorderStyle = BorderStyle.FixedSingle; labelBaseColor.Location = new Point(14, 9); labelBaseColor.Name = "labelBaseColor"; @@ -331,8 +334,8 @@ labelBaseColor.TabIndex = 2; labelBaseColor.Text = "Цвет"; labelBaseColor.TextAlign = ContentAlignment.MiddleCenter; - labelBaseColor.DragDrop += LabelBaseColor_DragDrop; - labelBaseColor.DragEnter += LabelBaseColor_DragEnter; + labelBaseColor.DragDrop += LabelBodyColor_DragDrop; + labelBaseColor.DragEnter += LabelBodyColor_DragEnter; // // FormTruckConfig // diff --git a/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.cs b/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.cs index 7eb92fe..7fb8495 100644 --- a/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.cs +++ b/ProjectDumpTruck/ProjectDumpTruck/FormTruckConfig.cs @@ -47,7 +47,7 @@ public partial class FormTruckConfig : Form panelBlack.MouseDown += Panel_MouseDown; panelWhite.MouseDown += Panel_MouseDown; - + buttonCancel.Click += (sender, e) => Close(); @@ -139,23 +139,20 @@ public partial class FormTruckConfig : Form } } - private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + /// + /// Действия при приеме перетаскиваемой информации(Основной цвет) + /// + /// + /// + private void LabelBodyColor_DragDrop(object sender, DragEventArgs e) { - if (_truck == null) return; - _truck.EntityTruck?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + _truck?.EntityTruck?.SetBodyColor((Color)e.Data?.GetData(typeof(Color))); DrawObject(); } - private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) + private void LabelBodyColor_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(typeof(Color))) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } + e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None; } private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)