Правки / Поиск ошибок

This commit is contained in:
Андрей Байгулов 2023-11-12 21:46:24 +04:00
parent a63bca3d27
commit 0feb1800b4
2 changed files with 19 additions and 9 deletions

View File

@ -90,6 +90,7 @@
// //
// labelAdvancedObject // labelAdvancedObject
// //
labelAdvancedObject.AllowDrop = true;
labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle; labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle;
labelAdvancedObject.Location = new Point(324, 175); labelAdvancedObject.Location = new Point(324, 175);
labelAdvancedObject.Name = "labelAdvancedObject"; labelAdvancedObject.Name = "labelAdvancedObject";
@ -101,6 +102,7 @@
// //
// labelSimpleObject // labelSimpleObject
// //
labelSimpleObject.AllowDrop = true;
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(181, 174); labelSimpleObject.Location = new Point(181, 174);
labelSimpleObject.Name = "labelSimpleObject"; labelSimpleObject.Name = "labelSimpleObject";
@ -129,6 +131,7 @@
// //
// panelColorPurple // panelColorPurple
// //
panelColorPurple.AllowDrop = true;
panelColorPurple.BackColor = Color.Purple; panelColorPurple.BackColor = Color.Purple;
panelColorPurple.Location = new Point(199, 84); panelColorPurple.Location = new Point(199, 84);
panelColorPurple.Name = "panelColorPurple"; panelColorPurple.Name = "panelColorPurple";
@ -137,6 +140,7 @@
// //
// panelColorBlack // panelColorBlack
// //
panelColorBlack.AllowDrop = true;
panelColorBlack.BackColor = Color.Black; panelColorBlack.BackColor = Color.Black;
panelColorBlack.Location = new Point(143, 84); panelColorBlack.Location = new Point(143, 84);
panelColorBlack.Name = "panelColorBlack"; panelColorBlack.Name = "panelColorBlack";
@ -145,6 +149,7 @@
// //
// panelColorGray // panelColorGray
// //
panelColorGray.AllowDrop = true;
panelColorGray.BackColor = Color.Silver; panelColorGray.BackColor = Color.Silver;
panelColorGray.Location = new Point(87, 84); panelColorGray.Location = new Point(87, 84);
panelColorGray.Name = "panelColorGray"; panelColorGray.Name = "panelColorGray";
@ -153,6 +158,7 @@
// //
// panelColorWhite // panelColorWhite
// //
panelColorWhite.AllowDrop = true;
panelColorWhite.BackColor = Color.White; panelColorWhite.BackColor = Color.White;
panelColorWhite.Location = new Point(31, 84); panelColorWhite.Location = new Point(31, 84);
panelColorWhite.Name = "panelColorWhite"; panelColorWhite.Name = "panelColorWhite";
@ -161,6 +167,7 @@
// //
// panelColorYellow // panelColorYellow
// //
panelColorYellow.AllowDrop = true;
panelColorYellow.BackColor = Color.Yellow; panelColorYellow.BackColor = Color.Yellow;
panelColorYellow.Location = new Point(199, 28); panelColorYellow.Location = new Point(199, 28);
panelColorYellow.Name = "panelColorYellow"; panelColorYellow.Name = "panelColorYellow";
@ -169,6 +176,7 @@
// //
// panelColorBlue // panelColorBlue
// //
panelColorBlue.AllowDrop = true;
panelColorBlue.BackColor = Color.Blue; panelColorBlue.BackColor = Color.Blue;
panelColorBlue.Location = new Point(143, 28); panelColorBlue.Location = new Point(143, 28);
panelColorBlue.Name = "panelColorBlue"; panelColorBlue.Name = "panelColorBlue";
@ -177,6 +185,7 @@
// //
// panelColorGreen // panelColorGreen
// //
panelColorGreen.AllowDrop = true;
panelColorGreen.BackColor = Color.FromArgb(0, 192, 0); panelColorGreen.BackColor = Color.FromArgb(0, 192, 0);
panelColorGreen.Location = new Point(87, 28); panelColorGreen.Location = new Point(87, 28);
panelColorGreen.Name = "panelColorGreen"; panelColorGreen.Name = "panelColorGreen";
@ -185,6 +194,7 @@
// //
// panelColorRed // panelColorRed
// //
panelColorRed.AllowDrop = true;
panelColorRed.BackColor = Color.Red; panelColorRed.BackColor = Color.Red;
panelColorRed.Location = new Point(31, 28); panelColorRed.Location = new Point(31, 28);
panelColorRed.Name = "panelColorRed"; panelColorRed.Name = "panelColorRed";
@ -257,10 +267,13 @@
panelWithPictureBox.Location = new Point(482, 12); panelWithPictureBox.Location = new Point(482, 12);
panelWithPictureBox.Name = "panelWithPictureBox"; panelWithPictureBox.Name = "panelWithPictureBox";
panelWithPictureBox.Size = new Size(316, 195); panelWithPictureBox.Size = new Size(316, 195);
panelWithPictureBox.TabIndex = 2; panelWithPictureBox.TabIndex = 1;
panelWithPictureBox.DragDrop += PanelObject_DragDrop;
panelWithPictureBox.DragEnter += PanelObject_DragEnter;
// //
// labelAdvancedColor // labelAdvancedColor
// //
labelAdvancedColor.AllowDrop = true;
labelAdvancedColor.BorderStyle = BorderStyle.FixedSingle; labelAdvancedColor.BorderStyle = BorderStyle.FixedSingle;
labelAdvancedColor.Location = new Point(159, 10); labelAdvancedColor.Location = new Point(159, 10);
labelAdvancedColor.Name = "labelAdvancedColor"; labelAdvancedColor.Name = "labelAdvancedColor";
@ -273,6 +286,7 @@
// //
// labelSimpleColor // labelSimpleColor
// //
labelSimpleColor.AllowDrop = true;
labelSimpleColor.BorderStyle = BorderStyle.FixedSingle; labelSimpleColor.BorderStyle = BorderStyle.FixedSingle;
labelSimpleColor.Location = new Point(14, 10); labelSimpleColor.Location = new Point(14, 10);
labelSimpleColor.Name = "labelSimpleColor"; labelSimpleColor.Name = "labelSimpleColor";

