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; Weight = weight;
BodyColor = bodyColor; BodyColor = bodyColor;
} }
public void ChangeColor(Color color)
{
BodyColor = color;
}
} }
} }

View File

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

View File

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

View File

@ -41,8 +41,8 @@ namespace ProjectTrolleybus
{ {
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp); Graphics gr = Graphics.FromImage(bmp);
_bus?.SetPosition(5, 5); _bus?.SetPosition(5, 5);
_bus?.DrawTransport(gr); _bus?.DrawTransport(gr);
pictureBoxObject.Image = bmp; pictureBoxObject.Image = bmp;
} }
@ -82,7 +82,7 @@ namespace ProjectTrolleybus
{ {
case "labelSimple": case "labelSimple":
_bus = new DrawingBus((int)numericUpDownSpeed.Value, _bus = new DrawingBus((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, _pictureWidth, _pictureHeight); (int)numericUpDownWeight.Value, Color.White, _pictureWidth, _pictureHeight);
break; break;
case "labelAdvanced": case "labelAdvanced":
_bus = new DrawingTrolleybus((int)numericUpDownSpeed.Value, _bus = new DrawingTrolleybus((int)numericUpDownSpeed.Value,
@ -113,18 +113,7 @@ namespace ProjectTrolleybus
if (_bus == null || _bus.EntityBus == null) if (_bus == null || _bus.EntityBus == null)
return; return;
Color colorBody = (Color)e.Data.GetData(typeof(Color)); Color colorBody = (Color)e.Data.GetData(typeof(Color));
if (_bus is DrawingTrolleybus == false) _bus.EntityBus.ChangeColor(colorBody);
{
_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);
}
DrawBus(); DrawBus();
} }
@ -145,23 +134,9 @@ namespace ProjectTrolleybus
if (_bus == null || _bus.EntityBus == null || _bus is DrawingTrolleybus == false) if (_bus == null || _bus.EntityBus == null || _bus is DrawingTrolleybus == false)
return; return;
Color colorAdditional = (Color)e.Data.GetData(typeof(Color)); Color colorAdditional = (Color)e.Data.GetData(typeof(Color));
_bus = new DrawingTrolleybus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, ((EntityTrolleybus)_bus.EntityBus).ChangeAdditColor(colorAdditional);
_bus.EntityBus.BodyColor, colorAdditional, checkBoxRoga.Checked,
checkBoxBattery.Checked, _pictureWidth, _pictureHeight);
DrawBus(); DrawBus();
} }
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
} }
} }