PIbd-21_Krasnikov_Lab1.base/WinFormsApp1/MultiTraktorDraw.cs

86 lines
3.1 KiB
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
namespace WinFormsApp1
{
class MultiTraktorDraw : TractorDraw
{
/// Инициализация свойств
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес трактора</param>
/// <param name="bodyColor">Цвет кузова</param>
/// <param name="dopColor">Дополнительный цвет</param>
/// <param name="trktrWidth">Ширина отрисовки автомобиля</param>
/// <param name="trktrHeight">Высота отрисовки автомобиля</param>
public MultiTraktorDraw(int speed, float weight, Color bodyColor, Color dopColor) : base(speed, weight, bodyColor, 188, 100)
{
Tractor = new MultiTraktor(speed, weight, bodyColor, dopColor);
}
public override void DrawEntity(Graphics g)
{
if (Tractor is not MultiTraktor multiTraktor)
{
return;
}
Pen pen_Black_1pxl = new Pen(Color.Black, 1);
Pen pen_Black_2pxl = new Pen(Color.Black, 2);
Brush brBlack = new SolidBrush(Color.Black);
Brush dopBrush = new SolidBrush(multiTraktor.DopColor);
PointF point1;
PointF point2;
PointF point3;
PointF point4;
g.DrawRectangle(pen_Black_1pxl, startPosX, startPosY + 8, 4, 35);
g.DrawRectangle(pen_Black_1pxl, startPosX + 33, startPosY + 34, 10, 15);
point1 = new PointF(startPosX, startPosY + 8);
point2 = new PointF(startPosX + 33, startPosY + 41);
point3 = new PointF(startPosX + 33, startPosY + 34);
point4 = new PointF(startPosX + 7, startPosY + 8);
PointF[] curvePoints =
{
point1,
point2,
point3,
point4
};
g.FillPolygon(dopBrush, curvePoints);
g.DrawPolygon(pen_Black_1pxl, curvePoints);
point1 = new PointF(startPosX + 6, startPosY + 8 + 15);
point2 = new PointF(startPosX + 6, startPosY + 8 + 35);
point3 = new PointF(startPosX + 26, startPosY + 8 + 35);
PointF[] curvePoints2 =
{
point1,
point2,
point3
};
g.FillPolygon(dopBrush, curvePoints2);
g.DrawPolygon(pen_Black_1pxl, curvePoints2);
startPosX += 43;
base.DrawEntity(g);
startPosX -= 43;
point1 = new PointF(startPosX + 43 + 102, startPosY + 30);
point2 = new PointF(startPosX + 43 + 102, startPosY + 65);
point3 = new PointF(startPosX + 43 + 137, startPosY + 65);
PointF[] curvePoints3 =
{
point1,
point2,
point3
};
g.FillPolygon(dopBrush, curvePoints3);
g.DrawPolygon(pen_Black_1pxl, curvePoints3);
}
}
}