Pibd-22_Presnyakova.V.V_Cat.../Catamaran/DrawingCatamaran.cs

68 lines
3.1 KiB
C#
Raw Normal View History

2022-09-25 11:25:29 +04:00
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Catamaran
{
2022-10-01 20:41:57 +04:00
internal class DrawingCatamaran : DrawingBoat
2022-09-25 11:25:29 +04:00
{
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
2022-10-01 20:41:57 +04:00
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Цвет кузова</param>
/// <param name="dopColor">Дополнительный цвет</param>
/// <param name="Floats">Признак наличия обвеса</param>
/// <param name="Sail">Признак наличия антикрыла</param>
public DrawingCatamaran(int speed, float weight, Color bodyColor, Color
dopColor, bool Floats, bool Sail) :
base(speed, weight, bodyColor, 110, 60)
2022-09-25 11:25:29 +04:00
{
2022-10-01 20:41:57 +04:00
Catamaran = new EntityCatamaran(speed, weight, bodyColor, dopColor, Floats,
Sail);
2022-09-25 11:25:29 +04:00
}
2022-11-07 01:27:11 +04:00
public DrawingCatamaran Copy(int? speed = null, float? weight = null, Color? bodyColor = null, Color? dopColor = null, bool? Floats = null, bool? Sail = null)
{
var b = (EntityCatamaran)Catamaran;
return new DrawingCatamaran(speed ?? b.Speed, weight ?? b.Weight, bodyColor ?? b.BodyColor, dopColor ?? b.DopColor, Floats ?? b.Floats, Sail ?? b.Sail);
}
2022-10-01 20:41:57 +04:00
public override void DrawTransport(Graphics g)
2022-09-25 11:25:29 +04:00
{
2022-10-01 20:41:57 +04:00
if (!(Catamaran is EntityCatamaran catamaranPro))
2022-09-25 11:25:29 +04:00
{
return;
}
Pen pen = new Pen(Color.Black);
2022-10-01 20:41:57 +04:00
Brush dopBrush = new SolidBrush(catamaranPro.DopColor);
if (catamaranPro.Floats)
2022-09-25 11:25:29 +04:00
{
2022-10-01 20:41:57 +04:00
g.DrawEllipse(pen, _startPosX, _startPosY, (int)(_catamaranWidth / 2), (int)(_catamaranHeight / 2));
g.FillEllipse(dopBrush, _startPosX, _startPosY, (int)(_catamaranWidth / 2), (int)(_catamaranHeight / 2));
g.DrawEllipse(pen, _startPosX, 10 + _startPosY + (int)(_catamaranHeight / 2), (int)(_catamaranWidth / 2), (int)(_catamaranHeight / 2));
g.FillEllipse(dopBrush, _startPosX, 10 + _startPosY + (int)(_catamaranHeight / 2), (int)(_catamaranWidth / 2), (int)(_catamaranHeight / 2));
2022-09-25 11:25:29 +04:00
}
2022-10-01 20:41:57 +04:00
_startPosX += 10;
_startPosY += 5;
base.DrawTransport(g);
_startPosX -= 10;
_startPosY -= 5;
if (catamaranPro.Sail)
2022-09-25 11:25:29 +04:00
{
2022-10-01 20:41:57 +04:00
Point point_1 = new Point((int)(_startPosX + _catamaranWidth * 2 / 4), (int)_startPosY + 5);
Point point_2 = new Point((int)(_startPosX + _catamaranWidth), (int)(_startPosY + _catamaranHeight / 2));
Point point_3 = new Point((int)(_startPosX + _catamaranWidth * 2 / 4), (int)(_startPosY + _catamaranHeight));
Point[] pointsArray = { point_1, point_2, point_3 };
g.DrawPolygon(pen, pointsArray);
g.FillPolygon(dopBrush, pointsArray);
2022-09-25 11:25:29 +04:00
}
2022-10-01 20:41:57 +04:00
2022-09-25 11:25:29 +04:00
}
}
}