Петрушин Егор ПИбд-22 Лабораторная работа №5 "Самоходная артиллерийская установка" #10

Closed
Egor_Petrushin wants to merge 6 commits from PIbd-22_Petrushin_E.A._Lab5 into PIbd-22_Petrushin_E.A._Lab4
6 changed files with 38 additions and 14 deletions
Showing only changes of commit 57d002abc8 - Show all commits

View File

@ -11,11 +11,11 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
{
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="bodyKit">Признак наличия залповой установки</param>
public DrawningSPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, int width, int height) : base(speed, weight, bodyColor, width, height)
public DrawningSPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool ballon, int width, int height) : base(speed, weight, bodyColor, width, height)
{
if (EntitySPAU != null)
{
EntitySPAU = new EntitySPAUchild(speed, weight, bodyColor, additionalColor, bodyKit);
EntitySPAU = new EntitySPAUchild(speed, weight, bodyColor, additionalColor, bodyKit, ballon);
}
}
public override void DrawTransport(Graphics g)
@ -33,6 +33,11 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
g.FillRectangle(additionalBrush, _startPosX + 15, _startPosY + 20, 20, 40);
g.DrawLine(penBlack, _startPosX + 5, _startPosY + 20, _startPosX + 15, _startPosY + 25);
}
if (entitySPAUchild.Ballon)
{
//баллон
g.FillRectangle(additionalBrush, _startPosX + 110, _startPosY + 35, 30, 20);
}
base.DrawTransport(g);
}

View File

@ -16,12 +16,18 @@ namespace SelfPropelledArtilleryUnit.Entities
/// Признак (опция) наличия залповой установки
/// </summary>
public bool BodyKit { get; private set; }
/// <summary>
/// Признак (опция) наличия баллона
/// </summary>
public bool Ballon { get; private set; }
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="bodyKit">Признак наличия залповой установки</param>
public EntitySPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit) : base(speed, weight, bodyColor)
public EntitySPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool ballon) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
BodyKit = bodyKit;
Ballon = ballon;
}
public void setAdditionalColor(Color color)
{

View File

@ -67,7 +67,7 @@ namespace SelfPropelledArtilleryUnit
}
_drawningSPAU = new DrawningSPAUchild(random.Next(100, 300),
random.Next(1000, 3000), color,
dopColor, true,
dopColor, true, true,
pictureBoxSPAU.Width, pictureBoxSPAU.Height);
_drawningSPAU.SetPosition(random.Next(10, 100), random.Next(10,
100));

View File

@ -29,6 +29,7 @@
private void InitializeComponent()
{
groupBox_param = new GroupBox();
сheckBox_ballon = new CheckBox();
checkBox_zalp = new CheckBox();
label_weight = new Label();
groupBox_colors = new GroupBox();
@ -65,6 +66,7 @@
//
// groupBox_param
//
groupBox_param.Controls.Add(сheckBox_ballon);
groupBox_param.Controls.Add(checkBox_zalp);
groupBox_param.Controls.Add(label_weight);
groupBox_param.Controls.Add(groupBox_colors);
@ -78,10 +80,20 @@
groupBox_param.TabStop = false;
groupBox_param.Text = "Параметры";
//
// сheckBox_ballon
//
сheckBox_ballon.AutoSize = true;
сheckBox_ballon.Location = new Point(6, 162);
сheckBox_ballon.Name = "сheckBox_ballon";
сheckBox_ballon.Size = new Size(82, 24);
сheckBox_ballon.TabIndex = 7;
сheckBox_ballon.Text = "Баллон";
сheckBox_ballon.UseVisualStyleBackColor = true;
//
// checkBox_zalp
//
checkBox_zalp.AutoSize = true;
checkBox_zalp.Location = new Point(6, 154);
checkBox_zalp.Location = new Point(6, 132);
checkBox_zalp.Name = "checkBox_zalp";
checkBox_zalp.Size = new Size(170, 24);
checkBox_zalp.TabIndex = 5;
@ -91,7 +103,7 @@
// label_weight
//
label_weight.AutoSize = true;
label_weight.Location = new Point(6, 86);
label_weight.Location = new Point(111, 76);
label_weight.Name = "label_weight";
label_weight.Size = new Size(33, 20);
label_weight.TabIndex = 3;
@ -180,7 +192,7 @@
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(6, 109);
numericUpDownWeight.Location = new Point(120, 99);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
@ -190,7 +202,7 @@
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(6, 56);
numericUpDownSpeed.Location = new Point(120, 46);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
@ -201,7 +213,7 @@
// label_speed
//
label_speed.AutoSize = true;
label_speed.Location = new Point(6, 33);
label_speed.Location = new Point(109, 23);
label_speed.Name = "label_speed";
label_speed.Size = new Size(73, 20);
label_speed.TabIndex = 0;
@ -360,5 +372,6 @@
private Panel panel_color;
private Panel panel_addit_color;
private Label label1;
private CheckBox сheckBox_ballon;
}
}

View File

@ -23,7 +23,7 @@ namespace SelfPropelledArtilleryUnit
/// <summary>
/// Событие
/// </summary>
private event SPAUDelegate? EventAddSPAU;
public event Action<DrawningSPAU>? EventAddSPAU;
/// <summary>
/// Конструктор
/// </summary>
@ -61,7 +61,7 @@ namespace SelfPropelledArtilleryUnit
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(SPAUDelegate ev)
public void AddEvent(Action<DrawningSPAU> ev)
{
if (EventAddSPAU == null)
{
@ -113,7 +113,7 @@ namespace SelfPropelledArtilleryUnit
_sPAU = new DrawningSPAU((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBox.Width, pictureBox.Height);
break;
case "labelModifiedObject":
_sPAU = new DrawningSPAUchild((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBox_zalp.Checked, pictureBox.Width, pictureBox.Height);
_sPAU = new DrawningSPAUchild((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBox_zalp.Checked, сheckBox_ballon.Checked, pictureBox.Width, pictureBox.Height);
break;
}
DrawSPAU();
@ -147,7 +147,7 @@ namespace SelfPropelledArtilleryUnit
case "panel_addit_color":
if (!(_sPAU is DrawningSPAUchild))
return;
(_sPAU.EntitySPAU as EntitySPAUchild)?.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
(_sPAU.EntitySPAU as EntitySPAUchild)?.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
break;
}
DrawSPAU();

View File

@ -11,5 +11,5 @@ namespace SelfPropelledArtilleryUnit.SPAUs
/// Делегат для передачи объекта-автомобиля
/// </summary>
/// <param name="car"></param>
public delegate void SPAUDelegate(DrawningSPAU sPAU);
//public delegate void SPAUDelegate(DrawningSPAU sPAU);
}