From a576085d7a95c4d37f6dd525529b4eaf2605e99a Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Wed, 2 Nov 2022 10:33:43 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/FormShipConfig.Designer.cs | 2 +- Liner/Liner/FormShipConfig.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Liner/Liner/FormShipConfig.Designer.cs b/Liner/Liner/FormShipConfig.Designer.cs index 44ad4be..5c597eb 100644 --- a/Liner/Liner/FormShipConfig.Designer.cs +++ b/Liner/Liner/FormShipConfig.Designer.cs @@ -287,7 +287,7 @@ this.LabelDopColor.Text = "Доп. цвет"; this.LabelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.LabelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop); - this.LabelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter); + this.LabelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragEnter); // // LabelBaseColor // diff --git a/Liner/Liner/FormShipConfig.cs b/Liner/Liner/FormShipConfig.cs index e39ac7e..5814faa 100644 --- a/Liner/Liner/FormShipConfig.cs +++ b/Liner/Liner/FormShipConfig.cs @@ -80,9 +80,9 @@ namespace Liner } DrawShip(); } - private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) + private void setDragEffect(DragEventArgs e, Type needTypeData, bool condition) { - if (e.Data.GetDataPresent(typeof(Color))) + if (e.Data.GetDataPresent(needTypeData) && condition) { e.Effect = DragDropEffects.Copy; } @@ -91,11 +91,13 @@ namespace Liner e.Effect = DragDropEffects.None; } } + private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) => setDragEffect(e, typeof(Color), _ship != null); + private void LabelDopColor_DragEnter(object sender, DragEventArgs e) => setDragEffect(e, typeof(Color), _ship != null && _ship is DrawningLiner); private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { _ship.SetColor((Color)e.Data.GetData(typeof(Color))); DrawShip(); - } + } private void LabelDopColor_DragDrop(object sender, DragEventArgs e) { if (_ship is not DrawningLiner liner)