This commit is contained in:
илья 2024-04-26 17:56:52 +04:00
parent d92fba59c9
commit ea96346a85
5 changed files with 37 additions and 34 deletions

View File

@ -195,9 +195,10 @@ public class DrawningLocomotive
{
return;
}
Pen pen = new(Color.Black, 2);
Pen pen2 = new(Color.White, 1);
Pen pen3 = new(Color.Black, 3);
Brush wheelBrush = new SolidBrush(Color.Black);
Brush wheelBrush2 = new SolidBrush(Color.Gray);
Brush headlightBrush = new SolidBrush(Color.Yellow);
@ -206,17 +207,17 @@ public class DrawningLocomotive
//границы круисера
Point[] points = { new Point(_startPosX.Value + 5, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value + 20), new Point(_startPosX.Value, _startPosY.Value + 20) };
//g.FillPolygon(additionalBrush, points);
Point[] points = { new Point(_startPosX.Value + 2, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value + 20), new Point(_startPosX.Value, _startPosY.Value + 20) };
g.DrawPolygon(pen, points);
g.FillRectangle(bodyBrush, _startPosX.Value, _startPosY.Value + 20, 140, 20);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 20, 140, 20);
g.DrawLine(pen, _startPosX.Value + 5, _startPosY.Value, _startPosX.Value + 140, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value, _startPosX.Value + 140, _startPosY.Value + 20);
//g.DrawLine(pen, _startPosX.Value + 2, _startPosY.Value, _startPosX.Value + 140, _startPosY.Value);
//g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value, _startPosX.Value + 140, _startPosY.Value + 20);
g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 20, _startPosX.Value + 5, _startPosY.Value);
//g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 20, _startPosX.Value + 5, _startPosY.Value );
g.FillRectangle(wheelBrush, _startPosX.Value + 140, _startPosY.Value + 3, 7, 34);
@ -236,6 +237,7 @@ public class DrawningLocomotive
Point[] points3 = { new Point(_startPosX.Value + 145, _startPosY.Value + 47), new Point(_startPosX.Value + 95, _startPosY.Value + 47), new Point(_startPosX.Value + 85, _startPosY.Value + 40), new Point(_startPosX.Value + 135, _startPosY.Value + 40) };
g.FillPolygon(wheelBrush, points3);
g.FillEllipse(wheelBrush2, _startPosX.Value + 37, _startPosY.Value + 41, 14, 14);
g.DrawEllipse(pen2, _startPosX.Value + 37, _startPosY.Value + 41, 15, 15);
g.FillEllipse(wheelBrush2, _startPosX.Value + 10, _startPosY.Value + 41, 14, 14);

View File

