using ProjectBus.Entities; using System.Drawing; namespace ProjectBus.Drawnings; /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// public class DrawningBus : DrawningSimpleBus { /// /// Конструктор /// /// Скорость /// Вес /// Основной цвет /// Дополнительный цвет /// Признак наличия дополнительного отсека /// Признак наличия гармошки public DrawningBus(int speed, double weight, Color bodyColor, Color additionalColor, bool additionalCompartment, bool accordion) : base(310,52) { EntitySimpleBus = new EntityBus(speed, weight, bodyColor, additionalColor, additionalCompartment, accordion); } public override void DrawTransport(Graphics g) { if (EntitySimpleBus == null || EntitySimpleBus is not EntityBus bus || !_startPosX.HasValue || !_startPosY.HasValue) { return; } Pen pen = new(Color.Black); Brush additionalBrush= new SolidBrush(bus.AdditionalColor); //доп отсек if (bus.AdditionalCompartment) { //корпус g.DrawRectangle(pen, _startPosX.Value + 204, _startPosY.Value - 1, 105, 50); g.DrawRectangle(pen, _startPosX.Value + 205, _startPosY.Value, 105, 50); g.FillRectangle(additionalBrush, _startPosX.Value + 205, _startPosY.Value, 105, 50); //окна g.FillEllipse(additionalBrush, _startPosX.Value + 247, _startPosY.Value + 6, 16, 25); g.FillEllipse(additionalBrush, _startPosX.Value + 275, _startPosY.Value + 6, 16, 25); g.DrawEllipse(pen, _startPosX.Value + 247, _startPosY.Value + 6, 16, 25); g.DrawEllipse(pen, _startPosX.Value + 275, _startPosY.Value + 6, 16, 25); //дверь g.FillRectangle(additionalBrush, _startPosX.Value + 215, _startPosY.Value + 10, 20, 40); g.DrawRectangle(pen, _startPosX.Value + 215, _startPosY.Value + 10, 20, 40); //колеса g.FillEllipse(additionalBrush, _startPosX.Value + 250, _startPosY.Value + 40, 20, 20); g.DrawEllipse(pen, _startPosX.Value + 250, _startPosY.Value + 40, 20, 20); } _startPosX += 0; _startPosY += 0; base.DrawTransport(g); //гармошка if (bus.Accordion) { Brush brGray = new SolidBrush(Color.LightGray); g.FillRectangle(brGray, _startPosX.Value + 175, _startPosY.Value + 4, 30, 42); g.FillRectangle(brGray, _startPosX.Value + 180, _startPosY.Value + 4, 5, 42); g.FillRectangle(brGray, _startPosX.Value + 185, _startPosY.Value + 4, 5, 42); g.FillRectangle(brGray, _startPosX.Value + 190, _startPosY.Value + 4, 5, 42); g.FillRectangle(brGray, _startPosX.Value + 195, _startPosY.Value + 4, 5, 42); g.DrawRectangle(pen, _startPosX.Value + 175, _startPosY.Value + 4, 30, 42); g.DrawRectangle(pen, _startPosX.Value + 180, _startPosY.Value + 4, 5, 42); g.DrawRectangle(pen, _startPosX.Value + 185, _startPosY.Value + 4, 5, 42); g.DrawRectangle(pen, _startPosX.Value + 190, _startPosY.Value + 4, 5, 42); g.DrawRectangle(pen, _startPosX.Value + 195, _startPosY.Value + 4, 5, 42); } } }