90 lines
3.6 KiB
C#
90 lines
3.6 KiB
C#
using ProjectBus.Entities;
|
||
using System.Drawing;
|
||
|
||
namespace ProjectBus.Drawnings;
|
||
|
||
/// <summary>
|
||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||
/// </summary>
|
||
public class DrawningBus : DrawningSimpleBus
|
||
{
|
||
/// <summary>
|
||
/// Конструктор
|
||
/// </summary>
|
||
/// <param name="speed">Скорость</param>
|
||
/// <param name="weight">Вес</param>
|
||
/// <param name="bodyColor">Основной цвет</param>
|
||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||
/// <param name="additionalCompartment">Признак наличия дополнительного отсека</param>
|
||
/// <param name="accordion"">Признак наличия гармошки</param>
|
||
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);
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|