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

94 lines
3.1 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
namespace WinFormsApp1
{
class MultiTraktorDraw : TractorDraw
{
2022-12-12 23:38:47 +04:00
public void SetDopColor(Color color)
{
2022-12-12 23:38:47 +04:00
((MultiTraktor)Tractor).DopColor = color;
}
public MultiTraktorDraw(int speed, float weight, Color bodyColor, Color dopColor, bool dopahead, bool dopbehind) : base(speed, weight, bodyColor, 188, 100)
{
Tractor = new MultiTraktor(speed, weight, bodyColor, dopColor, dopahead, dopbehind);
}
public override void DrawEntity(Graphics g)
{
if (Tractor is not MultiTraktor multiTraktor)
{
return;
}
2022-12-12 23:38:47 +04:00
if (!DrawCheck())
{
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);
2022-12-12 23:38:47 +04:00
if (multiTraktor.dopBehind)
{
2022-12-12 23:38:47 +04:00
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
};
2022-12-12 23:38:47 +04:00
g.FillPolygon(dopBrush, curvePoints);
g.DrawPolygon(pen_Black_1pxl, curvePoints);
2022-12-12 23:38:47 +04:00
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
};
2022-12-12 23:38:47 +04:00
g.FillPolygon(dopBrush, curvePoints2);
g.DrawPolygon(pen_Black_1pxl, curvePoints2);
}
startPosX += 43;
base.DrawEntity(g);
startPosX -= 43;
2022-12-12 23:38:47 +04:00
if (multiTraktor.dopAhead)
{
2022-12-12 23:38:47 +04:00
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
};
2022-12-12 23:38:47 +04:00
g.FillPolygon(dopBrush, curvePoints3);
g.DrawPolygon(pen_Black_1pxl, curvePoints3);
}
}
}
}