Lab5 error fix

This commit is contained in:
Yunusov_Niyaz 2023-11-22 19:42:40 +04:00
parent f31ccdc593
commit 3bd218f664
4 changed files with 15 additions and 31 deletions

View File

@ -22,5 +22,9 @@ namespace ProjectTrolleybus.Entities
Weight = weight;
BodyColor = bodyColor;
}
public void ChangeColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -22,5 +22,10 @@ namespace ProjectTrolleybus.Entities
Roga = roga;
Battery = battery;
}
public void ChangeAdditColor(Color color)
{
AdditionalColor = color;
}
}
}

View File

@ -279,7 +279,7 @@
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
labelAdditionalColor.DragEnter += labelColor_DragEnter;
//
// labelColor
//

View File

@ -113,18 +113,7 @@ namespace ProjectTrolleybus
if (_bus == null || _bus.EntityBus == null)
return;
Color colorBody = (Color)e.Data.GetData(typeof(Color));
if (_bus is DrawingTrolleybus == false)
{
_bus = new DrawingBus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
colorBody, _pictureWidth, _pictureHeight);
}
else
{
_bus = new DrawingTrolleybus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
colorBody, ((EntityTrolleybus)_bus.EntityBus).AdditionalColor, checkBoxRoga.Checked,
checkBoxBattery.Checked, _pictureWidth, _pictureHeight);
}
_bus.EntityBus.ChangeColor(colorBody);
DrawBus();
}
@ -145,23 +134,9 @@ namespace ProjectTrolleybus
if (_bus == null || _bus.EntityBus == null || _bus is DrawingTrolleybus == false)
return;
Color colorAdditional = (Color)e.Data.GetData(typeof(Color));
_bus = new DrawingTrolleybus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
_bus.EntityBus.BodyColor, colorAdditional, checkBoxRoga.Checked,
checkBoxBattery.Checked, _pictureWidth, _pictureHeight);
((EntityTrolleybus)_bus.EntityBus).ChangeAdditColor(colorAdditional);
DrawBus();
}
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
}