70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
using ElectricLocomotive.DrawningObject;
|
|
using ElectricLocomotive.Entities;
|
|
|
|
|
|
namespace ElectricLocomotive
|
|
{
|
|
public class DrawningElectricLocomotive : DrawningLocomotive
|
|
{
|
|
public DrawningElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool Horns_1,bool Horns_2, int width, int height)
|
|
: base (speed, weight, bodyColor, width , height)
|
|
{
|
|
if (EntityLocomotive != null)
|
|
{
|
|
EntityLocomotive = new EntityElectroLocomotive(speed, weight, bodyColor,
|
|
additionalColor, Horns_1,Horns_2);
|
|
}
|
|
}
|
|
|
|
public override void DrawTransport(Graphics g)
|
|
{
|
|
if (EntityLocomotive is not EntityElectroLocomotive electroLocomotive)
|
|
{
|
|
return;
|
|
}
|
|
Pen pen = new(electroLocomotive.BodyColor) ;
|
|
Brush brush = new SolidBrush(electroLocomotive.AdditionalColor);
|
|
// обвесы
|
|
if (electroLocomotive.Horns_1)
|
|
{
|
|
g.FillRectangle(brush, _startPosX + 25, _startPosY + 5, 15, 5);
|
|
|
|
Point[] horns =
|
|
{
|
|
new Point(_startPosX+25, _startPosY+10),
|
|
new Point(_startPosX+25, _startPosY+5),
|
|
new Point(_startPosX+33,_startPosY+5),
|
|
new Point(_startPosX+50, _startPosY),
|
|
new Point(_startPosX+33,_startPosY+5),
|
|
new Point(_startPosX+40,_startPosY+5),
|
|
new Point(_startPosX+40,_startPosY+10)
|
|
};
|
|
g.DrawPolygon(pen, horns);
|
|
}
|
|
if (electroLocomotive.Horns_2)
|
|
{
|
|
g.FillRectangle(brush, _startPosX + 65, _startPosY + 5, 15, 5);
|
|
Point[] horns2 =
|
|
{
|
|
new Point(_startPosX+65, _startPosY+10),
|
|
new Point(_startPosX+65, _startPosY+5),
|
|
new Point(_startPosX+73,_startPosY+5),
|
|
new Point(_startPosX+90, _startPosY),
|
|
new Point(_startPosX+73,_startPosY+5),
|
|
new Point(_startPosX+80,_startPosY+5),
|
|
new Point(_startPosX+80,_startPosY+10)
|
|
};
|
|
g.DrawPolygon(pen, horns2);
|
|
|
|
}
|
|
base.DrawTransport(g);
|
|
}
|
|
|
|
public void SetAdditionalColor(Color color)
|
|
{
|
|
(EntityLocomotive as EntityElectroLocomotive).SetAdditionalColor(color);
|
|
}
|
|
}
|
|
}
|
|
|