diff --git a/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs
index 05d9a74..141bf18 100644
--- a/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs
+++ b/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs
@@ -14,15 +14,15 @@ namespace AntiAircraftGun
///
/// Класс-сущность
///
- public EntityAntiAircraftGun AntiAircraftGun { private set; get; }
+ public EntityAntiAircraftGun AntiAircraftGun { protected set; get; }
///
/// Левая координата отрисовки зенитного орудия
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки зенитного орудия
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
@@ -45,10 +45,23 @@ namespace AntiAircraftGun
/// Скорость
/// Вес зенитного орудия
/// Цвет корпуса
- public void Init(int speed, float weight, Color bodyColor)
+ public DrawingAntiAircraftGun(int speed, float weight, Color bodyColor)
{
- AntiAircraftGun = new EntityAntiAircraftGun();
- AntiAircraftGun.Init(speed, weight, bodyColor);
+ AntiAircraftGun = new EntityAntiAircraftGun(speed, weight, bodyColor);
+ }
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес зенитного орудия
+ /// Цвет корпуса
+ /// Ширина отрисовки зенитного орудия
+ /// Высота отрисовки зенитного орудия
+ protected DrawingAntiAircraftGun(int speed, float weight, Color bodyColor, int antiAircrafGunWidth, int antiAircrafGunHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _antiAircrafGunWidth = antiAircrafGunWidth;
+ _antiAircrafGunHeight = antiAircrafGunHeight;
}
///
/// Установка позиции зенитного орудия
@@ -113,7 +126,7 @@ namespace AntiAircraftGun
/// Отрисовка зенитного орудия
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
@@ -130,7 +143,7 @@ namespace AntiAircraftGun
g.DrawEllipse(pen, _startPosX + 70, _startPosY + 20, 20, 20);
//катки в гусеницах
Brush brBlack = new SolidBrush(Color.Black);
- g.FillEllipse(brBlack, _startPosX +1, _startPosY + 21, 18, 18);
+ g.FillEllipse(brBlack, _startPosX + 1, _startPosY + 21, 18, 18);
g.FillEllipse(brBlack, _startPosX + 71, _startPosY + 21, 18, 18);
g.FillEllipse(brBlack, _startPosX + 19, _startPosY + 30, 11, 11);
g.FillEllipse(brBlack, _startPosX + 58, _startPosY + 30, 11, 11);
diff --git a/AntiAircraftGun/AntiAircraftGun/DrawingUpdateAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/DrawingUpdateAntiAircraftGun.cs
new file mode 100644
index 0000000..67830c0
--- /dev/null
+++ b/AntiAircraftGun/AntiAircraftGun/DrawingUpdateAntiAircraftGun.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AntiAircraftGun
+{
+ internal class DrawingUpdateAntiAircraftGun : DrawingAntiAircraftGun
+ {
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес зенитного орудия
+ /// Цвет корпуса
+ /// Дополнительный цвет
+ /// Признак наличия башни с орудием
+ /// Признак наличия радара
+ public DrawingUpdateAntiAircraftGun(int speed, float weight, Color bodyColor, Color dopColor, bool gun, bool radar) :
+ base(speed, weight, bodyColor, 110, 75)
+ {
+ AntiAircraftGun = new EntityUpdateAntiAircraftGun(speed, weight, bodyColor, dopColor, gun, radar);
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if (AntiAircraftGun is not EntityUpdateAntiAircraftGun updateAntiAircraftGun)
+ {
+ return;
+ }
+ Pen dopPen = new(updateAntiAircraftGun.DopColor, 4);
+ Brush dopBrush = new SolidBrush(updateAntiAircraftGun.DopColor);
+
+ if (updateAntiAircraftGun.Gun)
+ {
+ g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 30, 25, 15);
+ g.FillRectangle(dopBrush, _startPosX + 60, _startPosY + 38, 50, 3);
+ }
+ if (updateAntiAircraftGun.Radar)
+ {
+ g.DrawLine(dopPen, _startPosX + 27, _startPosY + 37, _startPosX + 27, _startPosY + 20);
+ g.FillPie(dopBrush, _startPosX + 3, _startPosY, 30, 30, -45, 180);
+ }
+ _startPosY += 35;
+ base.DrawTransport(g);
+ _startPosY -= 35;
+ }
+ }
+}
diff --git a/AntiAircraftGun/AntiAircraftGun/EntityAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/EntityAntiAircraftGun.cs
index f81d3d8..a9705c9 100644
--- a/AntiAircraftGun/AntiAircraftGun/EntityAntiAircraftGun.cs
+++ b/AntiAircraftGun/AntiAircraftGun/EntityAntiAircraftGun.cs
@@ -31,7 +31,7 @@ namespace AntiAircraftGun
///
///
///
- public void Init(int speed, float weight, Color bodyColor)
+ public EntityAntiAircraftGun(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
diff --git a/AntiAircraftGun/AntiAircraftGun/EntityUpdateAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/EntityUpdateAntiAircraftGun.cs
new file mode 100644
index 0000000..ff00aa8
--- /dev/null
+++ b/AntiAircraftGun/AntiAircraftGun/EntityUpdateAntiAircraftGun.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AntiAircraftGun
+{
+ internal class EntityUpdateAntiAircraftGun : EntityAntiAircraftGun
+ {
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color DopColor { get; private set; }
+ ///
+ /// Признак наличия башни с орудием
+ ///
+ public bool Gun { get; private set; }
+ ///
+ /// Признак наличия радара
+ ///
+ public bool Radar { get; private set; }
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес зенитного орудия
+ /// Цвет корпуса
+ /// Дополнительный цвет
+ /// Признак наличия башни с орудием
+ /// Признак наличия радара
+ public EntityUpdateAntiAircraftGun(int speed, float weight, Color bodyColor, Color dopColor, bool gun, bool radar) :
+ base(speed, weight, bodyColor)
+ {
+ DopColor = dopColor;
+ Gun = gun;
+ Radar = radar;
+ }
+ }
+}
diff --git a/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.Designer.cs b/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.Designer.cs
index c6429cf..57fd6b3 100644
--- a/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.Designer.cs
+++ b/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.Designer.cs
@@ -38,6 +38,7 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonCreareModif = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -46,13 +47,11 @@
//
this.pictureBoxAntiAircraftGun.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAntiAircraftGun.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxAntiAircraftGun.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBoxAntiAircraftGun.Name = "pictureBoxAntiAircraftGun";
- this.pictureBoxAntiAircraftGun.Size = new System.Drawing.Size(700, 316);
+ this.pictureBoxAntiAircraftGun.Size = new System.Drawing.Size(800, 425);
this.pictureBoxAntiAircraftGun.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxAntiAircraftGun.TabIndex = 0;
this.pictureBoxAntiAircraftGun.TabStop = false;
- this.pictureBoxAntiAircraftGun.Click += new System.EventHandler(this.pictureBoxAntiAircraftGun_Click);
this.pictureBoxAntiAircraftGun.Resize += new System.EventHandler(this.PictureBoxAntiAircraftGun_Resize);
//
// statusStrip
@@ -62,37 +61,35 @@
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor});
- this.statusStrip.Location = new System.Drawing.Point(0, 316);
+ this.statusStrip.Location = new System.Drawing.Point(0, 425);
this.statusStrip.Name = "statusStrip";
- this.statusStrip.Padding = new System.Windows.Forms.Padding(1, 0, 12, 0);
- this.statusStrip.Size = new System.Drawing.Size(700, 22);
+ this.statusStrip.Size = new System.Drawing.Size(800, 26);
this.statusStrip.TabIndex = 1;
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(59, 17);
+ this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(73, 20);
this.toolStripStatusLabelSpeed.Text = "Скорость";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(26, 17);
+ this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(33, 20);
this.toolStripStatusLabelWeight.Text = "Вес";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
- this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(33, 17);
+ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(42, 20);
this.toolStripStatusLabelBodyColor.Text = "Цвет";
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonCreate.Location = new System.Drawing.Point(10, 286);
- this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCreate.Location = new System.Drawing.Point(11, 381);
this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(82, 22);
+ this.buttonCreate.Size = new System.Drawing.Size(94, 29);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
@@ -103,10 +100,9 @@
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::AntiAircraftGun.Properties.Resources.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(634, 256);
- this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonUp.Location = new System.Drawing.Point(725, 341);
this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(26, 26);
+ this.buttonUp.Size = new System.Drawing.Size(30, 29);
this.buttonUp.TabIndex = 3;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
@@ -116,10 +112,9 @@
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::AntiAircraftGun.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(602, 284);
- this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonLeft.Location = new System.Drawing.Point(688, 379);
this.buttonLeft.Name = "buttonLeft";
- this.buttonLeft.Size = new System.Drawing.Size(26, 26);
+ this.buttonLeft.Size = new System.Drawing.Size(30, 29);
this.buttonLeft.TabIndex = 4;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
@@ -129,10 +124,9 @@
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::AntiAircraftGun.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(665, 284);
- this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonRight.Location = new System.Drawing.Point(760, 379);
this.buttonRight.Name = "buttonRight";
- this.buttonRight.Size = new System.Drawing.Size(26, 26);
+ this.buttonRight.Size = new System.Drawing.Size(30, 29);
this.buttonRight.TabIndex = 5;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
@@ -142,19 +136,30 @@
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::AntiAircraftGun.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(634, 284);
- this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonDown.Location = new System.Drawing.Point(725, 379);
this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(26, 26);
+ this.buttonDown.Size = new System.Drawing.Size(30, 29);
this.buttonDown.TabIndex = 6;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
+ // buttonCreareModif
+ //
+ this.buttonCreareModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreareModif.Location = new System.Drawing.Point(111, 381);
+ this.buttonCreareModif.Name = "buttonCreareModif";
+ this.buttonCreareModif.Size = new System.Drawing.Size(125, 29);
+ this.buttonCreareModif.TabIndex = 7;
+ this.buttonCreareModif.Text = "Модификация";
+ this.buttonCreareModif.UseVisualStyleBackColor = true;
+ this.buttonCreareModif.Click += new System.EventHandler(this.ButtonCreareModif_Click);
+ //
// FormAntiAircraftGun
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(700, 338);
+ this.ClientSize = new System.Drawing.Size(800, 451);
+ this.Controls.Add(this.buttonCreareModif);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
@@ -162,10 +167,9 @@
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxAntiAircraftGun);
this.Controls.Add(this.statusStrip);
- this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.MinimumSize = new System.Drawing.Size(46, 70);
+ this.MinimumSize = new System.Drawing.Size(50, 80);
this.Name = "FormAntiAircraftGun";
- this.Text = "Бронированная машина";
+ this.Text = "Зенитное орудие";
this.Click += new System.EventHandler(this.ButtonMove_Click);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).EndInit();
this.statusStrip.ResumeLayout(false);
@@ -187,5 +191,6 @@
private Button buttonLeft;
private Button buttonRight;
private Button buttonDown;
+ private Button buttonCreareModif;
}
}
\ No newline at end of file
diff --git a/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.cs
index 2353718..bb62ffc 100644
--- a/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.cs
+++ b/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.cs
@@ -23,6 +23,17 @@ namespace AntiAircraftGun
pictureBoxAntiAircraftGun.Image = bmp;
}
}
+ ///
+ ///
+ ///
+ private void SetData()
+ {
+ Random rnd = new();
+ _antiAircrafGun.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
+ toolStripStatusLabelSpeed.Text = $": {_antiAircrafGun.AntiAircraftGun.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_antiAircrafGun.AntiAircraftGun.Weight}";
+ toolStripStatusLabelBodyColor.Text = $": {_antiAircrafGun.AntiAircraftGun.BodyColor.Name}";
+ }
///
/// ""
@@ -31,16 +42,11 @@ namespace AntiAircraftGun
///
private void ButtonCreate_Click(object sender, EventArgs e)
{
- Random rnd = new();
- _antiAircrafGun = new DrawingAntiAircraftGun();
- _antiAircrafGun.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- _antiAircrafGun.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
- pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
- toolStripStatusLabelSpeed.Text = $": {_antiAircrafGun.AntiAircraftGun.Speed}";
- toolStripStatusLabelWeight.Text = $": {_antiAircrafGun.AntiAircraftGun.Weight}";
- toolStripStatusLabelBodyColor.Text = $": {_antiAircrafGun.AntiAircraftGun.BodyColor.Name}";
- Draw();
+ Random rnd = new();
+ _antiAircrafGun = new DrawingAntiAircraftGun(rnd.Next(100, 300), rnd.Next(1000, 2000),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ SetData();
+ Draw();
}
///
///
@@ -78,10 +84,20 @@ namespace AntiAircraftGun
_antiAircrafGun?.ChangeBorders(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
Draw();
}
-
- private void pictureBoxAntiAircraftGun_Click(object sender, EventArgs e)
+ ///
+ /// ""
+ ///
+ ///
+ ///
+ private void ButtonCreareModif_Click(object sender, EventArgs e)
{
-
+ Random rnd = new();
+ _antiAircrafGun = new DrawingUpdateAntiAircraftGun(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/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.resx b/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.resx
index 2c0949d..bbf576a 100644
--- a/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.resx
+++ b/AntiAircraftGun/AntiAircraftGun/FormAntiAircraftGun.resx
@@ -60,4 +60,7 @@
17, 17
+
+ 79
+
\ No newline at end of file