diff --git a/Hydroplane/DrawingHydroplane.cs b/Hydroplane/DrawingHydroplane.cs index 419881c..d38bb5b 100644 --- a/Hydroplane/DrawingHydroplane.cs +++ b/Hydroplane/DrawingHydroplane.cs @@ -21,19 +21,19 @@ namespace Hydroplane /// private int _pictureHeight; /// - /// Левая координата прорисовки автомобиля + /// Левая координата прорисовки гидроплана /// private int _startPosX; /// - /// Верхняя кооридната прорисовки автомобиля + /// Верхняя кооридната прорисовки гидроплана /// private int _startPosY; /// - /// Ширина прорисовки автомобиля + /// Ширина прорисовки гидроплана /// private readonly int _planeWidth = 175; /// - /// Высота прорисовки автомобиля + /// Высота прорисовки гидроплана /// private readonly int _planeHeight = 100; /// @@ -43,8 +43,8 @@ namespace Hydroplane /// Вес /// Цвет кузова /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла + /// Признак наличия надувной лодки + /// Признак наличия поплавков /// Ширина картинки /// Высота картинки /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах @@ -126,119 +126,35 @@ namespace Hydroplane return; } Pen pen = new(Color.Black); - Brush additionalBrush = new - SolidBrush(EntityHydroplane.AdditionalColor); - /* - // обвесы - if (EntityHydroplane.BodyKit) + Brush additionalBrush = new SolidBrush(EntityHydroplane.AdditionalColor); + Brush bodyBrush = new SolidBrush(EntityHydroplane.BodyColor); + + //раскраска основы + g.FillPolygon(bodyBrush, new[] { + new Point(_startPosX + 5, _startPosY), + new Point(_startPosX + 5, _startPosY + 55), + new Point(_startPosX + 130, _startPosY + 55), + new Point(_startPosX + 160, _startPosY + 40), + new Point(_startPosX + 130, _startPosY + 40), + new Point(_startPosX + 130, _startPosY + 25), + new Point(_startPosX + 55, _startPosY + 25) }); + + //раскраска ножек + g.FillRectangle(bodyBrush, _startPosX + 65, _startPosY + 55, 5, 15); + g.FillRectangle(bodyBrush, _startPosX + 125, _startPosY + 55, 5, 15); + + //раскраска иллюминаторов + g.FillEllipse(additionalBrush, _startPosX + 40, _startPosY + 30, 10, 10); + g.FillEllipse(additionalBrush, _startPosX + 60, _startPosY + 30, 10, 10); + g.FillEllipse(additionalBrush, _startPosX + 80, _startPosY + 30, 10, 10); + + //раскраска окна + g.FillPolygon(additionalBrush, new[] { - g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, - 20); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, - 20, 40); - g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, - 15); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, - 15, 15); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY, 20, 20); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY + 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 10, 20, 40); - g.FillRectangle(additionalBrush, _startPosX + 90, -_startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 45, 15, 15); - g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); - g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, - 40); - g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, - 15); - g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, - 14, 15); - g.FillEllipse(additionalBrush, _startPosX, _startPosY, - 20, 20); - g.FillEllipse(additionalBrush, _startPosX, _startPosY + - 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 1, - _startPosY + 10, 25, 40); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 45, 15, 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, - 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, - 39, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 1, 40, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 45, 40, 15); - } - //границы автомобиля - g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, - 30); - g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); - //задние фары - Brush brRed = new SolidBrush(Color.Red); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, - 20); - //передние фары - Brush brYellow = new SolidBrush(Color.Yellow); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, - 20); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, - 20); - //кузов - Brush br = new SolidBrush(EntityHydroplane.BodyColor); - g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); - //стекла - Brush brBlue = new SolidBrush(Color.LightBlue); - g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, - 2); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, - 2); - //выделяем рамкой крышу - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, - 40); - g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, - 30); - g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, - 30); - // спортивная линия - if (EntityHydroplane.SportLine) - { - g.FillRectangle(additionalBrush, _startPosX + 75, - _startPosY + 23, 25, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 23, 35, 15); - g.FillRectangle(additionalBrush, _startPosX + 10, - _startPosY + 23, 20, 15); - } - // крыло - if (EntityHydroplane.Wing) - { - g.FillRectangle(additionalBrush, _startPosX, _startPosY - + 5, 10, 50); - g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, - 50); - } - */ + new Point(_startPosX + 160, _startPosY + 40), + new Point(_startPosX + 130, _startPosY + 40), + new Point(_startPosX + 130, _startPosY + 25) }); + //основа g.DrawRectangle(pen, _startPosX + 5, _startPosY + 25, 125, 30); @@ -265,22 +181,36 @@ _startPosY + 1, 15, 15); g.DrawLine(pen, _startPosX + 125, _startPosY + 55, _startPosX + 125, _startPosY + 70); g.DrawLine(pen, _startPosX + 130, _startPosY + 55, _startPosX + 130, _startPosY + 70); - //лодка или колеса - if (EntityHydroplane.Boat) + //поплавки(лыжи) или колеса + if (EntityHydroplane.Bobber) { - g.DrawRectangle(pen, _startPosX + 55, _startPosY + 70, 100, 10); - g.DrawLine(pen, _startPosX + 155, _startPosY + 70, _startPosX + 175, _startPosY + 70); - g.DrawLine(pen, _startPosX + 175, _startPosY + 70, _startPosX + 155, _startPosY + 80); + g.FillPolygon(additionalBrush, new[] + { + new Point(_startPosX + 55, _startPosY + 70), + new Point(_startPosX + 55, _startPosY + 80), + new Point(_startPosX + 155, _startPosY + 80), + new Point(_startPosX + 175, _startPosY + 70) }); + + g.DrawPolygon(pen, new[] + { + new Point(_startPosX + 55, _startPosY + 70), + new Point(_startPosX + 55, _startPosY + 80), + new Point(_startPosX + 155, _startPosY + 80), + new Point(_startPosX + 175, _startPosY + 70) }); } else { + g.FillEllipse(additionalBrush, _startPosX + 60, _startPosY + 70, 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 120, _startPosY + 70, 15, 15); + g.DrawEllipse(pen, _startPosX + 60, _startPosY + 70, 15, 15); g.DrawEllipse(pen, _startPosX + 120, _startPosY + 70, 15, 15); } - //поплавок - if (EntityHydroplane.Bobber) + //надувная лодка + if (EntityHydroplane.Boat) { + g.FillEllipse(additionalBrush, _startPosX, _startPosY + 21, 32, 8); g.DrawEllipse(pen, _startPosX, _startPosY + 21, 32, 8); } } diff --git a/Hydroplane/EntityHydroplane.cs b/Hydroplane/EntityHydroplane.cs index 2f0dcb4..391dcda 100644 --- a/Hydroplane/EntityHydroplane.cs +++ b/Hydroplane/EntityHydroplane.cs @@ -33,18 +33,18 @@ namespace Hydroplane /// public bool Bobber { get; private set; } /// - /// Шаг перемещения автомобиля + /// Шаг перемещения гидроплана /// public double Step => (double)Speed * 100 / Weight; /// - /// Инициализация полей объекта-класса спортивного автомобиля + /// Инициализация полей объекта-класса гидроплана /// /// Скорость - /// Вес автомобиля + /// Вес гидроплана /// Основной цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла + /// Признак наличия надувной лодки + /// Признак наличия поплавков public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool boat, bool bobber) { diff --git a/Hydroplane/Form1.Designer.cs b/Hydroplane/FormHydroplane.Designer.cs similarity index 98% rename from Hydroplane/Form1.Designer.cs rename to Hydroplane/FormHydroplane.Designer.cs index 2a29200..8df2b87 100644 --- a/Hydroplane/Form1.Designer.cs +++ b/Hydroplane/FormHydroplane.Designer.cs @@ -1,6 +1,6 @@ namespace Hydroplane { - partial class Form1 + partial class FormHydroplane { /// /// Required designer variable. @@ -106,7 +106,7 @@ buttonRight.UseVisualStyleBackColor = true; buttonRight.Click += buttonMove_Click; // - // Form1 + // FormHydroplane // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; @@ -117,7 +117,7 @@ Controls.Add(buttonUp); Controls.Add(buttonCreate); Controls.Add(pictureBoxHydroplane); - Name = "Form1"; + Name = "FormHydroplane"; StartPosition = FormStartPosition.CenterScreen; Text = "Hydroplane"; ((System.ComponentModel.ISupportInitialize)pictureBoxHydroplane).EndInit(); diff --git a/Hydroplane/Form1.cs b/Hydroplane/FormHydroplane.cs similarity index 95% rename from Hydroplane/Form1.cs rename to Hydroplane/FormHydroplane.cs index 0e33b65..1f56883 100644 --- a/Hydroplane/Form1.cs +++ b/Hydroplane/FormHydroplane.cs @@ -1,18 +1,18 @@ namespace Hydroplane { - public partial class Form1 : Form + public partial class FormHydroplane : Form { /// /// - /// private DrawningHydroplane? _drawningHydroplane; - public Form1() + public FormHydroplane() { InitializeComponent(); } /// - /// + /// /// private void Draw() { diff --git a/Hydroplane/Form1.resx b/Hydroplane/FormHydroplane.resx similarity index 100% rename from Hydroplane/Form1.resx rename to Hydroplane/FormHydroplane.resx diff --git a/Hydroplane/Program.cs b/Hydroplane/Program.cs index 4ef437b..35abc6f 100644 --- a/Hydroplane/Program.cs +++ b/Hydroplane/Program.cs @@ -11,7 +11,7 @@ namespace Hydroplane // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FormHydroplane()); } } } \ No newline at end of file