Лабораторная 5

This commit is contained in:
evasina2312@gmail.com 2022-11-24 12:19:32 +04:00
parent 5de55d7ef9
commit 474573214e
4 changed files with 32 additions and 6 deletions

View File

@ -180,6 +180,15 @@ namespace ProjectMachine
public virtual void SetBaseColor(Color color)
{
if (Machine is EntityTank)
{
Machine = (EntityTank)Machine;
if (Machine is not null)
{
Machine = new EntityTank(Machine.Speed, Machine.Weight, color, (Machine as EntityTank).DopColor, (Machine as EntityTank).Turret, (Machine as EntityTank).Gun);
return;
}
}
Machine = new EntityMachine(Machine.Speed, Machine.Weight, color);
}
}

View File

@ -51,9 +51,13 @@ namespace ProjectMachine
_startPosY -= 5;
}
public void SetDopColor(Color color)
{
Machine = Machine as EntityTank;
if (Machine is not null)
{
Machine = new EntityTank(Machine.Speed, Machine.Weight, Machine.BodyColor,
color, (Machine as EntityTank).Turret, (Machine as EntityTank).Gun);
}
}
}
}

View File

@ -127,6 +127,7 @@
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(46, 53);
this.panelPurple.TabIndex = 3;
this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelYellow
//
@ -136,6 +137,7 @@
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(46, 53);
this.panelYellow.TabIndex = 1;
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelBlack
//
@ -145,6 +147,7 @@
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(46, 53);
this.panelBlack.TabIndex = 4;
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelBlue
//
@ -154,6 +157,7 @@
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(46, 53);
this.panelBlue.TabIndex = 1;
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelGray
//
@ -163,6 +167,7 @@
this.panelGray.Name = "panelGray";
this.panelGray.Size = new System.Drawing.Size(46, 53);
this.panelGray.TabIndex = 5;
this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelGreen
//
@ -172,6 +177,7 @@
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(46, 53);
this.panelGreen.TabIndex = 1;
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelWhite
//
@ -181,6 +187,7 @@
this.panelWhite.Name = "panelWhite";
this.panelWhite.Size = new System.Drawing.Size(46, 53);
this.panelWhite.TabIndex = 2;
this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelRed
//
@ -190,6 +197,7 @@
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(46, 53);
this.panelRed.TabIndex = 0;
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// checkBoxGun
//
@ -279,6 +287,8 @@
this.labelDopColor.TabIndex = 2;
this.labelDopColor.Text = "Доп. цвет";
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
//
// labelBaseColor
//
@ -290,6 +300,8 @@
this.labelBaseColor.TabIndex = 1;
this.labelBaseColor.Text = "Цвет";
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
//
// pictureBoxObject
//

View File

@ -19,7 +19,7 @@ namespace ProjectMachine
/// <summary>
/// Событие
/// </summary>
private event Action<DrawningMachine> EventAddTank;
private event TankDelegate EventAddTank;
/// <summary>
/// Конструктор
/// </summary>
@ -51,11 +51,11 @@ namespace ProjectMachine
/// Добавление события
/// </summary>
/// <param name="ev"></param>
public void AddEvent(Action<DrawningMachine> ev)
public void AddEvent(TankDelegate ev)
{
if (EventAddTank == null)
{
EventAddTank = new (ev);
EventAddTank = new TankDelegate(ev);
}
else
{
@ -120,7 +120,7 @@ namespace ProjectMachine
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelBaseColor_DragEnter(object sender, DragEventArgs e)
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
@ -131,6 +131,7 @@ namespace ProjectMachine
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Принимаем основной цвет
/// </summary>