PIBD-11_Basalov_A.D_Simple/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs

78 lines
3.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive.Entities;
namespace ProjectElectricLocomotive.Drawnings
{
/// <summary>
/// Класс, отвечающий за отрисовку и перемещение обьекта-сущности
/// </summary>
public class DrawningElectricLocomotive: DrawningLocomotive
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="pantograph">Признак наличия обвеса</param>
/// <param name="batterystorage">Признак наличия антикрыла</param>
/// --------------------------------------------------------------------------
/// Требуется конструктор, вызывать надо будет у класса EntityElectricLocomotive
/// ДОДЕЛАТЬ САМИМ!!!
public DrawningElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool pantograph, bool batterystorage) : base(155, 100)
{
EntityLocomotive = new EntityElectricLocomotive(speed, weight, bodyColor, additionalColor,
pantograph, batterystorage);
}
public override void DrawTransport(Graphics g)
{
if (EntityLocomotive == null || EntityLocomotive is not EntityElectricLocomotive electricLocomotive || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
_startPosX += 0;
_startPosY += 0;
base.DrawTransport(g);
_startPosX -= 0;
_startPosY -= 0;
Pen pen = new(Color.Black);
Brush additonalBrush = new SolidBrush(electricLocomotive.AdditionalColor);
Brush bodyBrush = new SolidBrush(electricLocomotive.BodyColor);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 155, 10);
g.FillRectangle(additonalBrush, _startPosX.Value + 1, _startPosY.Value + 51, 154, 9);
//Пантограф
if (electricLocomotive.Pantograph)
{
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value + 10);
g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 10, _startPosX.Value + 90, _startPosY.Value + 10);
}
//Отсек для батарей
if (electricLocomotive.BatteryStorage)
{
g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + 30, 30, 20);
g.FillRectangle(additonalBrush, _startPosX.Value + 101, _startPosY.Value + 31, 29, 19);
g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 40, _startPosX.Value + 115, _startPosY.Value + 50);
g.DrawLine(pen, _startPosX.Value + 115, _startPosY.Value + 40, _startPosX.Value + 120, _startPosY.Value + 40);
g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 30, _startPosX.Value + 115, _startPosY.Value + 40);
}
}
}
}