Исправления

This commit is contained in:
Андрей Байгулов 2023-11-12 22:25:06 +04:00
parent 26e3503e00
commit 0dfabf5f19

View File

@ -28,8 +28,10 @@ namespace ProjectElectricLocomotive
panelColorWhite.MouseDown += PanelColor_MouseDown; panelColorWhite.MouseDown += PanelColor_MouseDown;
panelColorYellow.MouseDown += PanelColor_MouseDown; panelColorYellow.MouseDown += PanelColor_MouseDown;
panelColorBlue.MouseDown += PanelColor_MouseDown; panelColorBlue.MouseDown += PanelColor_MouseDown;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
labelAdvancedObject.MouseDown += LabelObject_MouseDown;
buttonCancelObject.Click += (sender, e) => Close(); buttonCancelObject.Click += (s, e) => Close();
} }
public void AddEvent(LocomotiveDelegate ev) public void AddEvent(LocomotiveDelegate ev)
@ -55,6 +57,7 @@ namespace ProjectElectricLocomotive
{ {
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
} }
private void PanelObject_DragEnter(object sender, DragEventArgs e) private void PanelObject_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
@ -75,7 +78,7 @@ namespace ProjectElectricLocomotive
(int)numericUpDownWeight.Value, Color.White, pictureBoxLoco.Width, (int)numericUpDownWeight.Value, Color.White, pictureBoxLoco.Width,
pictureBoxLoco.Height); pictureBoxLoco.Height);
break; break;
case "labelModifiedObject": case "labelAdvancedObject":
_locomotive = new DrawingElectricLocomotive((int)numericUpDownSpeed.Value, _locomotive = new DrawingElectricLocomotive((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPantograph.Checked, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPantograph.Checked,
checkBoxCompartment.Checked, pictureBoxLoco.Width, checkBoxCompartment.Checked, pictureBoxLoco.Width,
@ -84,16 +87,19 @@ 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, (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
DragDropEffects.Move | DragDropEffects.Copy); 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));