Небольшие изменения.

This commit is contained in:
Павел Сорокин 2022-11-02 10:33:43 +04:00
parent 6999084ee6
commit a576085d7a
2 changed files with 6 additions and 4 deletions

View File

@ -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
//

View File

@ -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)