Сделаны ТODO

This commit is contained in:
evasina2312@gmail.com 2022-11-24 01:54:30 +04:00
parent 25b16cfdf9
commit 5de55d7ef9
6 changed files with 30 additions and 24 deletions

View File

@ -179,7 +179,7 @@ namespace ProjectMachine
}
public virtual void SetBaseColor(Color color)
{
{
Machine = new EntityMachine(Machine.Speed, Machine.Weight, color);
}
}

View File

@ -107,7 +107,7 @@ namespace ProjectMachine
dopColor = dialogDop.Color;
}
_machine = new DrawningTank(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData();
Draw();
}

View File

@ -77,7 +77,7 @@ namespace ProjectMachine
private void ButtonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
var machine = new DrawningTank(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)));
var machine = new DrawningTank(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(machine);
}
/// <summary>

View File

@ -115,9 +115,25 @@ namespace ProjectMachine
private void ButtonAddTank_Click(object sender, EventArgs e)
{
var formTankConfig = new FormTankConfig();
// TODO Call method AddEvent from formCarConfig
formTankConfig.AddEvent(new(AddTank));
formTankConfig.Show();
}
private void AddTank(DrawningMachine tank)
{
if (listBoxMaps.SelectedIndex == -1)
{
MessageBox.Show("Перед добавлением объекта необходимо создать карту");
}
else if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObject(tank) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
/// <summary>
/// Удаление объекта
/// </summary>

View File

@ -29,7 +29,6 @@
private void InitializeComponent()
{
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
this.checkBoxBodyKit = new System.Windows.Forms.CheckBox();
this.labelModifiedObject = new System.Windows.Forms.Label();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox();
@ -63,7 +62,6 @@
//
// groupBoxConfig
//
this.groupBoxConfig.Controls.Add(this.checkBoxBodyKit);
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
@ -80,17 +78,6 @@
this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры";
//
// checkBoxBodyKit
//
this.checkBoxBodyKit.AutoSize = true;
this.checkBoxBodyKit.Location = new System.Drawing.Point(6, 136);
this.checkBoxBodyKit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
this.checkBoxBodyKit.Size = new System.Drawing.Size(207, 24);
this.checkBoxBodyKit.TabIndex = 18;
this.checkBoxBodyKit.Text = "Признак наличия обвеса";
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
//
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@ -207,7 +194,7 @@
// checkBoxGun
//
this.checkBoxGun.AutoSize = true;
this.checkBoxGun.Location = new System.Drawing.Point(6, 223);
this.checkBoxGun.Location = new System.Drawing.Point(10, 172);
this.checkBoxGun.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.checkBoxGun.Name = "checkBoxGun";
this.checkBoxGun.Size = new System.Drawing.Size(299, 24);
@ -218,7 +205,7 @@
// checkBoxTurret
//
this.checkBoxTurret.AutoSize = true;
this.checkBoxTurret.Location = new System.Drawing.Point(6, 181);
this.checkBoxTurret.Location = new System.Drawing.Point(10, 124);
this.checkBoxTurret.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.checkBoxTurret.Name = "checkBoxTurret";
this.checkBoxTurret.Size = new System.Drawing.Size(281, 24);
@ -382,6 +369,5 @@
private PictureBox pictureBoxObject;
private Button buttonOk;
private Button buttonCancel;
private CheckBox checkBoxBodyKit;
}
}

View File

@ -19,7 +19,7 @@ namespace ProjectMachine
/// <summary>
/// Событие
/// </summary>
private event TankDelegate EventAddTank;
private event Action<DrawningMachine> EventAddTank;
/// <summary>
/// Конструктор
/// </summary>
@ -51,11 +51,11 @@ namespace ProjectMachine
/// Добавление события
/// </summary>
/// <param name="ev"></param>
public void AddEvent(TankDelegate ev)
public void AddEvent(Action<DrawningMachine> ev)
{
if (EventAddTank == null)
{
EventAddTank = new TankDelegate(ev);
EventAddTank = new (ev);
}
else
{
@ -138,7 +138,11 @@ namespace ProjectMachine
/// <param name="e"></param>
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
{
if (_tank != null)
{
_tank.SetBaseColor((Color)e.Data.GetData(typeof(Color)));
DrawTank();
}
}
/// <summary>
/// Принимаем дополнительный цвет