@ -13,14 +13,14 @@ namespace ProjectLocomotive.Drawnings
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="horns">Признак наличия рогов</param>
/// <param name="electro">Признак наличия электрической батареи</param>
/// <param name="pipe">Признак наличия трубы</param>
/// <param name="fueltank">Признак наличия топливного бака</param>
/// <param name="headlight">Признак наличия фары</param>
public DrawningTLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool horns, bool electro, bool headlight)
public DrawningTLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool pipe, bool fueltank, bool headlight)
: base(150, 50)
{
EntityLocomotive = new EntityTLocomotive(speed, weight, bodyColor, additionalColor, horns, electro, headlight);
EntityLocomotive = new EntityTLocomotive(speed, weight, bodyColor, additionalColor, pipe, fueltank, headlight);
}
public override void DrawTransport(Graphics g)
@ -33,37 +33,38 @@ namespace ProjectLocomotive.Drawnings
Pen pen = new(Color.Black, 2);
Pen pen2 = new(Color.White, 1);
Pen pen3 = new(Color.Black, 3);
Brush wheelBrush = new SolidBrush(Color.Black);
Brush wheelBrush2 = new SolidBrush(Color.Gray);
Brush headlightBrush = new SolidBrush(Color.Yellow);
Brush glassBrush = new SolidBrush(Color.Cyan);
Brush ElectroBrush = new HatchBrush(HatchStyle.ZigZag, entityTLocomotive.AdditionalColor, Color.FromArgb(163, 163, 163));
Brush FueltankBrush = new HatchBrush(HatchStyle.ZigZag, entityTLocomotive.AdditionalColor, Color.FromArgb(163, 163, 163));
Brush additionalBrush = new SolidBrush(entityTLocomotive.AdditionalColor);
Brush bodyBrush = new SolidBrush(EntityLocomotive.BodyColor);
Point[] points = { new Point(_startPosX.Value + 5, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value + 20), new Point(_startPosX.Value, _startPosY.Value + 20) };
Point[] points = { new Point(_startPosX.Value + 2, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value), new Point(_startPosX.Value + 140, _startPosY.Value + 20), new Point(_startPosX.Value, _startPosY.Value + 20) };
g.FillPolygon(additionalBrush, points);
base.DrawTransport(g);
Point[] points4 = { new Point(_startPosX.Value + 20, _startPosY.Value), new Point(_startPosX.Value + 30, _startPosY.Value), new Point(_startPosX.Value + 30, _startPosY.Value - 7), new Point(_startPosX.Value + 32, _startPosY.Value - 9), new Point(_startPosX.Value + 30, _startPosY.Value - 11), new Point(_startPosX.Value + 20, _startPosY.Value - 11), new Point(_startPosX.Value + 18, _startPosY.Value - 9), new Point(_startPosX.Value + 20, _startPosY.Value - 7), new Point(_startPosX.Value + 20, _startPosY.Value) };
g.FillPolygon(wheelBrush, points4);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value, _startPosX.Value + 47, _startPosY.Value - 5);
g.DrawLine(pen, _startPosX.Value + 47, _startPosY.Value - 5, _startPosX.Value + 67, _startPosY.Value - 10);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value - 10, _startPosX.Value + 87, _startPosY.Value - 5);
g.DrawLine(pen, _startPosX.Value + 87, _startPosY.Value - 5, _startPosX.Value + 67, _startPosY.Value);
if (entityTLocomotive.Electro)
if (entityTLocomotive.Fueltank)
{
g.FillRectangle(ElectroBrush, _startPosX.Value + 107, _startPosY.Value - 5 + 3, 33, 28);
g.DrawRectangle(pen, _startPosX.Value + 107, _startPosY.Value - 5 + 3, 33, 28);
Point[] points5 = { new Point(_startPosX.Value + 52, _startPosY.Value + 50), new Point(_startPosX.Value + 92, _startPosY.Value + 50), new Point(_startPosX.Value + 87, _startPosY.Value + 35), new Point(_startPosX.Value + 57, _startPosY.Value + 35) };
g.FillPolygon(wheelBrush, points5);
}
if (entityTLocomotive.Headlight)
{
g.FillEllipse(headlightBrush, _startPosX.Value - 3, _startPosY.Value + 23, 6, 14);
g.DrawEllipse(pen, _startPosX.Value - 3, _startPosY.Value + 23, 6, 14);
g.DrawLine(pen3, _startPosX.Value, _startPosY.Value - 5, _startPosX.Value + 15, _startPosY.Value);
g.FillEllipse(headlightBrush, _startPosX.Value - 2, _startPosY.Value - 6, 6, 14);
g.DrawEllipse(pen, _startPosX.Value - 2, _startPosY.Value - 6, 6, 14);
}

View File

@ -1,7 +1,7 @@
namespace ProjectLocomotive.Entities;
/// <summary>
/// Класс-сущность "поед"
/// Класс-сущность "поезд"
/// </summary>
public class EntityLocomotiev
{
@ -24,7 +24,7 @@ public class EntityLocomotiev
/// </summary>
public double Step => Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса поеда
/// Инициализация полей объекта-класса поезда
/// </summary>
/// <param name="speed">скорость</param>
/// <param name="weight">вес</param>

View File

@ -3,13 +3,13 @@
internal class EntityTLocomotive : EntityLocomotiev
{
/// <summary>
/// Признак (опция) наличие рогов
/// Признак (опция) наличие трубы
/// </summary>
public bool Horns { get; private set; }
public bool Pipe { get; private set; }
/// <summary>
/// Признак (опция) наличие электробатареи
/// Признак (опция) наличие топливного бака
/// </summary>
public bool Electro { get; private set; }
public bool Fueltank { get; private set; }
/// <summary>
/// Признак (опция) наличие фары
/// </summary>
@ -19,11 +19,11 @@
/// </summary>
public Color AdditionalColor { get; private set; }
public EntityTLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool horns, bool electro, bool headlight) : base(speed, weight, bodyColor)
public EntityTLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool pipe, bool fueltank, bool headlight) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
Horns = horns;
Electro = electro;
Pipe = pipe;
Fueltank = fueltank;
Headlight = headlight;
}
}

View File

@ -60,7 +60,7 @@
button1.Name = "button1";
button1.Size = new Size(186, 22);
button1.TabIndex = 1;
button1.Text = "создать электро-поезда";
button1.Text = "создать тепловоз";
button1.UseVisualStyleBackColor = true;
button1.Click += ButtonCreateLocomotive_Click;
//