PIbd-14_Pruidze_I.K_Simple_.../ProjectCruiser/DrawningSamples/DrawningCruiser.cs
2024-06-15 10:03:23 +04:00

49 lines
1.8 KiB
C#

using System.Drawing.Drawing2D;
using ProjectCruiser.Entities;
namespace ProjectCruiser.DrawningSamples;
public class DrawningCruiser : DrawningBase
{
// Инициализация свойств (все параметры класса (сущности))
public DrawningCruiser(int speed, double weight, Color bodyColor,
Color additionalColor, bool pad, bool hangars) : base(302, 42)
{
EntityTransport = new EntityCruiser(speed, weight,
bodyColor, additionalColor, pad, hangars);
}
public override void DrawTransport(Graphics g)
{
if (EntityTransport == null ||
EntityTransport is not EntityCruiser ship ||
!_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black, 2);
Brush PadBrush = new HatchBrush(HatchStyle.DottedDiamond, Color.LightGray, Color.Black);
Brush additionalBrush = new SolidBrush(ship.AdditionalColor);
//границы cruiser <...>
// &
// салон на верхней палубе :
base.DrawTransport(g);
// вертолетная площадка - non-default
if (ship.HelicopterPads)
{
g.DrawEllipse(pen, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
g.FillEllipse(PadBrush, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
}
// ангар(ы)
if (ship.Hangars)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 80, _startPosY.Value + 10, 10, 20);
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value + 12, 8, 12);
}
else g.FillRectangle(additionalBrush, _startPosX.Value + 250, _startPosY.Value + 20, 14, 7);
}
}