From e26698bfede76cdc9b8a6ba621e2243b6d8341f3 Mon Sep 17 00:00:00 2001 From: Aleksandr4350 <mosevnin_2016@mail.ru> Date: Wed, 21 Feb 2024 13:35:42 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D1=87=D0=B5=D1=82=D0=BA=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BD?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSportCar/DrawningAiroplane.cs | 56 ++++++++++++++----- .../ProjectSportCar/EntityAiroplane.cs | 18 +++--- 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs b/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs index 78ab71b..72ec0c1 100644 --- a/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs +++ b/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs @@ -39,7 +39,6 @@ public class DrawningAiroplane /// </summary> private readonly int _drawningaAiroplaneHeight = 110; - /// <summary> /// Инициализация свойств /// </summary> @@ -47,15 +46,14 @@ public class DrawningAiroplane /// <param name="weight">Вес</param> /// <param name="bodyColor">Основной цвет</param> /// <param name="additionalColor">Дополнительный цвет</param> - /// <param name="bodyKit">Признак наличия обвеса</param> - /// <param name="wing">Признак наличия антикрыла</param> + /// <param name="toplivbak">Признак наличия бака</param> + /// <param name="radar">Признак наличия радара</param> /// <param name="sportLine">Признак наличия гоночной полосы</param> public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool wing, bool sportLine) + additionalColor, bool toplivbak, bool radar, bool sportLine) { EntityAiroplane = new EntityAiroplane(); - EntityAiroplane.Init(speed, weight, bodyColor, additionalColor, - bodyKit, wing, sportLine); + EntityAiroplane.Init(speed, weight, bodyColor, additionalColor, toplivbak, radar, sportLine); _pictureWidth = null; _pictureHeight = null; _startPosX = null; @@ -77,6 +75,20 @@ public bool SetPictureSize(int width, int height) { _pictureWidth = width; _pictureHeight = height; + + if (_startPosX.HasValue && _startPosY.HasValue) + { + if (_startPosX + _drawningAiroplaneWidth <= _pictureWidth) + { + _startPosX = 0; + } + + if (_startPosY + _drawningaAiroplaneHeight <= _pictureWidth) + { + _startPosY = 0; + } + + } return true; } return false; @@ -100,20 +112,22 @@ public bool SetPictureSize(int width, int height) { x = 0; } + else if (x + _drawningAiroplaneWidth > _pictureWidth.Value) { x = _pictureWidth.Value - _drawningAiroplaneWidth; } + if (y < 0) { y = 0; } + else if (y + _drawningaAiroplaneHeight > _pictureHeight.Value) { y = _pictureHeight.Value - _drawningaAiroplaneHeight; } - _startPosX = x; _startPosY = y; } @@ -189,7 +203,7 @@ public bool MoveTransport(DirectionType direction) //задняя часть самолета полукруг g.DrawArc(pen, _startPosX.Value + 20, _startPosY.Value + 60, 30,30,90,180); - //топливный бак + //сзади g.DrawEllipse(pen, _startPosX.Value + 25, _startPosY.Value + 55, 40,10); Brush brbr = new SolidBrush(Color.Brown); g.FillEllipse(brbr, _startPosX.Value + 25, _startPosY.Value + 55, 40,10); @@ -206,9 +220,8 @@ public bool MoveTransport(DirectionType direction) //вверх от тругольника до треугольника g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 60, _startPosX.Value + 150, _startPosY.Value + 60); - //крыло - g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 70, 70, 10); + g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 70, 70, 10); Brush brbl = new SolidBrush(Color.Black); g.FillEllipse(brbl, _startPosX.Value + 65, _startPosY.Value + 70, 70, 10); @@ -221,11 +234,26 @@ public bool MoveTransport(DirectionType direction) g.DrawEllipse(pen, _startPosX.Value + 60, _startPosY.Value + 95, 10, 10); g.DrawEllipse(pen, _startPosX.Value + 130, _startPosY.Value + 95, 10, 10); + //топливный бак + if (EntityAiroplane.Toplivbak) + { + g.FillRectangle(additionalBrush, _startPosX.Value + 80,_startPosY.Value + 45, 30, 15); + //g.FillRectangle(additionalBrush, _startPosX.Value + 35,_startPosY.Value + 23, 35, 15); + //g.FillRectangle(additionalBrush, _startPosX.Value + 10,_startPosY.Value + 23, 20, 15); + } + + //Радар + if (EntityAiroplane.Radar) + { + Brush brGreen = new SolidBrush(Color.LightGreen); + g.FillEllipse(brGreen, _startPosX.Value + 150, _startPosY.Value + 75, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 150, _startPosY.Value + 75, 10, 10); + } - //g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value +10, 20, 40); - //g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value,15, 15); - - // + //спортивная линия + if (EntityAiroplane.SportLine) { + g.FillRectangle(additionalBrush, _startPosX.Value + 138, _startPosY.Value + 60, 10, 30); + } } } diff --git a/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs b/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs index 240cb34..ab1c7ef 100644 --- a/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs +++ b/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs @@ -19,13 +19,13 @@ public class EntityAiroplane /// </summary> public Color AdditionalColor { get; private set; } /// <summary> - /// Признак (опция) наличия обвеса + /// Признак (опция) наличия бака /// </summary> - public bool BodyKit { get; private set; } + public bool Toplivbak { get; private set; } /// <summary> - /// Признак (опция) наличия антикрыла + /// Признак (опция) наличия радара // </summary> - public bool Wing { get; private set; } + public bool Radar { get; private set; } /// <summary> /// Признак (опция) наличия гоночной полосы /// </summary> @@ -41,17 +41,17 @@ public class EntityAiroplane /// <param name="weight"></вес> /// <param name="bodyColor"></Основной цвет> /// <param name="additionalColor"></Дополнительный цвет> - /// <param name="bodyKit"></ Признак наличия обвеса> - /// <param name="wing"></Признак (опция) наличия антикрыла> + /// <param name="toplivbak"></ Признак наличия бака> + /// <param name="radar"></Признак (опция) наличия радара> /// <param name="sportLine"></Признак (опция) наличия гоночной полосы> - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool toplivbak, bool radar, bool sportLine) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; - BodyKit = bodyKit; - Wing = wing; + Toplivbak = toplivbak; + Radar = radar; SportLine = sportLine; }