DozorovaA.A_SecondLabWork #2
@ -11,15 +11,15 @@ namespace ArmoredVehicle
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public ArmoredVehicleEntity ArmoredVehicle { get; private set; }
|
||||
public ArmoredVehicleEntity ArmoredVehicle { get; protected set; }
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
protected float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
protected float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
@ -31,11 +31,11 @@ namespace ArmoredVehicle
|
||||
/// <summary>
|
||||
/// Ширина отрисовки
|
||||
/// </summary>
|
||||
private readonly int _ArmoredVehicleWidth = 210;
|
||||
private readonly int _ArmoredVehicleWidth = 500;
|
||||
/// <summary>
|
||||
/// Высота отрисовки
|
||||
/// </summary>
|
||||
private readonly int _ArmoredVehicleHeight = 50;
|
||||
private readonly int _ArmoredVehicleHeight = 100;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
@ -46,6 +46,13 @@ namespace ArmoredVehicle
|
||||
{
|
||||
ArmoredVehicle = new ArmoredVehicleEntity(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawingArmoredVehicle(int speed, float weight, Color bodyColor, int ArmoredVehicleWidth, int ArmoredVehicleHeight):
|
||||
this(speed, weight, bodyColor)
|
||||
{
|
||||
_ArmoredVehicleHeight = ArmoredVehicleHeight;
|
||||
_ArmoredVehicleWidth = ArmoredVehicleWidth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
@ -128,7 +135,7 @@ namespace ArmoredVehicle
|
||||
/// Отрисовка
|
||||
/// </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)
|
||||
|
45
ArmoredVehicle/DrawingTank.cs
Normal file
45
ArmoredVehicle/DrawingTank.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
internal class DrawingTank : DrawingArmoredVehicle
|
||||
{
|
||||
public DrawingTank(int speed, float weight, Color bodyColor, Color dopColor, bool machineGun, bool tower, bool gun)
|
||||
: base(speed, weight, bodyColor)
|
||||
{
|
||||
ArmoredVehicle = new TankEnity(speed, weight, bodyColor, dopColor, machineGun, tower, gun);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (ArmoredVehicle is not TankEnity machine)
|
||||
{
|
||||
return;
|
||||
}
|
||||
base.DrawTransport(g);
|
||||
|
||||
Brush br = new SolidBrush(machine?.DopColor ?? Color.Black);
|
||||
Pen p = new Pen(machine?.DopColor ?? Color.Black, 5);
|
||||
|
||||
if (machine.Tower)
|
||||
{
|
||||
|
||||
g.FillRectangle(br, _startPosX + 60, _startPosY - 30, 80, 30);
|
||||
g.DrawLine(p, _startPosX + 90, _startPosY - 20, _startPosX + 250, _startPosY - 20);
|
||||
if (machine.MachineGun)
|
||||
{
|
||||
p = new Pen(machine?.DopColor ?? Color.Black, 3);
|
||||
|
||||
g.DrawLine(p, _startPosX + 90, _startPosY - 45, _startPosX + 90, _startPosY - 30);
|
||||
g.DrawLine(p, _startPosX + 85, _startPosY - 35, _startPosX + 120, _startPosY - 35);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
13
ArmoredVehicle/MainForm.Designer.cs
generated
13
ArmoredVehicle/MainForm.Designer.cs
generated
@ -39,6 +39,7 @@
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.TankButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -144,11 +145,22 @@
|
||||
this.statusStrip.TabIndex = 8;
|
||||
this.statusStrip.Text = "statusStrip1";
|
||||
//
|
||||
// TankButton
|
||||
//
|
||||
this.TankButton.Location = new System.Drawing.Point(139, 365);
|
||||
this.TankButton.Name = "TankButton";
|
||||
this.TankButton.Size = new System.Drawing.Size(143, 34);
|
||||
this.TankButton.TabIndex = 14;
|
||||
this.TankButton.Text = "Модификация";
|
||||
this.TankButton.UseVisualStyleBackColor = true;
|
||||
this.TankButton.Click += new System.EventHandler(this.TankButton_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
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.TankButton);
|
||||
this.Controls.Add(this.ButtonDown);
|
||||
this.Controls.Add(this.ButtonRight);
|
||||
this.Controls.Add(this.ButtonLeft);
|
||||
@ -179,5 +191,6 @@
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelColor;
|
||||
private StatusStrip statusStrip;
|
||||
private Button TankButton;
|
||||
}
|
||||
}
|
@ -36,11 +36,17 @@ namespace ArmoredVehicle
|
||||
Random rnd = new();
|
||||
_ArmoredVehicle = new DrawingArmoredVehicle(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void SetData()
|
||||
{
|
||||
Random rnd = new();
|
||||
_ArmoredVehicle.SetPosition(/*rnd.Next(0, 100)*/ -10, rnd.Next(0, 100), DrawingPictureBox.Width, DrawingPictureBox.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_ArmoredVehicle.ArmoredVehicle.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_ArmoredVehicle.ArmoredVehicle.Weight}";
|
||||
toolStripStatusLabelColor.Text = $"Öâåò: {_ArmoredVehicle.ArmoredVehicle.BodyColor.Name}";
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
||||
@ -79,5 +85,19 @@ namespace ArmoredVehicle
|
||||
_ArmoredVehicle?.ChangeBorders(DrawingPictureBox.Width, DrawingPictureBox.Height);
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void TankButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_ArmoredVehicle = new DrawingTank(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)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@
|
||||
<data name="ButtonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vwAADr8BOAVTJAAAy5RJREFUeF7s/emTZGd54O/3L9eqbkkI1GKxkUHsCA8gsXhACBNsxoBsY2BYhIkY
|
||||
vgAADr4B6kKxwAAAy5RJREFUeF7s/emTZGd54O/3L9eqbkkI1GKxkUHsCA8gsXhACBNsxoBsY2BYhIkY
|
||||
ApgAIeMxYRADg74QNjJbBMYwrIPD0oBZBHjAbGYkbGMW4wn+GI/VXZVL+XdX3tmHstDSLVU/dVfmdb04
|
||||
8WTptfq583Oec/LIvwFAbV/+8pf/fwDU0+v1cnHkyJG4vu1tb1v+ww0A+03AAqA6AQugJgELgGYELACq
|
||||
E7AAahKwAGhGwAKgOgELoCYBC4BmBCwAqhOwAGoSsABoRsACoDoBC6AmAQuAZgQsAKoTsABqErAAaEbA
|
||||
@ -936,7 +936,7 @@
|
||||
<data name="ButtonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vwAADr8BOAVTJAAAtnhJREFUeF7s3fmbZXdVL/7NHs6p6m4ydRIvQwgJiQgSCJDwRUaVYICAPqjhEmVw
|
||||
vgAADr4B6kKxwAAAtnhJREFUeF7s3fmbZXdVL/7NHs6p6m4ydRIvQwgJiQgSCJDwRUaVYICAPqjhEmVw
|
||||
iAo3xAjKKBBl8MEQUO5FgSBwITIJ6FUMgyZBCSjivX9O0nXG+q7aq2p7aELS6VTX2afq9frh86z92QdI
|
||||
uqvO4367PmsXmwAAAADQYwIsAAAAAHpNgAUAAABArwmwAAAAAOg1ARYAAAAAvSbAAgAAAKDXBFgAAAAA
|
||||
9JoACwAAAIBeE2ABAAAA0GsCLAAAAAB6TYAFAAAAQK8JsAAAAADoNQEWAAAAAL0mwAIAAACg1wRYAAAA
|
||||
@ -1721,7 +1721,7 @@
|
||||
<data name="ButtonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vwAADr8BOAVTJAAAt0tJREFUeF7s3fmXbHdZL/7qGvucEwicDBgkEIYwKCEB4mJIIiKwkEEGXQHBCA5c
|
||||
vgAADr4B6kKxwAAAt0tJREFUeF7s3fmXbHdZL/7qGvucEwicDBgkEIYwKCEB4mJIIiKwkEEGXQHBCA5c
|
||||
hst0EQ34lcGrQBACsq5BJhUvYYoQVCZRQlBALsa77h9z17rprtq7Nt+n9lO9LUJCzsnp7r2r6/X64bOe
|
||||
/al2mdNdVWvtN8/n2b0fAgAAAECHCbAAAAAA6DQBFgAAAACdJsACAAAAoNMEWAAAAAB0mgALAAAAgE4T
|
||||
YAEAAADQaQIsAAAAADpNgAUAAABApwmwAAAAAOg0ARYAAAAAnSbAAgAAAKDTBFgAAAAAdJoACwAAAIBO
|
||||
@ -2509,7 +2509,7 @@
|
||||
<data name="ButtonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vwAADr8BOAVTJAAAy01JREFUeF7s3fm/ZFV5L/7TVbWr6nTTjM0QBUQhikMEgsQBiYYEoqJGo8YxJlGD
|
||||
vgAADr4B6kKxwAAAy01JREFUeF7s3fm/ZFV5L/7TVbWr6nTTjM0QBUQhikMEgsQBiYYEoqJGo8YxJlGD
|
||||
XxViNIng1WBiDEQxwRgvDhiNosYB472KQyBgohLuNa/c1/1fbuxTs9/n7Kd6WSLQ0+lzani/f1ivtTcK
|
||||
3edU7f2sz15r7bUfAwAAAMAcE2ABAAAAMNcEWAAAAADMNQEWAAAAAHNNgAUAAADAXBNgAQAAADDXBFgA
|
||||
AAAAzDUBFgAAAABzTYAFAAAAwFwTYAEAAAAw1wRYAAAAAMw1ARYAAAAAc02ABQAAAMBcE2ABAAAAMNcE
|
||||
|
53
ArmoredVehicle/TankEnity.cs
Normal file
53
ArmoredVehicle/TankEnity.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
internal class TankEnity : ArmoredVehicleEntity
|
||||
{
|
||||
|
||||
public TankEnity(int speed, float weight, Color bodyColor, Color dopColor, bool machineGun, bool tower, bool gun) : base(speed, weight, bodyColor)
|
||||
{
|
||||
DopColor = dopColor;
|
||||
MachineGun = machineGun;
|
||||
Tower = tower;
|
||||
Gun = gun;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color DopColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия пулемета
|
||||
/// </summary>
|
||||
public bool MachineGun { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия башни
|
||||
/// </summary>
|
||||
public bool Tower { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия орудия
|
||||
/// </summary>
|
||||
public bool Gun { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия полосы
|
||||
/// </summary>
|
||||
public bool Line { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="MachineGun">Признак наличия пулемета</param>
|
||||
/// <param name="Tower">Признак наличия башни</param>
|
||||
/// <param name="Gun">Признак наличия орудия</param>
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user