PIbd-23_Vrazhkin_S_A_Electr.../lab1/DrawingObjects/DrawingElectricLocomotiv.cs

30 lines
1.6 KiB
C#
Raw Normal View History

2023-10-17 13:49:31 +04:00
using System.Drawing.Drawing2D;
namespace ElectricLocomotive;
2023-10-03 11:53:51 +04:00
public class DrawingElectricLocomotiv : DrawingLocomotiv
{
2023-10-17 13:49:31 +04:00
public DrawingElectricLocomotiv(int speed, double weight, int width, int height, Color mainColor, Color dopColor, Color batteryColor, Color rogaColor) : base(speed, weight, width,
height, mainColor, dopColor)
2023-10-03 11:53:51 +04:00
{
if (EntityLocomotiv != null)
{
2023-10-17 13:49:31 +04:00
EntityLocomotiv = new EntityElectricLocomotiv(speed, weight, batteryColor, rogaColor, mainColor, dopColor);
2023-10-03 11:53:51 +04:00
}
}
public override void DrawLoco(Graphics g)
{
if (EntityLocomotiv == null) return;
base.DrawLoco(g);
if (EntityLocomotiv is not EntityElectricLocomotiv electricLocomotiv) return;
SolidBrush batteryBrush = new(electricLocomotiv.BatteryColor);
Pen rogaPen = new(electricLocomotiv.RogaColor);
//Roga
g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2, _startPosY + 30), new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15));
g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15), new Point(_startPosX + _vehicleWidth / 2, _startPosY));
//battery
Point[] batteryPoints = { new Point(_startPosX + _vehicleWidth - 10,_startPosY + _vehicleHeight - 25), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 20), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 55), new Point(_startPosX + _vehicleWidth - 10, _startPosY + _vehicleHeight - 50) };
g.FillPolygon(batteryBrush, batteryPoints);
}
}