Turner I.A. LabWork02 #2
@ -14,15 +14,15 @@ namespace AntiAircraftGun
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityAntiAircraftGun AntiAircraftGun { private set; get; }
|
||||
public EntityAntiAircraftGun AntiAircraftGun { protected set; get; }
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки зенитного орудия
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
protected float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки зенитного орудия
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
protected float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
@ -50,6 +50,20 @@ namespace AntiAircraftGun
|
||||
AntiAircraftGun = new EntityAntiAircraftGun(speed, weight, bodyColor);
|
||||
}
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес зенитного орудия</param>
|
||||
/// <param name="bodyColor">Цвет корпуса</param>
|
||||
/// <param name="carWidth">Ширина отрисовки зенитного орудия</param>
|
||||
/// <param name="carHeight">Высота отрисовки зенитного орудия</param>
|
||||
protected DrawingAntiAircraftGun(int speed, float weight, Color bodyColor, int antiAircrafGunWidth, int antiAircrafGunHeight) :
|
||||
this(speed, weight, bodyColor)
|
||||
{
|
||||
_antiAircrafGunWidth = antiAircrafGunWidth;
|
||||
_antiAircrafGunHeight = antiAircrafGunHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции зенитного орудия
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
@ -112,7 +126,7 @@ namespace AntiAircraftGun
|
||||
/// Отрисовка зенитного орудия
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
|
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AntiAircraftGun
|
||||
{
|
||||
internal class DrawingUpdateAntiAircraftGun : DrawingAntiAircraftGun
|
||||
{
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес зенитного орудия</param>
|
||||
/// <param name="bodyColor">Цвет корпуса</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="gun">Признак наличия башни с орудием</param>
|
||||
/// <param name="radar">Признак наличия радара</param>
|
||||
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);
|
||||
_startPosY += 35;
|
||||
base.DrawTransport(g);
|
||||
_startPosY -= 35;
|
||||
if (updateAntiAircraftGun.Gun)
|
||||
{
|
||||
g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 20, 25, 15);
|
||||
g.FillRectangle(dopBrush, _startPosX + 60, _startPosY + 25, 50, 5);
|
||||
g.FillRectangle(dopBrush, _startPosX + 60, _startPosY + 30, 20, 5);
|
||||
}
|
||||
if (updateAntiAircraftGun.Radar)
|
||||
{
|
||||
g.DrawLine(dopPen, _startPosX + 27, _startPosY + 35, _startPosX + 27, _startPosY + 20);
|
||||
g.FillPie(dopBrush, _startPosX + 3, _startPosY, 30, 30, -45, 180);
|
||||
g.DrawLine(dopPen, _startPosX + 20, _startPosY + 15, _startPosX + 15, _startPosY + 10);
|
||||
g.FillEllipse(dopBrush, _startPosX + 10, _startPosY + 5, 10, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color DopColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия башни с орудием
|
||||
/// </summary>
|
||||
public bool Gun { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия радара
|
||||
/// </summary>
|
||||
public bool Radar { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес зенитного орудия</param>
|
||||
/// <param name="bodyColor">Цвет корпуса</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="gun">Признак наличия башни с орудием</param>
|
||||
/// <param name="radar">Признак наличия радара</param>
|
||||
public EntityUpdateAntiAircraftGun(int speed, float weight, Color bodyColor, Color dopColor, bool gun, bool radar) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
DopColor = dopColor;
|
||||
Gun = gun;
|
||||
Radar = radar;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
@ -142,11 +143,23 @@
|
||||
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(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
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);
|
||||
@ -178,5 +191,6 @@
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonCreareModif;
|
||||
}
|
||||
}
|
@ -23,6 +23,17 @@ namespace AntiAircraftGun
|
||||
pictureBoxAntiAircraftGun.Image = bmp;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Ìåòîä óñòàíîâêè äàííûõ
|
||||
/// </summary>
|
||||
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}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü"
|
||||
@ -31,15 +42,11 @@ namespace AntiAircraftGun
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
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)));
|
||||
_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();
|
||||
}
|
||||
/// <summary>
|
||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
||||
@ -77,5 +84,20 @@ namespace AntiAircraftGun
|
||||
_antiAircrafGun?.ChangeBorders(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ìîäèôèêàöèÿ"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -60,4 +60,7 @@
|
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>79</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user