From e42016dec629434615ddc0d39316575b78406b41 Mon Sep 17 00:00:00 2001 From: NikGapon <45200250+NikGapon@users.noreply.github.com> Date: Wed, 26 Oct 2022 21:45:24 +0400 Subject: [PATCH] final --- Airbus/Airbus/CountPorthole.cs | 1 + Airbus/Airbus/DrawingAirbus.cs | 20 +++++++++++--------- Airbus/Airbus/DrawningPorthole.cs | 4 +++- Airbus/Airbus/FormAirbus.cs | 22 ++++++++++++++++++++-- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Airbus/Airbus/CountPorthole.cs b/Airbus/Airbus/CountPorthole.cs index 473e68b..a64a5cb 100644 --- a/Airbus/Airbus/CountPorthole.cs +++ b/Airbus/Airbus/CountPorthole.cs @@ -8,6 +8,7 @@ namespace Airbus { internal enum CountPorthole { + None = 0, Ten = 10, Twenty = 20, Thirty = 30, diff --git a/Airbus/Airbus/DrawingAirbus.cs b/Airbus/Airbus/DrawingAirbus.cs index 1421f4a..1c0df93 100644 --- a/Airbus/Airbus/DrawingAirbus.cs +++ b/Airbus/Airbus/DrawingAirbus.cs @@ -10,7 +10,7 @@ namespace Airbus { /// Класс-сущность public EntityAirbus airbus { private set; get; } - + public DrawningPorthole porthole { private set; get; } /// Левая координата отрисовки автомобиля private float _startPosX; /// Верхняя кооридната отрисовки автомобиля @@ -25,6 +25,7 @@ namespace Airbus public void Init(int speed, float weight, Color bodyColor) { airbus = new EntityAirbus(); + porthole = new DrawningPorthole(); airbus.Init(speed, weight, bodyColor); } @@ -39,7 +40,10 @@ namespace Airbus _pictureWidth = width; _pictureHeight = height; } - + public void Upd_count_Porthole(CountPorthole count) + { + porthole.CountPorthole = (int)count; + } public void MoveTransport(Direction direction) { if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return; @@ -63,12 +67,13 @@ namespace Airbus public void DrawTransport(Graphics g) { + if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) { return; } Pen pen = new(Color.Black); - + SolidBrush brush = new SolidBrush(airbus?.BodyColor ?? Color.White); g.FillPolygon(brush, new[] { @@ -86,15 +91,11 @@ namespace Airbus new Point((int)(_startPosX), (int)(_startPosY)), }); g.DrawEllipse(new(Color.Blue, 2), _startPosX, _startPosY + 15, 25, 5); - - /*g.DrawEllipse(new(Color.Red, 2), _startPosX + _airbusWidth - 40, _startPosY + 30, 20, 20); - g.DrawEllipse(new(Color.Red, 2), _startPosX + _airbusWidth - 65, _startPosY + 30, 20, 20); - g.DrawEllipse(new(Color.Red, 2), _startPosX + _airbusWidth - 90, _startPosY + 30, 20, 20);*/ - g.DrawEllipse(new(Color.Black, 2), _startPosX + _airbusWidth - 30, _startPosY + _airbusHeight + 25, 4, 4); g.DrawEllipse(new(Color.Black, 2), _startPosX + _airbusWidth - 35, _startPosY + _airbusHeight + 25, 4, 4); g.DrawEllipse(new(Color.Black, 2), _startPosX , _startPosY + _airbusHeight + 25, 4, 4); - + + porthole.DrawPorthole(g, Color.Red, _startPosX, _startPosY); } public void ChangeBorders(int width, int height) @@ -115,6 +116,7 @@ namespace Airbus { _startPosY = _pictureHeight.Value - _airbusHeight; } + } } diff --git a/Airbus/Airbus/DrawningPorthole.cs b/Airbus/Airbus/DrawningPorthole.cs index bbafa85..ad1e432 100644 --- a/Airbus/Airbus/DrawningPorthole.cs +++ b/Airbus/Airbus/DrawningPorthole.cs @@ -20,10 +20,12 @@ namespace Airbus } public void DrawPorthole(Graphics g, Color color, float posX, float posY) { - for (int i = 0; i < CountPorthole; i++) + + for (int i = 0; i < (int)CountPorthole; i++) { g.DrawEllipse(new(color, 2), posX + 150 - i * 7, posY + 30, 5, 5); } + } } } diff --git a/Airbus/Airbus/FormAirbus.cs b/Airbus/Airbus/FormAirbus.cs index b244946..cc5ee21 100644 --- a/Airbus/Airbus/FormAirbus.cs +++ b/Airbus/Airbus/FormAirbus.cs @@ -13,10 +13,11 @@ namespace Airbus public partial class FormAirbus : Form { private DrawningAirbus airbus; - + public FormAirbus() { InitializeComponent(); + } private void Draw() @@ -66,10 +67,27 @@ namespace Airbus airbus?.ChangeBorders(pictureBox.Width, pictureBox.Height); Draw(); } - + CountPorthole count_porthole = CountPorthole.None; private void comboBoxPortholeSer_SelectedIndexChanged(object sender, EventArgs e) { + + switch (comboBoxPortholeSer.Text) + { + case "10": + count_porthole = CountPorthole.Ten; + toolStripStatusLabelSpeed.Text = Convert.ToString((int)count_porthole); + break; + case "20": + count_porthole = CountPorthole.Twenty; + break; + case "30": + count_porthole = CountPorthole.Thirty; + break; + + } + airbus.Upd_count_Porthole(count_porthole); + Draw(); } } }