View File

@ -51,7 +51,6 @@ namespace ProjectElectricLocomotive
_locomotive?.DrawTransport(gr); _locomotive?.DrawTransport(gr);
pictureBoxLoco.Image = bmp; pictureBoxLoco.Image = bmp;
} }
private void LabelObject_MouseDown(object sender, MouseEventArgs e) private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{ {
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
@ -85,27 +84,25 @@ namespace ProjectElectricLocomotive
} }
DrawLocomotive(); DrawLocomotive();
} }
private void buttonAddObject_Click(object sender, EventArgs e) private void buttonAddObject_Click(object sender, EventArgs e)
{ {
EventAddLocomotive?.Invoke(_locomotive); EventAddLocomotive?.Invoke(_locomotive);
Close(); Close();
} }
private void PanelColor_MouseDown(object sender, MouseEventArgs e) 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) private void LabelColor_DragDrop(object sender, DragEventArgs e)
{ {
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color)); ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
switch (((Label)sender).Name) switch (((Label)sender).Name)
{ {
case "labelColor": case "labelSimpleObject":
_locomotive.SetColor((Color)e.Data.GetData(typeof(Color))); _locomotive.SetColor((Color)e.Data.GetData(typeof(Color)));
break; break;
case "labelAddColor": case "labelAdvancedObject":
if (_locomotive is not DrawingLocomotive) return; if (_locomotive is not DrawingLocomotive) return;
else else
{ {
@ -115,7 +112,6 @@ namespace ProjectElectricLocomotive
} }
DrawLocomotive(); DrawLocomotive();
} }
private void LabelColor_DragEnter(object sender, DragEventArgs e) private void LabelColor_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data.GetDataPresent(typeof(Color))) if (e.Data.GetDataPresent(typeof(Color)))