diff --git a/Airbus/Airbus/DrawingAirbus.cs b/Airbus/Airbus/DrawingAirbus.cs index 12f6603..4ad0aa8 100644 --- a/Airbus/Airbus/DrawingAirbus.cs +++ b/Airbus/Airbus/DrawingAirbus.cs @@ -8,8 +8,8 @@ namespace Airbus { internal class DrawingAirbus : DrawningAirplane { - public DrawingAirbus(int speed, float weight, Color bodyColor, Color dopColor, bool compartment, bool engine) : - base(speed, weight, bodyColor, 150, 30) + public DrawingAirbus(int speed, float weight, Color bodyColor, Color dopColor, bool compartment, bool engine, IPorthole formPorthole) : + base(speed, weight, bodyColor, 150, 30, formPorthole) { airplane = new EntityAirbus(speed, weight, bodyColor, dopColor, compartment, engine); } diff --git a/Airbus/Airbus/DrawingAirplane.cs b/Airbus/Airbus/DrawingAirplane.cs index 71af918..efe2fe7 100644 --- a/Airbus/Airbus/DrawingAirplane.cs +++ b/Airbus/Airbus/DrawingAirplane.cs @@ -10,7 +10,7 @@ namespace Airbus { /// Класс-сущность public EntityAirplane airplane { protected set; get; } - public DrawningPorthole porthole { private set; get; } + public IPorthole porthole { private set; get; } /// Левая координата отрисовки автомобиля protected float _startPosX; @@ -23,10 +23,10 @@ namespace Airbus /// Ширина отрисовки автомобиля protected readonly int _airplaneWidth = 150; //Ширина отрисовки корабля protected readonly int _airplaneHeight = 30; //Высота отрисовки корабля - public DrawningAirplane(int speed, float weight, Color bodyColor) + public DrawningAirplane(int speed, float weight, Color bodyColor, IPorthole formPorthole) { airplane = new EntityAirplane(speed, weight, bodyColor); - porthole = new DrawningPorthole(); + porthole = formPorthole; } public void SetPosition(int x, int y, int width, int height) @@ -62,8 +62,8 @@ namespace Airbus } } protected DrawningAirplane(int speed, float weight, Color bodyColor, int - carWidth, int carHeight) : - this(speed, weight, bodyColor) + carWidth, int carHeight, IPorthole formPorthole) : + this(speed, weight, bodyColor, formPorthole) { _airplaneWidth = carWidth; _airplaneHeight = carHeight; @@ -97,6 +97,7 @@ namespace Airbus g.DrawEllipse(new(Color.Black, 2), _startPosX + _airplaneWidth - 30, _startPosY + _airplaneHeight + 25, 4, 4); g.DrawEllipse(new(Color.Black, 2), _startPosX + _airplaneWidth - 35, _startPosY + _airplaneHeight + 25, 4, 4); g.DrawEllipse(new(Color.Black, 2), _startPosX , _startPosY + _airplaneHeight + 25, 4, 4); + porthole.DrawPortholes(g, Color.Red, _startPosX, _startPosY); } public void Upd_count_Porthole(CountPorthole count) diff --git a/Airbus/Airbus/DrawingRhombPorthole.cs b/Airbus/Airbus/DrawingRhombPorthole.cs new file mode 100644 index 0000000..2d3ddbf --- /dev/null +++ b/Airbus/Airbus/DrawingRhombPorthole.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal class DrawingRhombPorthole : DrawningPorthole + { + protected override void DrawPorthole(Graphics g, Color color, float posX, float posY) + { + Pen pen = new(color, 1); + PointF[] point = new PointF[4]; + point[0] = new PointF(posX - 2, posY); + point[1] = new PointF(posX, posY - 2); + point[2] = new PointF(posX + 2, posY); + point[3] = new PointF(posX, posY + 2); + + g.DrawPolygon(pen, point); + } + } +} + diff --git a/Airbus/Airbus/DrawingSquarePorthole.cs b/Airbus/Airbus/DrawingSquarePorthole.cs new file mode 100644 index 0000000..f04179f --- /dev/null +++ b/Airbus/Airbus/DrawingSquarePorthole.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal class DrawingSquarePorthole : DrawningPorthole + { + protected override void DrawPorthole(Graphics g, Color color, float posX, float posY) + { + g.DrawRectangle(new(color, 1), posX, posY, 5, 5); + } + } +} diff --git a/Airbus/Airbus/DrawningPorthole.cs b/Airbus/Airbus/DrawningPorthole.cs index 75fff1c..faafef4 100644 --- a/Airbus/Airbus/DrawningPorthole.cs +++ b/Airbus/Airbus/DrawningPorthole.cs @@ -28,9 +28,9 @@ namespace Airbus } } - public virtual void DrawPorthole(Graphics g, Color color, float posX, float posY) + protected virtual void DrawPorthole(Graphics g, Color color, float posX, float posY) { - g.DrawEllipse(new(color, 2), posX, posY, 5, 5); + g.DrawEllipse(new(color, 1), posX, posY, 5, 5); } } diff --git a/Airbus/Airbus/FormAirplane.cs b/Airbus/Airbus/FormAirplane.cs index 494f3ee..f19d913 100644 --- a/Airbus/Airbus/FormAirplane.cs +++ b/Airbus/Airbus/FormAirplane.cs @@ -38,8 +38,9 @@ namespace Airbus } private void buttonCreate_Click(object sender, EventArgs e) { + Random random = new Random(); - airplane = new DrawningAirplane(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + airplane = new DrawningAirplane(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), new DrawningPorthole()); SetData(); Draw(); @@ -75,7 +76,6 @@ namespace Airbus { case "10": count_porthole = CountPorthole.Ten; - toolStripStatusLabelSpeed.Text = Convert.ToString((int)count_porthole); break; case "20": count_porthole = CountPorthole.Twenty; @@ -102,7 +102,7 @@ namespace Airbus airplane = new DrawingAirbus(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - true, true); + true, true, new DrawningPorthole()); SetData(); Draw(); } diff --git a/Airbus/Airbus/FormMap.Designer.cs b/Airbus/Airbus/FormMap.Designer.cs index d4556b7..7e671eb 100644 --- a/Airbus/Airbus/FormMap.Designer.cs +++ b/Airbus/Airbus/FormMap.Designer.cs @@ -38,6 +38,8 @@ this.buttonDown = new System.Windows.Forms.Button(); this.buttonModCreate = new System.Windows.Forms.Button(); this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); + this.comboBoxPortholeSer = new System.Windows.Forms.ComboBox(); + this.comboBoxFormPorthole = new System.Windows.Forms.ComboBox(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.SuspendLayout(); @@ -165,11 +167,37 @@ this.comboBoxSelectorMap.TabIndex = 8; this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelectorMap_SelectedIndexChanged); // + // comboBoxPortholeSer + // + this.comboBoxPortholeSer.FormattingEnabled = true; + this.comboBoxPortholeSer.Items.AddRange(new object[] { + "10", + "20", + "30"}); + this.comboBoxPortholeSer.Location = new System.Drawing.Point(139, 12); + this.comboBoxPortholeSer.Name = "comboBoxPortholeSer"; + this.comboBoxPortholeSer.Size = new System.Drawing.Size(121, 23); + this.comboBoxPortholeSer.TabIndex = 9; + // + // comboBoxFormPorthole + // + this.comboBoxFormPorthole.FormattingEnabled = true; + this.comboBoxFormPorthole.Items.AddRange(new object[] { + "Обычные", + "Крадратные", + "Ромбом"}); + this.comboBoxFormPorthole.Location = new System.Drawing.Point(139, 41); + this.comboBoxFormPorthole.Name = "comboBoxFormPorthole"; + this.comboBoxFormPorthole.Size = new System.Drawing.Size(121, 23); + this.comboBoxFormPorthole.TabIndex = 10; + // // FormMap // 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.comboBoxFormPorthole); + this.Controls.Add(this.comboBoxPortholeSer); this.Controls.Add(this.comboBoxSelectorMap); this.Controls.Add(this.buttonModCreate); this.Controls.Add(this.buttonDown); @@ -201,5 +229,7 @@ private Button buttonDown; private Button buttonModCreate; private ComboBox comboBoxSelectorMap; + private ComboBox comboBoxPortholeSer; + private ComboBox comboBoxFormPorthole; } } diff --git a/Airbus/Airbus/FormMap.cs b/Airbus/Airbus/FormMap.cs index c452576..dcbc4b0 100644 --- a/Airbus/Airbus/FormMap.cs +++ b/Airbus/Airbus/FormMap.cs @@ -28,9 +28,37 @@ namespace Airbus } private void buttonCreate_Click(object sender, EventArgs e) { - Random random = new Random(); - var airbus = new DrawningAirplane(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + IPorthole formPorthole = new DrawningPorthole(); + switch (comboBoxFormPorthole.Text) + { + case "Обычные": + formPorthole = new DrawningPorthole(); + break; + case "Крадратные": + formPorthole = new DrawingSquarePorthole(); + break; + case "Ромбом": + formPorthole = new DrawingRhombPorthole(); + break; + } + Random random = new Random(); + var airbus = new DrawningAirplane(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), formPorthole); + CountPorthole count_porthole = CountPorthole.Ten; + switch (comboBoxPortholeSer.Text) + { + case "10": + count_porthole = CountPorthole.Ten; + break; + case "20": + count_porthole = CountPorthole.Twenty; + break; + case "30": + count_porthole = CountPorthole.Thirty; + break; + + } + airbus.Upd_count_Porthole(count_porthole); SetData(airbus); } @@ -58,15 +86,45 @@ namespace Airbus private void buttonModCreate_Click(object sender, EventArgs e) { + IPorthole formPorthole = new DrawningPorthole(); + switch (comboBoxFormPorthole.Text) + { + case "Обычные": + formPorthole = new DrawningPorthole(); + break; + case "Крадратные": + formPorthole = new DrawingSquarePorthole(); + + break; + case "Ромбом": + formPorthole = new DrawingRhombPorthole(); + break; + } Random random = new Random(); var airbus = new DrawingAirbus(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - true, true); + true, true, formPorthole); + CountPorthole count_porthole = CountPorthole.Ten; + 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); SetData(airbus); } - + private void comboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBoxSelectorMap.Text) diff --git a/Airbus/Airbus/IPorthole.cs b/Airbus/Airbus/IPorthole.cs index fda8628..b015ce8 100644 --- a/Airbus/Airbus/IPorthole.cs +++ b/Airbus/Airbus/IPorthole.cs @@ -10,6 +10,6 @@ namespace Airbus { int CountPorthole { get; set; } - public void DrawPorthole(Graphics g, Color color, float posX, float posY); + public void DrawPortholes(Graphics g, Color color, float posX, float posY); } }