e boi it works

This commit is contained in:
Baryshev Dmitry 2024-04-17 12:30:47 +04:00
parent d551b7b9e0
commit c578482ba0
2 changed files with 15 additions and 15 deletions

View File

@ -183,6 +183,7 @@
// //
// panelRed // panelRed
// //
panelRed.AllowDrop = true;
panelRed.BackColor = Color.Red; panelRed.BackColor = Color.Red;
panelRed.Location = new Point(15, 26); panelRed.Location = new Point(15, 26);
panelRed.Name = "panelRed"; panelRed.Name = "panelRed";
@ -312,6 +313,7 @@
// //
// labelAdditionalColor // labelAdditionalColor
// //
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(122, 9); labelAdditionalColor.Location = new Point(122, 9);
labelAdditionalColor.Name = "labelAdditionalColor"; labelAdditionalColor.Name = "labelAdditionalColor";
@ -324,6 +326,7 @@
// //
// labelBaseColor // labelBaseColor
// //
labelBaseColor.AllowDrop = true;
labelBaseColor.BorderStyle = BorderStyle.FixedSingle; labelBaseColor.BorderStyle = BorderStyle.FixedSingle;
labelBaseColor.Location = new Point(14, 9); labelBaseColor.Location = new Point(14, 9);
labelBaseColor.Name = "labelBaseColor"; labelBaseColor.Name = "labelBaseColor";
@ -331,8 +334,8 @@
labelBaseColor.TabIndex = 2; labelBaseColor.TabIndex = 2;
labelBaseColor.Text = "Цвет"; labelBaseColor.Text = "Цвет";
labelBaseColor.TextAlign = ContentAlignment.MiddleCenter; labelBaseColor.TextAlign = ContentAlignment.MiddleCenter;
labelBaseColor.DragDrop += LabelBaseColor_DragDrop; labelBaseColor.DragDrop += LabelBodyColor_DragDrop;
labelBaseColor.DragEnter += LabelBaseColor_DragEnter; labelBaseColor.DragEnter += LabelBodyColor_DragEnter;
// //
// FormTruckConfig // FormTruckConfig
// //

View File

@ -47,7 +47,7 @@ public partial class FormTruckConfig : Form
panelBlack.MouseDown += Panel_MouseDown; panelBlack.MouseDown += Panel_MouseDown;
panelWhite.MouseDown += Panel_MouseDown; panelWhite.MouseDown += Panel_MouseDown;
buttonCancel.Click += (sender, e) => Close(); buttonCancel.Click += (sender, e) => Close();
@ -139,23 +139,20 @@ public partial class FormTruckConfig : Form
} }
} }
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) /// <summary>
/// Действия при приеме перетаскиваемой информации(Основной цвет)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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(); 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 = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
{
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)