Pibd-22_Presnyakova.V.V_Cat.../Catamaran/DrawingCatamaran.cs
2022-11-07 01:27:11 +04:00

68 lines
3.1 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;
namespace Catamaran
{
internal class DrawingCatamaran : DrawingBoat
{
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <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)
{
Catamaran = new EntityCatamaran(speed, weight, bodyColor, dopColor, Floats,
Sail);
}
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);
}
public override void DrawTransport(Graphics g)
{
if (!(Catamaran is EntityCatamaran catamaranPro))
{
return;
}
Pen pen = new Pen(Color.Black);
Brush dopBrush = new SolidBrush(catamaranPro.DopColor);
if (catamaranPro.Floats)
{
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));
}
_startPosX += 10;
_startPosY += 5;
base.DrawTransport(g);
_startPosX -= 10;
_startPosY -= 5;
if (catamaranPro.Sail)
{
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);
}
}
}
}