Лабораторная работа №5
This commit is contained in:
parent
2c39c97efa
commit
d5fc3fd5ec
@ -48,6 +48,12 @@ public class EntityAirFighter : EntityWarPlane
|
|||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
/// <param name="rocket">Признак наличия рокет</param>
|
/// <param name="rocket">Признак наличия рокет</param>
|
||||||
/// <param name="additionalWing">Признак наличия дополнительных крыльев</param>
|
/// <param name="additionalWing">Признак наличия дополнительных крыльев</param>
|
||||||
|
|
||||||
|
public void SetAdditionalColor(Color addirionalColor)
|
||||||
|
{
|
||||||
|
AdditionalColor = addirionalColor;
|
||||||
|
}
|
||||||
|
|
||||||
public EntityAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing) :base(speed, weight, bodyColor)
|
public EntityAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing) :base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -25,6 +25,11 @@ public class EntityWarPlane
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double Step => Speed * 100 / Weight;
|
public double Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
|
public void SetBodyColor(Color bodyColor)
|
||||||
|
{
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор сущности
|
/// Конструктор сущности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
buttonRemove = new Button();
|
buttonRemove = new Button();
|
||||||
buttonAddWarPlane = new Button();
|
buttonAddWarPlane = new Button();
|
||||||
button1 = new Button();
|
button1 = new Button();
|
||||||
buttonAddAirFighter = new Button();
|
|
||||||
maskedTextBoxPosition = new MaskedTextBox();
|
maskedTextBoxPosition = new MaskedTextBox();
|
||||||
buttonGoToCheck = new Button();
|
buttonGoToCheck = new Button();
|
||||||
buttonCreateCompany = new Button();
|
buttonCreateCompany = new Button();
|
||||||
@ -60,11 +59,9 @@
|
|||||||
groupBox1.Controls.Add(panelStorage);
|
groupBox1.Controls.Add(panelStorage);
|
||||||
groupBox1.Controls.Add(comboBoxSelectorCompany);
|
groupBox1.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBox1.Dock = DockStyle.Right;
|
groupBox1.Dock = DockStyle.Right;
|
||||||
groupBox1.Location = new Point(753, 0);
|
groupBox1.Location = new Point(659, 0);
|
||||||
groupBox1.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
groupBox1.Name = "groupBox1";
|
groupBox1.Name = "groupBox1";
|
||||||
groupBox1.Padding = new Padding(3, 4, 3, 4);
|
groupBox1.Size = new Size(174, 663);
|
||||||
groupBox1.Size = new Size(199, 884);
|
|
||||||
groupBox1.TabIndex = 0;
|
groupBox1.TabIndex = 0;
|
||||||
groupBox1.TabStop = false;
|
groupBox1.TabStop = false;
|
||||||
groupBox1.Text = "Инструменты";
|
groupBox1.Text = "Инструменты";
|
||||||
@ -74,22 +71,19 @@
|
|||||||
panelCompanyTools.Controls.Add(buttonRemove);
|
panelCompanyTools.Controls.Add(buttonRemove);
|
||||||
panelCompanyTools.Controls.Add(buttonAddWarPlane);
|
panelCompanyTools.Controls.Add(buttonAddWarPlane);
|
||||||
panelCompanyTools.Controls.Add(button1);
|
panelCompanyTools.Controls.Add(button1);
|
||||||
panelCompanyTools.Controls.Add(buttonAddAirFighter);
|
|
||||||
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
||||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
panelCompanyTools.Location = new Point(0, 497);
|
panelCompanyTools.Location = new Point(0, 373);
|
||||||
panelCompanyTools.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
panelCompanyTools.Size = new Size(199, 371);
|
panelCompanyTools.Size = new Size(174, 278);
|
||||||
panelCompanyTools.TabIndex = 9;
|
panelCompanyTools.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// buttonRemove
|
// buttonRemove
|
||||||
//
|
//
|
||||||
buttonRemove.Location = new Point(7, 193);
|
buttonRemove.Location = new Point(6, 145);
|
||||||
buttonRemove.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonRemove.Name = "buttonRemove";
|
buttonRemove.Name = "buttonRemove";
|
||||||
buttonRemove.Size = new Size(185, 59);
|
buttonRemove.Size = new Size(162, 44);
|
||||||
buttonRemove.TabIndex = 4;
|
buttonRemove.TabIndex = 4;
|
||||||
buttonRemove.Text = "Удалить самолет";
|
buttonRemove.Text = "Удалить самолет";
|
||||||
buttonRemove.UseVisualStyleBackColor = true;
|
buttonRemove.UseVisualStyleBackColor = true;
|
||||||
@ -97,10 +91,9 @@
|
|||||||
//
|
//
|
||||||
// buttonAddWarPlane
|
// buttonAddWarPlane
|
||||||
//
|
//
|
||||||
buttonAddWarPlane.Location = new Point(7, 4);
|
buttonAddWarPlane.Location = new Point(6, 27);
|
||||||
buttonAddWarPlane.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonAddWarPlane.Name = "buttonAddWarPlane";
|
buttonAddWarPlane.Name = "buttonAddWarPlane";
|
||||||
buttonAddWarPlane.Size = new Size(185, 69);
|
buttonAddWarPlane.Size = new Size(162, 52);
|
||||||
buttonAddWarPlane.TabIndex = 1;
|
buttonAddWarPlane.TabIndex = 1;
|
||||||
buttonAddWarPlane.Text = "Добавление военного самолета";
|
buttonAddWarPlane.Text = "Добавление военного самолета";
|
||||||
buttonAddWarPlane.UseVisualStyleBackColor = true;
|
buttonAddWarPlane.UseVisualStyleBackColor = true;
|
||||||
@ -108,42 +101,28 @@
|
|||||||
//
|
//
|
||||||
// button1
|
// button1
|
||||||
//
|
//
|
||||||
button1.Location = new Point(7, 327);
|
button1.Location = new Point(6, 245);
|
||||||
button1.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
button1.Name = "button1";
|
button1.Name = "button1";
|
||||||
button1.Size = new Size(185, 40);
|
button1.Size = new Size(162, 30);
|
||||||
button1.TabIndex = 6;
|
button1.TabIndex = 6;
|
||||||
button1.Text = "Обновить";
|
button1.Text = "Обновить";
|
||||||
button1.UseVisualStyleBackColor = true;
|
button1.UseVisualStyleBackColor = true;
|
||||||
button1.Click += ButtonRefresh_Click;
|
button1.Click += ButtonRefresh_Click;
|
||||||
//
|
//
|
||||||
// buttonAddAirFighter
|
|
||||||
//
|
|
||||||
buttonAddAirFighter.Location = new Point(7, 81);
|
|
||||||
buttonAddAirFighter.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonAddAirFighter.Name = "buttonAddAirFighter";
|
|
||||||
buttonAddAirFighter.Size = new Size(185, 59);
|
|
||||||
buttonAddAirFighter.TabIndex = 2;
|
|
||||||
buttonAddAirFighter.Text = "Добавление истребителя";
|
|
||||||
buttonAddAirFighter.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddAirFighter.Click += ButtonAddAirFighter_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
maskedTextBoxPosition.Location = new Point(9, 148);
|
maskedTextBoxPosition.Location = new Point(8, 111);
|
||||||
maskedTextBoxPosition.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
maskedTextBoxPosition.Mask = "00";
|
maskedTextBoxPosition.Mask = "00";
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
maskedTextBoxPosition.Size = new Size(185, 27);
|
maskedTextBoxPosition.Size = new Size(162, 23);
|
||||||
maskedTextBoxPosition.TabIndex = 3;
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
maskedTextBoxPosition.ValidatingType = typeof(int);
|
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
//
|
//
|
||||||
// buttonGoToCheck
|
// buttonGoToCheck
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Location = new Point(7, 260);
|
buttonGoToCheck.Location = new Point(6, 195);
|
||||||
buttonGoToCheck.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
buttonGoToCheck.Size = new Size(185, 59);
|
buttonGoToCheck.Size = new Size(162, 44);
|
||||||
buttonGoToCheck.TabIndex = 5;
|
buttonGoToCheck.TabIndex = 5;
|
||||||
buttonGoToCheck.Text = "Передать на тест";
|
buttonGoToCheck.Text = "Передать на тест";
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
@ -151,10 +130,9 @@
|
|||||||
//
|
//
|
||||||
// buttonCreateCompany
|
// buttonCreateCompany
|
||||||
//
|
//
|
||||||
buttonCreateCompany.Location = new Point(7, 459);
|
buttonCreateCompany.Location = new Point(6, 344);
|
||||||
buttonCreateCompany.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
buttonCreateCompany.Size = new Size(185, 31);
|
buttonCreateCompany.Size = new Size(162, 23);
|
||||||
buttonCreateCompany.TabIndex = 8;
|
buttonCreateCompany.TabIndex = 8;
|
||||||
buttonCreateCompany.Text = "Создать компанию";
|
buttonCreateCompany.Text = "Создать компанию";
|
||||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||||
@ -170,18 +148,16 @@
|
|||||||
panelStorage.Controls.Add(textBoxCollectionName);
|
panelStorage.Controls.Add(textBoxCollectionName);
|
||||||
panelStorage.Controls.Add(labelCollectionName);
|
panelStorage.Controls.Add(labelCollectionName);
|
||||||
panelStorage.Dock = DockStyle.Top;
|
panelStorage.Dock = DockStyle.Top;
|
||||||
panelStorage.Location = new Point(3, 24);
|
panelStorage.Location = new Point(3, 19);
|
||||||
panelStorage.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelStorage.Name = "panelStorage";
|
panelStorage.Name = "panelStorage";
|
||||||
panelStorage.Size = new Size(193, 361);
|
panelStorage.Size = new Size(168, 271);
|
||||||
panelStorage.TabIndex = 7;
|
panelStorage.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// buttonCollectionRemove
|
// buttonCollectionRemove
|
||||||
//
|
//
|
||||||
buttonCollectionRemove.Location = new Point(3, 280);
|
buttonCollectionRemove.Location = new Point(3, 210);
|
||||||
buttonCollectionRemove.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonCollectionRemove.Name = "buttonCollectionRemove";
|
buttonCollectionRemove.Name = "buttonCollectionRemove";
|
||||||
buttonCollectionRemove.Size = new Size(185, 31);
|
buttonCollectionRemove.Size = new Size(162, 23);
|
||||||
buttonCollectionRemove.TabIndex = 6;
|
buttonCollectionRemove.TabIndex = 6;
|
||||||
buttonCollectionRemove.Text = "Удалить коллекцию";
|
buttonCollectionRemove.Text = "Удалить коллекцию";
|
||||||
buttonCollectionRemove.UseVisualStyleBackColor = true;
|
buttonCollectionRemove.UseVisualStyleBackColor = true;
|
||||||
@ -190,18 +166,17 @@
|
|||||||
// listBoxCollection
|
// listBoxCollection
|
||||||
//
|
//
|
||||||
listBoxCollection.FormattingEnabled = true;
|
listBoxCollection.FormattingEnabled = true;
|
||||||
listBoxCollection.Location = new Point(3, 147);
|
listBoxCollection.ItemHeight = 15;
|
||||||
listBoxCollection.Margin = new Padding(3, 4, 3, 4);
|
listBoxCollection.Location = new Point(3, 110);
|
||||||
listBoxCollection.Name = "listBoxCollection";
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
listBoxCollection.Size = new Size(185, 124);
|
listBoxCollection.Size = new Size(162, 94);
|
||||||
listBoxCollection.TabIndex = 5;
|
listBoxCollection.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// buttonCollectionAdd
|
// buttonCollectionAdd
|
||||||
//
|
//
|
||||||
buttonCollectionAdd.Location = new Point(3, 108);
|
buttonCollectionAdd.Location = new Point(3, 81);
|
||||||
buttonCollectionAdd.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||||
buttonCollectionAdd.Size = new Size(185, 31);
|
buttonCollectionAdd.Size = new Size(162, 23);
|
||||||
buttonCollectionAdd.TabIndex = 4;
|
buttonCollectionAdd.TabIndex = 4;
|
||||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||||
@ -210,10 +185,9 @@
|
|||||||
// radioButtonList
|
// radioButtonList
|
||||||
//
|
//
|
||||||
radioButtonList.AutoSize = true;
|
radioButtonList.AutoSize = true;
|
||||||
radioButtonList.Location = new Point(105, 75);
|
radioButtonList.Location = new Point(92, 56);
|
||||||
radioButtonList.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
radioButtonList.Name = "radioButtonList";
|
radioButtonList.Name = "radioButtonList";
|
||||||
radioButtonList.Size = new Size(80, 24);
|
radioButtonList.Size = new Size(66, 19);
|
||||||
radioButtonList.TabIndex = 3;
|
radioButtonList.TabIndex = 3;
|
||||||
radioButtonList.TabStop = true;
|
radioButtonList.TabStop = true;
|
||||||
radioButtonList.Text = "Список";
|
radioButtonList.Text = "Список";
|
||||||
@ -222,10 +196,9 @@
|
|||||||
// radioButtonMassive
|
// radioButtonMassive
|
||||||
//
|
//
|
||||||
radioButtonMassive.AutoSize = true;
|
radioButtonMassive.AutoSize = true;
|
||||||
radioButtonMassive.Location = new Point(3, 75);
|
radioButtonMassive.Location = new Point(3, 56);
|
||||||
radioButtonMassive.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
radioButtonMassive.Name = "radioButtonMassive";
|
radioButtonMassive.Name = "radioButtonMassive";
|
||||||
radioButtonMassive.Size = new Size(82, 24);
|
radioButtonMassive.Size = new Size(67, 19);
|
||||||
radioButtonMassive.TabIndex = 2;
|
radioButtonMassive.TabIndex = 2;
|
||||||
radioButtonMassive.TabStop = true;
|
radioButtonMassive.TabStop = true;
|
||||||
radioButtonMassive.Text = "Массив";
|
radioButtonMassive.Text = "Массив";
|
||||||
@ -233,18 +206,17 @@
|
|||||||
//
|
//
|
||||||
// textBoxCollectionName
|
// textBoxCollectionName
|
||||||
//
|
//
|
||||||
textBoxCollectionName.Location = new Point(3, 36);
|
textBoxCollectionName.Location = new Point(3, 27);
|
||||||
textBoxCollectionName.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
textBoxCollectionName.Size = new Size(185, 27);
|
textBoxCollectionName.Size = new Size(162, 23);
|
||||||
textBoxCollectionName.TabIndex = 1;
|
textBoxCollectionName.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// labelCollectionName
|
// labelCollectionName
|
||||||
//
|
//
|
||||||
labelCollectionName.AutoSize = true;
|
labelCollectionName.AutoSize = true;
|
||||||
labelCollectionName.Location = new Point(24, 12);
|
labelCollectionName.Location = new Point(21, 9);
|
||||||
labelCollectionName.Name = "labelCollectionName";
|
labelCollectionName.Name = "labelCollectionName";
|
||||||
labelCollectionName.Size = new Size(158, 20);
|
labelCollectionName.Size = new Size(125, 15);
|
||||||
labelCollectionName.TabIndex = 0;
|
labelCollectionName.TabIndex = 0;
|
||||||
labelCollectionName.Text = "Название коллекции:";
|
labelCollectionName.Text = "Название коллекции:";
|
||||||
//
|
//
|
||||||
@ -254,10 +226,9 @@
|
|||||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||||
comboBoxSelectorCompany.Location = new Point(7, 416);
|
comboBoxSelectorCompany.Location = new Point(6, 312);
|
||||||
comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
comboBoxSelectorCompany.Size = new Size(185, 28);
|
comboBoxSelectorCompany.Size = new Size(162, 23);
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
@ -265,21 +236,18 @@
|
|||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 0);
|
pictureBox.Location = new Point(0, 0);
|
||||||
pictureBox.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(753, 884);
|
pictureBox.Size = new Size(659, 663);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// FormWarPlaneCollection
|
// FormWarPlaneCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(952, 884);
|
ClientSize = new Size(833, 663);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBox1);
|
Controls.Add(groupBox1);
|
||||||
Margin = new Padding(3, 4, 3, 4);
|
|
||||||
Name = "FormWarPlaneCollection";
|
Name = "FormWarPlaneCollection";
|
||||||
Text = "Коллекция военных самолетов";
|
Text = "Коллекция военных самолетов";
|
||||||
groupBox1.ResumeLayout(false);
|
groupBox1.ResumeLayout(false);
|
||||||
@ -296,7 +264,6 @@
|
|||||||
private GroupBox groupBox1;
|
private GroupBox groupBox1;
|
||||||
private ComboBox comboBoxSelectorCompany;
|
private ComboBox comboBoxSelectorCompany;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
private Button buttonAddAirFighter;
|
|
||||||
private Button buttonAddWarPlane;
|
private Button buttonAddWarPlane;
|
||||||
private PictureBox pictureBox;
|
private PictureBox pictureBox;
|
||||||
private Button buttonRemove;
|
private Button buttonRemove;
|
||||||
|
@ -44,28 +44,22 @@ public partial class FormWarPlaneCollection : Form
|
|||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateObject(string type)
|
|
||||||
|
|
||||||
|
private void ButtonAddWarPlane_Click(object sender, EventArgs e){
|
||||||
|
|
||||||
|
FormWarPlaneConfig form = new();
|
||||||
|
form.Show();
|
||||||
|
form.AddEvent(SetWarPlane);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetWarPlane(DrawningWarPlane warPlane)
|
||||||
{
|
{
|
||||||
if (_company == null)
|
if (_company == null || warPlane == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Random random = new();
|
if (_company + warPlane != -1)
|
||||||
DrawningWarPlane drawningWarPlane;
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case nameof(DrawningWarPlane):
|
|
||||||
drawningWarPlane = new DrawningWarPlane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
|
|
||||||
break;
|
|
||||||
case nameof(DrawningAirFighter):
|
|
||||||
drawningWarPlane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
|
|
||||||
GetColor(random),GetColor(random),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_company + drawningWarPlane != -1)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
@ -74,29 +68,10 @@ public partial class FormWarPlaneCollection : Form
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddWarPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarPlane));
|
|
||||||
|
|
||||||
private void ButtonAddAirFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirFighter));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение цвета
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="random">Генератор случайных чисел</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static Color GetColor(Random random)
|
|
||||||
{
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0,
|
|
||||||
256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -33,29 +33,31 @@
|
|||||||
panelPurple = new Panel();
|
panelPurple = new Panel();
|
||||||
panelYellow = new Panel();
|
panelYellow = new Panel();
|
||||||
panelBlack = new Panel();
|
panelBlack = new Panel();
|
||||||
panelGray = new Panel();
|
panelGrey = new Panel();
|
||||||
panelBlue = new Panel();
|
panelBlue = new Panel();
|
||||||
panelWhite = new Panel();
|
panelWhite = new Panel();
|
||||||
panelGreen = new Panel();
|
panelGreen = new Panel();
|
||||||
panelRed = new Panel();
|
panelRed = new Panel();
|
||||||
checkBoxAdditionalWing = new CheckBox();
|
checkBoxAdditionalWing = new CheckBox();
|
||||||
checkBoxRocket = new CheckBox();
|
checkBoxRocket = new CheckBox();
|
||||||
numericUpDownWheight = new NumericUpDown();
|
numericUpDownWeight = new NumericUpDown();
|
||||||
labelWheight = new Label();
|
labelWheight = new Label();
|
||||||
numericUpDownSpeed = new NumericUpDown();
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
labelSpeed = new Label();
|
labelSpeed = new Label();
|
||||||
label = new Label();
|
labelModifiedObject = new Label();
|
||||||
labelSimpleObject = new Label();
|
labelSimpleObject = new Label();
|
||||||
pictureBoxObject = new PictureBox();
|
pictureBoxObject = new PictureBox();
|
||||||
buttonAdd = new Button();
|
buttonAdd = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
panelObject = new Panel();
|
PanelObject = new Panel();
|
||||||
|
labelAdditionalColor = new Label();
|
||||||
|
labelBodyColor = new Label();
|
||||||
groupBoxConfig.SuspendLayout();
|
groupBoxConfig.SuspendLayout();
|
||||||
groupBoxColor.SuspendLayout();
|
groupBoxColor.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWheight).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
panelObject.SuspendLayout();
|
PanelObject.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxConfig
|
// groupBoxConfig
|
||||||
@ -63,16 +65,18 @@
|
|||||||
groupBoxConfig.Controls.Add(groupBoxColor);
|
groupBoxConfig.Controls.Add(groupBoxColor);
|
||||||
groupBoxConfig.Controls.Add(checkBoxAdditionalWing);
|
groupBoxConfig.Controls.Add(checkBoxAdditionalWing);
|
||||||
groupBoxConfig.Controls.Add(checkBoxRocket);
|
groupBoxConfig.Controls.Add(checkBoxRocket);
|
||||||
groupBoxConfig.Controls.Add(numericUpDownWheight);
|
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||||
groupBoxConfig.Controls.Add(labelWheight);
|
groupBoxConfig.Controls.Add(labelWheight);
|
||||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||||
groupBoxConfig.Controls.Add(labelSpeed);
|
groupBoxConfig.Controls.Add(labelSpeed);
|
||||||
groupBoxConfig.Controls.Add(label);
|
groupBoxConfig.Controls.Add(labelModifiedObject);
|
||||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||||
groupBoxConfig.Dock = DockStyle.Left;
|
groupBoxConfig.Dock = DockStyle.Left;
|
||||||
groupBoxConfig.Location = new Point(0, 0);
|
groupBoxConfig.Location = new Point(0, 0);
|
||||||
|
groupBoxConfig.Margin = new Padding(3, 2, 3, 2);
|
||||||
groupBoxConfig.Name = "groupBoxConfig";
|
groupBoxConfig.Name = "groupBoxConfig";
|
||||||
groupBoxConfig.Size = new Size(569, 266);
|
groupBoxConfig.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
groupBoxConfig.Size = new Size(498, 264);
|
||||||
groupBoxConfig.TabIndex = 0;
|
groupBoxConfig.TabIndex = 0;
|
||||||
groupBoxConfig.TabStop = false;
|
groupBoxConfig.TabStop = false;
|
||||||
groupBoxConfig.Text = "Параметры";
|
groupBoxConfig.Text = "Параметры";
|
||||||
@ -82,14 +86,16 @@
|
|||||||
groupBoxColor.Controls.Add(panelPurple);
|
groupBoxColor.Controls.Add(panelPurple);
|
||||||
groupBoxColor.Controls.Add(panelYellow);
|
groupBoxColor.Controls.Add(panelYellow);
|
||||||
groupBoxColor.Controls.Add(panelBlack);
|
groupBoxColor.Controls.Add(panelBlack);
|
||||||
groupBoxColor.Controls.Add(panelGray);
|
groupBoxColor.Controls.Add(panelGrey);
|
||||||
groupBoxColor.Controls.Add(panelBlue);
|
groupBoxColor.Controls.Add(panelBlue);
|
||||||
groupBoxColor.Controls.Add(panelWhite);
|
groupBoxColor.Controls.Add(panelWhite);
|
||||||
groupBoxColor.Controls.Add(panelGreen);
|
groupBoxColor.Controls.Add(panelGreen);
|
||||||
groupBoxColor.Controls.Add(panelRed);
|
groupBoxColor.Controls.Add(panelRed);
|
||||||
groupBoxColor.Location = new Point(219, 12);
|
groupBoxColor.Location = new Point(192, 9);
|
||||||
|
groupBoxColor.Margin = new Padding(3, 2, 3, 2);
|
||||||
groupBoxColor.Name = "groupBoxColor";
|
groupBoxColor.Name = "groupBoxColor";
|
||||||
groupBoxColor.Size = new Size(335, 157);
|
groupBoxColor.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
groupBoxColor.Size = new Size(293, 123);
|
||||||
groupBoxColor.TabIndex = 8;
|
groupBoxColor.TabIndex = 8;
|
||||||
groupBoxColor.TabStop = false;
|
groupBoxColor.TabStop = false;
|
||||||
groupBoxColor.Text = "Цвета";
|
groupBoxColor.Text = "Цвета";
|
||||||
@ -97,73 +103,82 @@
|
|||||||
// panelPurple
|
// panelPurple
|
||||||
//
|
//
|
||||||
panelPurple.BackColor = Color.Purple;
|
panelPurple.BackColor = Color.Purple;
|
||||||
panelPurple.Location = new Point(271, 99);
|
panelPurple.Location = new Point(237, 74);
|
||||||
|
panelPurple.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelPurple.Name = "panelPurple";
|
panelPurple.Name = "panelPurple";
|
||||||
panelPurple.Size = new Size(58, 52);
|
panelPurple.Size = new Size(51, 39);
|
||||||
panelPurple.TabIndex = 7;
|
panelPurple.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// panelYellow
|
// panelYellow
|
||||||
//
|
//
|
||||||
panelYellow.BackColor = Color.Yellow;
|
panelYellow.BackColor = Color.Yellow;
|
||||||
panelYellow.Location = new Point(271, 26);
|
panelYellow.Location = new Point(237, 20);
|
||||||
|
panelYellow.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelYellow.Name = "panelYellow";
|
panelYellow.Name = "panelYellow";
|
||||||
panelYellow.Size = new Size(58, 52);
|
panelYellow.Size = new Size(51, 39);
|
||||||
panelYellow.TabIndex = 3;
|
panelYellow.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// panelBlack
|
// panelBlack
|
||||||
//
|
//
|
||||||
panelBlack.BackColor = Color.Black;
|
panelBlack.BackColor = Color.Black;
|
||||||
panelBlack.Location = new Point(176, 99);
|
panelBlack.Location = new Point(154, 74);
|
||||||
|
panelBlack.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelBlack.Name = "panelBlack";
|
panelBlack.Name = "panelBlack";
|
||||||
panelBlack.Size = new Size(58, 52);
|
panelBlack.Size = new Size(51, 39);
|
||||||
panelBlack.TabIndex = 6;
|
panelBlack.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// panelGray
|
// panelGrey
|
||||||
//
|
//
|
||||||
panelGray.BackColor = Color.Gray;
|
panelGrey.BackColor = Color.Gray;
|
||||||
panelGray.Location = new Point(89, 99);
|
panelGrey.Location = new Point(78, 74);
|
||||||
panelGray.Name = "panelGray";
|
panelGrey.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelGray.Size = new Size(58, 52);
|
panelGrey.Name = "panelGrey";
|
||||||
panelGray.TabIndex = 5;
|
panelGrey.Size = new Size(51, 39);
|
||||||
|
panelGrey.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// panelBlue
|
// panelBlue
|
||||||
//
|
//
|
||||||
panelBlue.BackColor = Color.Blue;
|
panelBlue.BackColor = Color.Blue;
|
||||||
panelBlue.Location = new Point(176, 26);
|
panelBlue.Location = new Point(154, 20);
|
||||||
|
panelBlue.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelBlue.Name = "panelBlue";
|
panelBlue.Name = "panelBlue";
|
||||||
panelBlue.Size = new Size(58, 52);
|
panelBlue.Size = new Size(51, 39);
|
||||||
panelBlue.TabIndex = 2;
|
panelBlue.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// panelWhite
|
// panelWhite
|
||||||
//
|
//
|
||||||
panelWhite.BackColor = Color.White;
|
panelWhite.BackColor = Color.White;
|
||||||
panelWhite.Location = new Point(6, 99);
|
panelWhite.Location = new Point(5, 74);
|
||||||
|
panelWhite.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelWhite.Name = "panelWhite";
|
panelWhite.Name = "panelWhite";
|
||||||
panelWhite.Size = new Size(58, 52);
|
panelWhite.Size = new Size(51, 39);
|
||||||
panelWhite.TabIndex = 4;
|
panelWhite.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// panelGreen
|
// panelGreen
|
||||||
//
|
//
|
||||||
panelGreen.BackColor = Color.Green;
|
panelGreen.BackColor = Color.Green;
|
||||||
panelGreen.Location = new Point(89, 26);
|
panelGreen.Location = new Point(78, 20);
|
||||||
|
panelGreen.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelGreen.Name = "panelGreen";
|
panelGreen.Name = "panelGreen";
|
||||||
panelGreen.Size = new Size(58, 52);
|
panelGreen.Size = new Size(51, 39);
|
||||||
panelGreen.TabIndex = 1;
|
panelGreen.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// panelRed
|
// panelRed
|
||||||
//
|
//
|
||||||
panelRed.BackColor = Color.Red;
|
panelRed.BackColor = Color.Red;
|
||||||
panelRed.Location = new Point(6, 26);
|
panelRed.Location = new Point(5, 20);
|
||||||
|
panelRed.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelRed.Name = "panelRed";
|
panelRed.Name = "panelRed";
|
||||||
panelRed.Size = new Size(58, 52);
|
panelRed.Size = new Size(51, 39);
|
||||||
panelRed.TabIndex = 0;
|
panelRed.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// checkBoxAdditionalWing
|
// checkBoxAdditionalWing
|
||||||
//
|
//
|
||||||
checkBoxAdditionalWing.AutoSize = true;
|
checkBoxAdditionalWing.AutoSize = true;
|
||||||
checkBoxAdditionalWing.Location = new Point(12, 175);
|
checkBoxAdditionalWing.Location = new Point(6, 234);
|
||||||
|
checkBoxAdditionalWing.Margin = new Padding(3, 2, 3, 2);
|
||||||
checkBoxAdditionalWing.Name = "checkBoxAdditionalWing";
|
checkBoxAdditionalWing.Name = "checkBoxAdditionalWing";
|
||||||
checkBoxAdditionalWing.Size = new Size(339, 24);
|
checkBoxAdditionalWing.Size = new Size(270, 19);
|
||||||
checkBoxAdditionalWing.TabIndex = 7;
|
checkBoxAdditionalWing.TabIndex = 7;
|
||||||
checkBoxAdditionalWing.Text = "Признак наличия дополнительных крыльев";
|
checkBoxAdditionalWing.Text = "Признак наличия дополнительных крыльев";
|
||||||
checkBoxAdditionalWing.UseVisualStyleBackColor = true;
|
checkBoxAdditionalWing.UseVisualStyleBackColor = true;
|
||||||
@ -171,127 +186,167 @@
|
|||||||
// checkBoxRocket
|
// checkBoxRocket
|
||||||
//
|
//
|
||||||
checkBoxRocket.AutoSize = true;
|
checkBoxRocket.AutoSize = true;
|
||||||
checkBoxRocket.Location = new Point(12, 145);
|
checkBoxRocket.Location = new Point(6, 195);
|
||||||
|
checkBoxRocket.Margin = new Padding(3, 2, 3, 2);
|
||||||
checkBoxRocket.Name = "checkBoxRocket";
|
checkBoxRocket.Name = "checkBoxRocket";
|
||||||
checkBoxRocket.Size = new Size(196, 24);
|
checkBoxRocket.Size = new Size(156, 19);
|
||||||
checkBoxRocket.TabIndex = 6;
|
checkBoxRocket.TabIndex = 6;
|
||||||
checkBoxRocket.Text = "Признак наличия ракет";
|
checkBoxRocket.Text = "Признак наличия ракет";
|
||||||
checkBoxRocket.UseVisualStyleBackColor = true;
|
checkBoxRocket.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// numericUpDownWheight
|
// numericUpDownWeight
|
||||||
//
|
//
|
||||||
numericUpDownWheight.Location = new Point(96, 63);
|
numericUpDownWeight.Location = new Point(84, 47);
|
||||||
numericUpDownWheight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
|
||||||
numericUpDownWheight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
numericUpDownWheight.Name = "numericUpDownWheight";
|
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
numericUpDownWheight.Size = new Size(85, 27);
|
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
numericUpDownWheight.TabIndex = 5;
|
numericUpDownWeight.Size = new Size(74, 23);
|
||||||
numericUpDownWheight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
numericUpDownWeight.TabIndex = 5;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
//
|
//
|
||||||
// labelWheight
|
// labelWheight
|
||||||
//
|
//
|
||||||
labelWheight.AutoSize = true;
|
labelWheight.AutoSize = true;
|
||||||
labelWheight.Location = new Point(17, 70);
|
labelWheight.Location = new Point(15, 53);
|
||||||
labelWheight.Name = "labelWheight";
|
labelWheight.Name = "labelWheight";
|
||||||
labelWheight.Size = new Size(33, 20);
|
labelWheight.Size = new Size(26, 15);
|
||||||
labelWheight.TabIndex = 4;
|
labelWheight.TabIndex = 4;
|
||||||
labelWheight.Text = "Вес";
|
labelWheight.Text = "Вес";
|
||||||
//
|
//
|
||||||
// numericUpDownSpeed
|
// numericUpDownSpeed
|
||||||
//
|
//
|
||||||
numericUpDownSpeed.Location = new Point(96, 26);
|
numericUpDownSpeed.Location = new Point(84, 20);
|
||||||
|
numericUpDownSpeed.Margin = new Padding(3, 2, 3, 2);
|
||||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
numericUpDownSpeed.Size = new Size(85, 27);
|
numericUpDownSpeed.Size = new Size(74, 23);
|
||||||
numericUpDownSpeed.TabIndex = 3;
|
numericUpDownSpeed.TabIndex = 3;
|
||||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
//
|
//
|
||||||
// labelSpeed
|
// labelSpeed
|
||||||
//
|
//
|
||||||
labelSpeed.AutoSize = true;
|
labelSpeed.AutoSize = true;
|
||||||
labelSpeed.Location = new Point(17, 24);
|
labelSpeed.Location = new Point(15, 18);
|
||||||
labelSpeed.Name = "labelSpeed";
|
labelSpeed.Name = "labelSpeed";
|
||||||
labelSpeed.Size = new Size(73, 20);
|
labelSpeed.Size = new Size(59, 15);
|
||||||
labelSpeed.TabIndex = 2;
|
labelSpeed.TabIndex = 2;
|
||||||
labelSpeed.Text = "Скорость";
|
labelSpeed.Text = "Скорость";
|
||||||
//
|
//
|
||||||
// label
|
// labelModifiedObject
|
||||||
//
|
//
|
||||||
label.BorderStyle = BorderStyle.FixedSingle;
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
label.Location = new Point(459, 174);
|
labelModifiedObject.Location = new Point(399, 233);
|
||||||
label.Name = "label";
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
label.Size = new Size(106, 24);
|
labelModifiedObject.Size = new Size(93, 18);
|
||||||
label.TabIndex = 1;
|
labelModifiedObject.TabIndex = 1;
|
||||||
label.Text = "Продвинутый";
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
label.TextAlign = ContentAlignment.MiddleCenter;
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
label.Click += labelObject_Click;
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
//
|
//
|
||||||
// labelSimpleObject
|
// labelSimpleObject
|
||||||
//
|
//
|
||||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
labelSimpleObject.Location = new Point(357, 174);
|
labelSimpleObject.Location = new Point(304, 233);
|
||||||
labelSimpleObject.Name = "labelSimpleObject";
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
labelSimpleObject.Size = new Size(96, 24);
|
labelSimpleObject.Size = new Size(84, 18);
|
||||||
labelSimpleObject.TabIndex = 0;
|
labelSimpleObject.TabIndex = 0;
|
||||||
labelSimpleObject.Text = "Простой";
|
labelSimpleObject.Text = "Простой";
|
||||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
labelSimpleObject.Click += labelObject_Click;
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
//
|
//
|
||||||
// pictureBoxObject
|
// pictureBoxObject
|
||||||
//
|
//
|
||||||
pictureBoxObject.Location = new Point(26, 34);
|
pictureBoxObject.Location = new Point(12, 38);
|
||||||
|
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
pictureBoxObject.Name = "pictureBoxObject";
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
pictureBoxObject.Size = new Size(181, 117);
|
pictureBoxObject.Size = new Size(176, 149);
|
||||||
pictureBoxObject.TabIndex = 1;
|
pictureBoxObject.TabIndex = 1;
|
||||||
pictureBoxObject.TabStop = false;
|
pictureBoxObject.TabStop = false;
|
||||||
|
pictureBoxObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
pictureBoxObject.DragEnter += PanelObject_DragEnter;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Location = new Point(604, 179);
|
buttonAdd.Location = new Point(517, 236);
|
||||||
|
buttonAdd.Margin = new Padding(3, 2, 3, 2);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(94, 29);
|
buttonAdd.Size = new Size(82, 22);
|
||||||
buttonAdd.TabIndex = 2;
|
buttonAdd.TabIndex = 2;
|
||||||
buttonAdd.Text = "Добавить";
|
buttonAdd.Text = "Добавить";
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(713, 179);
|
buttonCancel.Location = new Point(623, 236);
|
||||||
|
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(94, 29);
|
buttonCancel.Size = new Size(82, 22);
|
||||||
buttonCancel.TabIndex = 3;
|
buttonCancel.TabIndex = 3;
|
||||||
buttonCancel.Text = "Отменить";
|
buttonCancel.Text = "Отменить";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// panelObject
|
// PanelObject
|
||||||
//
|
//
|
||||||
panelObject.AllowDrop = true;
|
PanelObject.AllowDrop = true;
|
||||||
panelObject.Controls.Add(pictureBoxObject);
|
PanelObject.Controls.Add(labelAdditionalColor);
|
||||||
panelObject.Location = new Point(591, 12);
|
PanelObject.Controls.Add(labelBodyColor);
|
||||||
panelObject.Name = "panelObject";
|
PanelObject.Controls.Add(pictureBoxObject);
|
||||||
panelObject.Size = new Size(225, 161);
|
PanelObject.Location = new Point(517, 9);
|
||||||
panelObject.TabIndex = 4;
|
PanelObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
panelObject.DragEnter += PanelObject_DragEnter;
|
PanelObject.Name = "PanelObject";
|
||||||
|
PanelObject.Size = new Size(197, 205);
|
||||||
|
PanelObject.TabIndex = 4;
|
||||||
|
PanelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
PanelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// labelAdditionalColor
|
||||||
|
//
|
||||||
|
labelAdditionalColor.AllowDrop = true;
|
||||||
|
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAdditionalColor.Location = new Point(100, 6);
|
||||||
|
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||||
|
labelAdditionalColor.Size = new Size(88, 18);
|
||||||
|
labelAdditionalColor.TabIndex = 3;
|
||||||
|
labelAdditionalColor.Text = "Доп. цвет";
|
||||||
|
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
|
||||||
|
labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelBodyColor
|
||||||
|
//
|
||||||
|
labelBodyColor.AllowDrop = true;
|
||||||
|
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelBodyColor.Location = new Point(12, 6);
|
||||||
|
labelBodyColor.Name = "labelBodyColor";
|
||||||
|
labelBodyColor.Size = new Size(77, 18);
|
||||||
|
labelBodyColor.TabIndex = 2;
|
||||||
|
labelBodyColor.Text = "Цвет";
|
||||||
|
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||||
|
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
|
||||||
//
|
//
|
||||||
// FormWarPlaneConfig
|
// FormWarPlaneConfig
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(819, 266);
|
ClientSize = new Size(717, 264);
|
||||||
Controls.Add(panelObject);
|
Controls.Add(PanelObject);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonAdd);
|
Controls.Add(buttonAdd);
|
||||||
Controls.Add(groupBoxConfig);
|
Controls.Add(groupBoxConfig);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
Name = "FormWarPlaneConfig";
|
Name = "FormWarPlaneConfig";
|
||||||
Text = "Создание объекта";
|
Text = "Создание объекта";
|
||||||
groupBoxConfig.ResumeLayout(false);
|
groupBoxConfig.ResumeLayout(false);
|
||||||
groupBoxConfig.PerformLayout();
|
groupBoxConfig.PerformLayout();
|
||||||
groupBoxColor.ResumeLayout(false);
|
groupBoxColor.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWheight).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
panelObject.ResumeLayout(false);
|
PanelObject.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,11 +354,11 @@
|
|||||||
|
|
||||||
private GroupBox groupBoxConfig;
|
private GroupBox groupBoxConfig;
|
||||||
private Label labelSimpleObject;
|
private Label labelSimpleObject;
|
||||||
private Label label;
|
private Label labelModifiedObject;
|
||||||
private Label labelSpeed;
|
private Label labelSpeed;
|
||||||
private NumericUpDown numericUpDownSpeed;
|
private NumericUpDown numericUpDownSpeed;
|
||||||
private Label labelWheight;
|
private Label labelWheight;
|
||||||
private NumericUpDown numericUpDownWheight;
|
private NumericUpDown numericUpDownWeight;
|
||||||
private CheckBox checkBoxRocket;
|
private CheckBox checkBoxRocket;
|
||||||
private CheckBox checkBoxAdditionalWing;
|
private CheckBox checkBoxAdditionalWing;
|
||||||
private GroupBox groupBoxColor;
|
private GroupBox groupBoxColor;
|
||||||
@ -313,11 +368,13 @@
|
|||||||
private Panel panelGreen;
|
private Panel panelGreen;
|
||||||
private Panel panelPurple;
|
private Panel panelPurple;
|
||||||
private Panel panelBlack;
|
private Panel panelBlack;
|
||||||
private Panel panelGray;
|
private Panel panelGrey;
|
||||||
private Panel panelWhite;
|
private Panel panelWhite;
|
||||||
private PictureBox pictureBoxObject;
|
private PictureBox pictureBoxObject;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Panel panelObject;
|
private Panel PanelObject;
|
||||||
|
private Label labelAdditionalColor;
|
||||||
|
private Label labelBodyColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectAirFighter.Drawning;
|
using ProjectAirFighter.Drawning;
|
||||||
|
using ProjectAirFighter.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -9,42 +10,166 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ProjectAirFighter
|
namespace ProjectAirFighter;
|
||||||
{
|
|
||||||
|
/// <summary>
|
||||||
|
/// Форма конфигурации объекта
|
||||||
|
/// </summary>
|
||||||
public partial class FormWarPlaneConfig : Form
|
public partial class FormWarPlaneConfig : Form
|
||||||
{
|
{
|
||||||
private DrawningWarPlane _warPlane;
|
|
||||||
|
/// <summary>
|
||||||
|
/// Объект - прорисовка военного самолета
|
||||||
|
/// </summary>
|
||||||
|
private DrawningWarPlane _warPlane = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие для передачи объекта
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawningWarPlane>? WarPlaneDelegate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
public FormWarPlaneConfig()
|
public FormWarPlaneConfig()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
panelRed.MouseDown += Panel_MouseDown;
|
||||||
|
panelGreen.MouseDown += Panel_MouseDown;
|
||||||
|
panelWhite.MouseDown += Panel_MouseDown;
|
||||||
|
panelBlack.MouseDown += Panel_MouseDown;
|
||||||
|
panelYellow.MouseDown += Panel_MouseDown;
|
||||||
|
panelBlue.MouseDown += Panel_MouseDown;
|
||||||
|
panelGrey.MouseDown += Panel_MouseDown;
|
||||||
|
panelPurple.MouseDown += Panel_MouseDown;
|
||||||
|
|
||||||
|
//TODO привязать анонимный метод через lamda с закрытием формы
|
||||||
|
buttonCancel.Click += (sender, e) => Close();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Привязка внешнего метода к событию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="warPlaneDelegate"></param>
|
||||||
|
public void AddEvent(Action<DrawningWarPlane> warPlaneDelegate)
|
||||||
|
{
|
||||||
|
if (WarPlaneDelegate == null)
|
||||||
|
{
|
||||||
|
WarPlaneDelegate = warPlaneDelegate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarPlaneDelegate += warPlaneDelegate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Прорисовка объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void labelObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
|
|
||||||
|
private void DrawObject()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_warPlane?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
_warPlane?.SetPosition(5, 5);
|
||||||
|
_warPlane?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Передаем информацию при нажатии Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Действие при приеме претаскиваеиой информации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_warPlane = new DrawningWarPlane((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_warPlane = new DrawningAirFighter((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxRocket.Checked, checkBoxAdditionalWing.Checked);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Panel_MouseDown(object? sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor!, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_warPlane == null) return;
|
||||||
|
_warPlane.EntityWarPlane?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
|
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
|
||||||
|
else
|
||||||
e.Effect = DragDropEffects.None;
|
e.Effect = DragDropEffects.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_warPlane?.EntityWarPlane is EntityAirFighter _airFighter)
|
||||||
|
{
|
||||||
|
_airFighter?.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
}
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(typeof(Color)))
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
else
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_warPlane != null)
|
||||||
|
{
|
||||||
|
WarPlaneDelegate?.Invoke(_warPlane);
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
6
ProjectAirFighter/ProjectAirFighter/WarPlaneDelegate.cs
Normal file
6
ProjectAirFighter/ProjectAirFighter/WarPlaneDelegate.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
using ProjectAirFighter.Drawning;
|
||||||
|
|
||||||
|
|
||||||
|
namespace ProjectAirFighter;
|
||||||
|
|
||||||
|
public delegate void WarPlaneDelegate(DrawningWarPlane warPlane);
|
Loading…
Reference in New Issue
Block a user