diff --git a/AirplaneWithRadar/AirplaneWithRadar.sln b/AirplaneWithRadar/AirplaneWithRadar.sln index 4a8e4db..5aea5a9 100644 --- a/AirplaneWithRadar/AirplaneWithRadar.sln +++ b/AirplaneWithRadar/AirplaneWithRadar.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32819.101 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirplaneWithRadar", "AirplaneWithRadar\AirplaneWithRadar.csproj", "{5BE6CDF5-36FB-4F6F-83FE-AA87400376ED}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AirplaneWithRadar", "AirplaneWithRadar\AirplaneWithRadar.csproj", "{5BE6CDF5-36FB-4F6F-83FE-AA87400376ED}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Элементы решения", "Элементы решения", "{D63FD6F4-AAFA-44BE-8233-A8A2B38C4526}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs index 040c5d1..25dafbc 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs @@ -14,15 +14,15 @@ namespace AirplaneWithRadar /// /// Класс-сущность /// - public EntityAirplane Airplane { private set; get; } + public EntityAirplane Airplane { protected set; get; } /// /// Левая координата отрисовки самолета /// - private float _startPosX; + protected float _startPosX; /// /// Верхняя кооридната отрисовки самолета /// - private float _startPosY; + protected float _startPosY; /// /// Ширина окна отрисовки /// @@ -49,6 +49,20 @@ namespace AirplaneWithRadar { Airplane = new EntityAirplane(speed, weight, bodyColor); } + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес автомобиля + /// Цвет кузова + /// Ширина отрисовки автомобиля + /// Высота отрисовки автомобиля + protected DrawingAirplane(int speed, float weight, Color bodyColor, int airplaneWidth, int airplaneHeight) : this(speed, weight, bodyColor) + { + _airplaneWidth = airplaneWidth; + _airplaneHeight = airplaneHeight; + } + /// /// Установка позиции самолета /// @@ -124,7 +138,7 @@ namespace AirplaneWithRadar /// Отрисовка автомобиля /// /// - public void DrawTransport(Graphics g) + public virtual void DrawTransport(Graphics g) { if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplaneWithRadar.cs new file mode 100644 index 0000000..3af778f --- /dev/null +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplaneWithRadar.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirplaneWithRadar +{ + internal class DrawingAirplaneWithRadar : DrawingAirplane + { + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес самолета + /// Цвет самолета + /// Дополнительный цвет + /// Признак наличия радара + /// Признак наличия дополнительных топливных баков + public DrawingAirplaneWithRadar(int speed, float weight, Color bodyColor, Color dopColor, bool radar, bool extraFuelTank) : base(speed, weight, bodyColor, 110, 60) + { + Airplane = new EntityAirplaneWithRadar(speed, weight, bodyColor, dopColor, radar, extraFuelTank); + } + public override void DrawTransport(Graphics g) + { + if (Airplane is not EntityAirplaneWithRadar airplaneWithRadar) + { + return; + } + Pen pen = new(Color.Black, 5); + Brush dopBrush = new SolidBrush(airplaneWithRadar.DopColor); + + if (airplaneWithRadar.Radar) + { + g.DrawLine(pen, _startPosX + 120, _startPosY + 30, _startPosX + 110, _startPosY + 60); + g.DrawLine(pen, _startPosX + 150, _startPosY + 60, _startPosX + 140, _startPosY + 30); + Point point1 = new Point((int)_startPosX + 120, (int)_startPosY + 30); + Point point2 = new Point((int)_startPosX + 110, (int)_startPosY + 60); + Point point3 = new Point((int)_startPosX + 150, (int)_startPosY + 60); + Point point4 = new Point((int)_startPosX + 140, (int)_startPosY + 30); + Point[] radarPoints = { point1, point2, point3, point4 }; + g.FillPolygon(dopBrush, radarPoints); + g.DrawEllipse(pen, _startPosX + 85, _startPosY + 15, 90, 20); + g.FillEllipse(dopBrush, _startPosX + 85, _startPosY + 15, 90, 20); + + } + + _startPosX += 10; + _startPosY += 5; + base.DrawTransport(g); + _startPosX -= 10; + _startPosY -= 5; + + if (airplaneWithRadar.ExtraFuelTank) + { + g.DrawLine(pen, _startPosX + 145, _startPosY + 98, _startPosX + 145, _startPosY + 108); + g.DrawLine(pen, _startPosX + 167, _startPosY + 98, _startPosX + 167, _startPosY + 108); + g.FillRectangle(dopBrush, _startPosX + 145, _startPosY + 98, 22, 10); + g.DrawEllipse(pen, _startPosX + 130, _startPosY + 102, 30, 6); + g.FillEllipse(dopBrush, _startPosX + 130, _startPosY + 102, 30, 6); + g.DrawLine(pen, _startPosX + 140, _startPosY + 102, _startPosX + 170, _startPosY + 102); + g.DrawLine(pen, _startPosX + 140, _startPosY + 108, _startPosX + 170, _startPosY + 108); + g.FillRectangle(dopBrush, _startPosX + 140, _startPosY + 102, 30, 6); + g.DrawLine(pen, _startPosX + 169, _startPosY + 102, _startPosX + 190, _startPosY + 105); + g.DrawLine(pen, _startPosX + 169, _startPosY + 108, _startPosX + 190, _startPosY + 105); + g.DrawLine(pen, _startPosX + 170, _startPosY + 105, _startPosX + 194, _startPosY + 105); + Point point1 = new Point((int)_startPosX + 169, (int)_startPosY + 102); + Point point2 = new Point((int)_startPosX + 190, (int)_startPosY + 105); + Point point3 = new Point((int)_startPosX + 169, (int)_startPosY + 108); + Point[] fuelTankPoints = { point1, point2, point3 }; + g.FillPolygon(dopBrush, fuelTankPoints); + } + } + } +} diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs new file mode 100644 index 0000000..b5ca4bc --- /dev/null +++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirplaneWithRadar +{ + internal class EntityAirplaneWithRadar : EntityAirplane + { + /// + /// Дополнительный цвет + /// + public Color DopColor { get; private set; } + /// + /// Признак наличия радара + /// + public bool Radar { get; private set; } + /// + /// Признак наличия дополнительных топливных баков + /// + public bool ExtraFuelTank { get; private set; } + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес автомобиля + /// Цвет кузова + /// Дополнительный цвет + /// Признак наличия радара + /// Признак наличия дополнительных топливных баков + public EntityAirplaneWithRadar(int speed, float weight, Color bodyColor, Color dopColor, bool radar, bool extraFuelTank) : base(speed, weight, bodyColor) + { + DopColor = dopColor; + Radar = radar; + ExtraFuelTank = extraFuelTank; + } + + } +} diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs index f556edf..0c78545 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.Designer.cs @@ -38,6 +38,7 @@ this.buttonLeft = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); + this.buttonCreateModif = new System.Windows.Forms.Button(); this.statusStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); this.SuspendLayout(); @@ -142,11 +143,22 @@ this.buttonRight.UseVisualStyleBackColor = true; this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // + // buttonCreateModif + // + this.buttonCreateModif.Location = new System.Drawing.Point(130, 372); + this.buttonCreateModif.Name = "buttonCreateModif"; + this.buttonCreateModif.Size = new System.Drawing.Size(140, 34); + this.buttonCreateModif.TabIndex = 7; + this.buttonCreateModif.Text = "Модификация"; + this.buttonCreateModif.UseVisualStyleBackColor = true; + this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // // FormAirplaneWithRadar // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonCreateModif); this.Controls.Add(this.buttonRight); this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonLeft); @@ -176,5 +188,6 @@ private Button buttonLeft; private Button buttonDown; private Button buttonRight; + private Button buttonCreateModif; } } \ No newline at end of file diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs index 33e772e..b5c0eb3 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplaneWithRadar.cs @@ -20,6 +20,17 @@ namespace AirplaneWithRadar pictureBoxAirplane.Image = bmp; } /// + /// + /// + private void SetData() + { + Random rnd = new(); + _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height); + toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}"; + toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}"; + toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}"; + } + /// /// "" /// /// @@ -27,13 +38,8 @@ namespace AirplaneWithRadar private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _airplane = new DrawingAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), - pictureBoxAirplane.Width, pictureBoxAirplane.Height); - toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}"; - toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}"; - toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}"; + _airplane = new DrawingAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(); Draw(); } @@ -70,7 +76,18 @@ namespace AirplaneWithRadar { } - - + /// + /// "" + /// + /// + /// + private void ButtonCreateModif_Click(object sender, EventArgs e) + { + Random rnd = new(); + _airplane = new DrawingAirplaneWithRadar(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), + Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,2))); + SetData(); + Draw(); + } } } \ No newline at end of file diff --git a/AirplaneWithRadar/EntityAirplaneWithRadar.cs b/AirplaneWithRadar/EntityAirplaneWithRadar.cs new file mode 100644 index 0000000..d555ecb --- /dev/null +++ b/AirplaneWithRadar/EntityAirplaneWithRadar.cs @@ -0,0 +1,8 @@ +using System; + +public class Class1 +{ + public Class1() + { + } +}