diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.Designer.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.Designer.cs index d4b13ef..f851898 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.Designer.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.Designer.cs @@ -90,6 +90,7 @@ // // labelAdvancedObject // + labelAdvancedObject.AllowDrop = true; labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle; labelAdvancedObject.Location = new Point(324, 175); labelAdvancedObject.Name = "labelAdvancedObject"; @@ -101,6 +102,7 @@ // // labelSimpleObject // + labelSimpleObject.AllowDrop = true; labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; labelSimpleObject.Location = new Point(181, 174); labelSimpleObject.Name = "labelSimpleObject"; @@ -129,6 +131,7 @@ // // panelColorPurple // + panelColorPurple.AllowDrop = true; panelColorPurple.BackColor = Color.Purple; panelColorPurple.Location = new Point(199, 84); panelColorPurple.Name = "panelColorPurple"; @@ -137,6 +140,7 @@ // // panelColorBlack // + panelColorBlack.AllowDrop = true; panelColorBlack.BackColor = Color.Black; panelColorBlack.Location = new Point(143, 84); panelColorBlack.Name = "panelColorBlack"; @@ -145,6 +149,7 @@ // // panelColorGray // + panelColorGray.AllowDrop = true; panelColorGray.BackColor = Color.Silver; panelColorGray.Location = new Point(87, 84); panelColorGray.Name = "panelColorGray"; @@ -153,6 +158,7 @@ // // panelColorWhite // + panelColorWhite.AllowDrop = true; panelColorWhite.BackColor = Color.White; panelColorWhite.Location = new Point(31, 84); panelColorWhite.Name = "panelColorWhite"; @@ -161,6 +167,7 @@ // // panelColorYellow // + panelColorYellow.AllowDrop = true; panelColorYellow.BackColor = Color.Yellow; panelColorYellow.Location = new Point(199, 28); panelColorYellow.Name = "panelColorYellow"; @@ -169,6 +176,7 @@ // // panelColorBlue // + panelColorBlue.AllowDrop = true; panelColorBlue.BackColor = Color.Blue; panelColorBlue.Location = new Point(143, 28); panelColorBlue.Name = "panelColorBlue"; @@ -177,6 +185,7 @@ // // panelColorGreen // + panelColorGreen.AllowDrop = true; panelColorGreen.BackColor = Color.FromArgb(0, 192, 0); panelColorGreen.Location = new Point(87, 28); panelColorGreen.Name = "panelColorGreen"; @@ -185,6 +194,7 @@ // // panelColorRed // + panelColorRed.AllowDrop = true; panelColorRed.BackColor = Color.Red; panelColorRed.Location = new Point(31, 28); panelColorRed.Name = "panelColorRed"; @@ -257,10 +267,13 @@ panelWithPictureBox.Location = new Point(482, 12); panelWithPictureBox.Name = "panelWithPictureBox"; panelWithPictureBox.Size = new Size(316, 195); - panelWithPictureBox.TabIndex = 2; + panelWithPictureBox.TabIndex = 1; + panelWithPictureBox.DragDrop += PanelObject_DragDrop; + panelWithPictureBox.DragEnter += PanelObject_DragEnter; // // labelAdvancedColor // + labelAdvancedColor.AllowDrop = true; labelAdvancedColor.BorderStyle = BorderStyle.FixedSingle; labelAdvancedColor.Location = new Point(159, 10); labelAdvancedColor.Name = "labelAdvancedColor"; @@ -273,6 +286,7 @@ // // labelSimpleColor // + labelSimpleColor.AllowDrop = true; labelSimpleColor.BorderStyle = BorderStyle.FixedSingle; labelSimpleColor.Location = new Point(14, 10); labelSimpleColor.Name = "labelSimpleColor"; diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs index 88f472d..ee2f971 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs @@ -51,7 +51,6 @@ namespace ProjectElectricLocomotive _locomotive?.DrawTransport(gr); pictureBoxLoco.Image = bmp; } - private void LabelObject_MouseDown(object sender, MouseEventArgs e) { (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); @@ -85,27 +84,25 @@ namespace ProjectElectricLocomotive } DrawLocomotive(); } - private void buttonAddObject_Click(object sender, EventArgs e) { EventAddLocomotive?.Invoke(_locomotive); Close(); } - private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, + DragDropEffects.Move | DragDropEffects.Copy); } - private void LabelColor_DragDrop(object sender, DragEventArgs e) { ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color)); switch (((Label)sender).Name) { - case "labelColor": + case "labelSimpleObject": _locomotive.SetColor((Color)e.Data.GetData(typeof(Color))); break; - case "labelAddColor": + case "labelAdvancedObject": if (_locomotive is not DrawingLocomotive) return; else { @@ -115,7 +112,6 @@ namespace ProjectElectricLocomotive } DrawLocomotive(); } - private void LabelColor_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Color)))