diff --git a/AirplaneWithRadar/AirplaneWithRadar/CountPortholes.cs b/AirplaneWithRadar/AirplaneWithRadar/CountPortholes.cs
new file mode 100644
index 0000000..83a8bac
--- /dev/null
+++ b/AirplaneWithRadar/AirplaneWithRadar/CountPortholes.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirplaneWithRadar
+{
+ internal enum CountPortholes
+ {
+ Ten = 10,
+ Twetwenty = 20,
+ Thirty = 30,
+ }
+}
diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs
index c0a6314..3d6df27 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs
@@ -10,6 +10,7 @@ namespace AirplaneWithRadar
/// Класс-сущность
///
public EntityAirplane Airplane { private set; get; }
+ public DrawningAirplanePortholes DrawningPortholes { get; private set; }
///
/// Левая координата отрисовки самолёта
///
@@ -44,6 +45,8 @@ namespace AirplaneWithRadar
{
Airplane = new EntityAirplane();
Airplane.Init(speed, weight, bodyColor);
+ DrawningPortholes = new();
+ DrawningPortholes.CountPortholes = 30;
}
///
/// Установка позиции
@@ -141,8 +144,8 @@ namespace AirplaneWithRadar
g.FillPolygon(brush, point);
//крылья
- g.DrawLine(pen, _startPosX + 20, _startPosY + h - 3, _startPosX + 60, _startPosY + h - 3);
- g.DrawLine(pen, _startPosX + 20, _startPosY + h - 2, _startPosX + 60, _startPosY + h - 2);
+ g.DrawLine(pen, _startPosX + 20, _startPosY + h , _startPosX + 60, _startPosY + h );
+ g.DrawLine(pen, _startPosX + 20, _startPosY + h +1 , _startPosX + 60, _startPosY + h +1);
g.DrawLine(pen, _startPosX - 1, _startPosY + h / 3, _startPosX + 15, _startPosY + h / 3);
g.DrawLine(pen, _startPosX - 1, _startPosY + h / 3 + 1, _startPosX + 15, _startPosY + h / 3 + 1);
@@ -152,7 +155,9 @@ namespace AirplaneWithRadar
g.DrawRectangle(pen, _startPosX + 20, _startPosY + h + (h / 3), 2, 2);
g.DrawRectangle(pen, _startPosX + 24, _startPosY + h + (h / 3), 2, 2);
g.DrawRectangle(pen, _startPosX + _airplaneWidth - 20, _startPosY + h + (h / 3), 2, 2);
+ DrawningPortholes.DrawPortholes(g, (int)_startPosX+5, (int)_startPosY+5, (int)_airplaneWidth);
_startPosY -= 4;
+
}
///
/// Смена границ формы отрисовки
diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplanePortholes.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplanePortholes.cs
new file mode 100644
index 0000000..f67964c
--- /dev/null
+++ b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplanePortholes.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirplaneWithRadar
+{
+ internal class DrawningAirplanePortholes
+ {
+ private CountPortholes _countPortholes;
+
+ public int CountPortholes
+ {
+ get
+ {
+ return (int)_countPortholes;
+ }
+ set
+ {
+ _countPortholes = (CountPortholes)(value);
+ }
+ }
+
+ public void DrawPortholes(Graphics g, int _startPosX, int _startPosY, int _airplaneWidth)
+ {
+ int middle = _startPosX + ((_airplaneWidth - 25) / 2);
+ DrawPorthole(g, middle, _startPosY);
+ int left = middle - 5;
+ int right = middle + 5;
+ for (var i = 1; i <= CountPortholes / 4; i += 1)
+ {
+ DrawPorthole(g, left, _startPosY);
+ left -= 5;
+ DrawPorthole(g, right, _startPosY);
+ right += 5;
+ }
+ }
+
+ private void DrawPorthole(Graphics g, int _startPosX, int _startPosY)
+ {
+ Pen pen = new(Color.Black);
+ g.DrawRectangle(pen, _startPosX, _startPosY, 2, 2);
+ }
+ }
+}
\ No newline at end of file
diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.Designer.cs
index ff7bc2d..387adce 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.Designer.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.Designer.cs
@@ -38,6 +38,8 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
+ this.labelPortholes = new System.Windows.Forms.Label();
+ this.comboBoxPortholes = new System.Windows.Forms.ComboBox();
this.statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
this.SuspendLayout();
@@ -142,11 +144,34 @@
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
+ // labelPortholes
+ //
+ this.labelPortholes.AutoSize = true;
+ this.labelPortholes.Location = new System.Drawing.Point(12, 374);
+ this.labelPortholes.Name = "labelPortholes";
+ this.labelPortholes.Size = new System.Drawing.Size(177, 15);
+ this.labelPortholes.TabIndex = 7;
+ this.labelPortholes.Text = "Колличество иллюминаторов:";
+ //
+ // comboBoxPortholes
+ //
+ this.comboBoxPortholes.FormattingEnabled = true;
+ this.comboBoxPortholes.Items.AddRange(new object[] {
+ "10",
+ "20",
+ "30"});
+ this.comboBoxPortholes.Location = new System.Drawing.Point(195, 371);
+ this.comboBoxPortholes.Name = "comboBoxPortholes";
+ this.comboBoxPortholes.Size = new System.Drawing.Size(44, 23);
+ this.comboBoxPortholes.TabIndex = 8;
+ //
// FormAirplane
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.comboBoxPortholes);
+ this.Controls.Add(this.labelPortholes);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
@@ -176,5 +201,7 @@
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
+ private Label labelPortholes;
+ private ComboBox comboBoxPortholes;
}
}
\ No newline at end of file
diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs
index 3de3911..f980d42 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs
@@ -32,6 +32,7 @@ namespace AirplaneWithRadar
Random rnd = new();
_airplane = new DrawningAirplane();
_airplane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ _airplane.DrawningPortholes.CountPortholes = Convert.ToInt32(comboBoxPortholes.Text);
_airplane.SetPosition(rnd.Next(20, 100), rnd.Next(20, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}";
toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}";