From 0aae5667ec6cdcd1b02f09d279723da245e26204 Mon Sep 17 00:00:00 2001 From: ivans Date: Thu, 13 Jun 2024 11:53:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B101?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSeaplane/DrawingSeaplane.cs | 28 +++---- .../ProjectSeaplane/DrawingWindows.cs | 77 +++++++++++++++++++ .../ProjectSeaplane/EntitySeaplane.cs | 5 +- .../ProjectSeaplane/FormSeaplane.Designer.cs | 16 ++++ .../ProjectSeaplane/FormSeaplane.cs | 4 +- .../ProjectSeaplane/NumberOfWindows.cs | 25 ++++++ 6 files changed, 132 insertions(+), 23 deletions(-) create mode 100644 ProjectSeaplane/ProjectSeaplane/DrawingWindows.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/NumberOfWindows.cs diff --git a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs index a70537f..a1d6f4c 100644 --- a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs @@ -8,7 +8,7 @@ public class DrawingSeaplane /// Класс-сущность /// public EntitySeaplane? EntitySeaplane { get; private set; } - + public DrawingWindows Windows; /// /// Ширина окна /// @@ -32,7 +32,7 @@ public class DrawingSeaplane /// /// Ширина прорисовки автомобиля /// - private readonly int _drawningSeaplaneWidth = 155; + private readonly int _drawningSeaplaneWidth = 160; /// /// Высота прорисовки автомобиля @@ -49,13 +49,15 @@ public class DrawingSeaplane /// Тип "шасси" (0 - поплавки, 1 - лодочный тип) /// Признак наличия радара public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar) - { + { EntitySeaplane = new EntitySeaplane(); EntitySeaplane.Init(speed, weight, bodyColor, additionalColor, landingGear, radar); _pictureWidth = null; _pictureHeight = null; _startPosX = null; _startPosY = null; + Windows = new DrawingWindows(); + Windows.WinNum = 0; } /// @@ -137,7 +139,7 @@ public class DrawingSeaplane { //влево case DirectionType.Left: - if (_startPosX.Value - EntitySeaplane.Step > 0) + if (_startPosX.Value - EntitySeaplane.Step > 1) { _startPosX -= (int)EntitySeaplane.Step; } @@ -149,7 +151,7 @@ public class DrawingSeaplane _startPosY -= (int)EntitySeaplane.Step; } return true; - // вправо + //вправо case DirectionType.Right: if (_startPosX + (int)EntitySeaplane.Step < _pictureWidth - _drawningSeaplaneWidth) @@ -177,11 +179,12 @@ public class DrawingSeaplane { if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue) { + return; } - Pen pen = new(Color.Black); Pen penKraya = new(Color.Black, 2); Brush additionalBrush = new SolidBrush(EntitySeaplane.AdditionalColor); + Pen pen = new(Color.Black); //Начинаем рисовать //Полигон для хвоста Point point1 = new Point(_startPosX.Value, _startPosY.Value); @@ -215,17 +218,6 @@ public class DrawingSeaplane //Крыло g.FillEllipse(brAdditional, _startPosX.Value + 45, _startPosY.Value + 43, 50, 7); - - //Иллюминаторы - - for (int i = 0; i < 80; i += 10) - { - - g.FillEllipse(brWhity, _startPosX.Value + 30 + i, _startPosY.Value + 34, 6, 6); - - - } - //Поплавки if (EntitySeaplane.LandingGear) @@ -253,7 +245,7 @@ public class DrawingSeaplane } //Пилоты g.FillEllipse(brWhity, _startPosX.Value + 115, _startPosY.Value + 34, 20, 8); - + Windows.DrawWindows(g, _startPosX.Value + 5, _startPosY.Value + 5); } } diff --git a/ProjectSeaplane/ProjectSeaplane/DrawingWindows.cs b/ProjectSeaplane/ProjectSeaplane/DrawingWindows.cs new file mode 100644 index 0000000..8db9758 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/DrawingWindows.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectSeaplane; + +public class DrawingWindows +{ + /// + /// Класс-сущность + /// + public EntitySeaplane? EntitySeaplane { get; private set; } + /// + /// Количество иллюминаторов + /// + private NumberOfWindows numberOfWindows; + public int WinNum + { + set + { + if (value == 10 || value < 15) + { + numberOfWindows = NumberOfWindows.TenWindows; + } + else if (value == 20 || (value >= 15 && value < 25)) + { + numberOfWindows = NumberOfWindows.TwentyWindows; + } + else if (value == 30 || (value >= 25 && value < 31)) + { + numberOfWindows = NumberOfWindows.ThirtyWindows; + } + } + } + /// + /// Прорисовка доп класса + /// + /// + public void DrawWindows(Graphics g, int _startPosX, int _startPosY) + { + + Brush brWhity = new SolidBrush(Color.GhostWhite); + + + switch (numberOfWindows) + { + case NumberOfWindows.TenWindows: + for (int i = 0; i < 60; i += 6) + { + g.FillEllipse(brWhity, _startPosX + 30 + i, _startPosY + 26, 4, 4); + } + break; + case NumberOfWindows.TwentyWindows: + for (int j = 0; j < 5; j += 4) + { + for (int i = 0; i < 60; i += 6) + { + g.FillEllipse(brWhity, _startPosX + 30 + i, _startPosY + 26 + j, 4, 4); + } + } + break; + case NumberOfWindows.ThirtyWindows: + for (int j = 0; j < 9; j += 4) + { + for (int i = 0; i < 60; i += 6) + { + g.FillEllipse(brWhity, _startPosX + 30 + i, _startPosY + 26 + j, 4, 4); + } + } + break; + + } + + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs index 7cc3293..295d834 100644 --- a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs @@ -1,4 +1,6 @@ -namespace ProjectSeaplane; +using static System.Windows.Forms.LinkLabel; + +namespace ProjectSeaplane; /// /// Класс-сущность Гидросамолета /// @@ -49,6 +51,5 @@ public class EntitySeaplane AdditionalColor = additionalColor; LandingGear = landingGear; Radar = radar; - } } \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs index 0a9fcd0..cb3e1bc 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs @@ -34,7 +34,9 @@ buttonDown = new Button(); buttonUp = new Button(); buttonRight = new Button(); + numericUpDownNumberOfWindows = new NumericUpDown(); ((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownNumberOfWindows).BeginInit(); SuspendLayout(); // // pictureBoxSeaplane @@ -109,11 +111,23 @@ buttonRight.UseVisualStyleBackColor = false; buttonRight.Click += ButtonMove_Click; // + // numericUpDownNumberOfWindows + // + numericUpDownNumberOfWindows.Increment = new decimal(new int[] { 10, 0, 0, 0 }); + numericUpDownNumberOfWindows.Location = new Point(93, 349); + numericUpDownNumberOfWindows.Maximum = new decimal(new int[] { 30, 0, 0, 0 }); + numericUpDownNumberOfWindows.Minimum = new decimal(new int[] { 10, 0, 0, 0 }); + numericUpDownNumberOfWindows.Name = "numericUpDownNumberOfWindows"; + numericUpDownNumberOfWindows.Size = new Size(47, 23); + numericUpDownNumberOfWindows.TabIndex = 8; + numericUpDownNumberOfWindows.Value = new decimal(new int[] { 10, 0, 0, 0 }); + // // FormSeaplane // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(590, 379); + Controls.Add(numericUpDownNumberOfWindows); Controls.Add(buttonRight); Controls.Add(buttonUp); Controls.Add(buttonDown); @@ -123,6 +137,7 @@ Name = "FormSeaplane"; Text = "Гидросамолет"; ((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownNumberOfWindows).EndInit(); ResumeLayout(false); } @@ -134,5 +149,6 @@ private Button buttonDown; private Button buttonUp; private Button buttonRight; + private NumericUpDown numericUpDownNumberOfWindows; } } \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs index 3883816..f26d10c 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs @@ -46,7 +46,7 @@ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); _drawingSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); _drawingSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100)); - + _drawingSeaplane.Windows.WinNum = (int)numericUpDownNumberOfWindows.Value; Draw(); } /// @@ -84,7 +84,5 @@ Draw(); } } - - } } \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/NumberOfWindows.cs b/ProjectSeaplane/ProjectSeaplane/NumberOfWindows.cs new file mode 100644 index 0000000..d6bb463 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/NumberOfWindows.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectSeaplane; +/// +/// Количество иллюминаторов +/// +public enum NumberOfWindows +{ + /// + /// 10 иллюминаторов + /// + TenWindows, + /// + /// 20 иллюминаторов + /// + TwentyWindows, + /// + /// 30 иллюминаторов + /// + ThirtyWindows +}