From d5fc3fd5ec3db8a7bf0a80bb008a6b2eff20a020 Mon Sep 17 00:00:00 2001
From: nezui1 <104579567+nezui1@users.noreply.github.com>
Date: Sat, 20 Apr 2024 15:47:54 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=20=E2=84=965?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entities/EntityAirFighter.cs | 6 +
.../Entities/EntityWarPlane.cs | 5 +
.../FormWarPlaneCollection.Designer.cs | 109 +++------
.../FormWarPlaneCollection.cs | 49 +---
.../FormWarPlaneConfig.Designer.cs | 227 +++++++++++-------
.../ProjectAirFighter/FormWarPlaneConfig.cs | 187 ++++++++++++---
.../ProjectAirFighter/WarPlaneDelegate.cs | 6 +
7 files changed, 365 insertions(+), 224 deletions(-)
create mode 100644 ProjectAirFighter/ProjectAirFighter/WarPlaneDelegate.cs
diff --git a/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs
index c6984d2..07b7380 100644
--- a/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs
+++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs
@@ -48,6 +48,12 @@ public class EntityAirFighter : EntityWarPlane
/// Дополнительный цвет
/// Признак наличия рокет
/// Признак наличия дополнительных крыльев
+
+ 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)
{
diff --git a/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs
index d62fb0d..2c6cf4d 100644
--- a/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs
+++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs
@@ -25,6 +25,11 @@ public class EntityWarPlane
///
public double Step => Speed * 100 / Weight;
+ public void SetBodyColor(Color bodyColor)
+ {
+ BodyColor = bodyColor;
+ }
+
///
/// Конструктор сущности
///
diff --git a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs
index 3124f9a..493e22b 100644
--- a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs
+++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs
@@ -33,7 +33,6 @@
buttonRemove = new Button();
buttonAddWarPlane = new Button();
button1 = new Button();
- buttonAddAirFighter = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonGoToCheck = new Button();
buttonCreateCompany = new Button();
@@ -60,11 +59,9 @@
groupBox1.Controls.Add(panelStorage);
groupBox1.Controls.Add(comboBoxSelectorCompany);
groupBox1.Dock = DockStyle.Right;
- groupBox1.Location = new Point(753, 0);
- groupBox1.Margin = new Padding(3, 4, 3, 4);
+ groupBox1.Location = new Point(659, 0);
groupBox1.Name = "groupBox1";
- groupBox1.Padding = new Padding(3, 4, 3, 4);
- groupBox1.Size = new Size(199, 884);
+ groupBox1.Size = new Size(174, 663);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Инструменты";
@@ -74,22 +71,19 @@
panelCompanyTools.Controls.Add(buttonRemove);
panelCompanyTools.Controls.Add(buttonAddWarPlane);
panelCompanyTools.Controls.Add(button1);
- panelCompanyTools.Controls.Add(buttonAddAirFighter);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Enabled = false;
- panelCompanyTools.Location = new Point(0, 497);
- panelCompanyTools.Margin = new Padding(3, 4, 3, 4);
+ panelCompanyTools.Location = new Point(0, 373);
panelCompanyTools.Name = "panelCompanyTools";
- panelCompanyTools.Size = new Size(199, 371);
+ panelCompanyTools.Size = new Size(174, 278);
panelCompanyTools.TabIndex = 9;
//
// buttonRemove
//
- buttonRemove.Location = new Point(7, 193);
- buttonRemove.Margin = new Padding(3, 4, 3, 4);
+ buttonRemove.Location = new Point(6, 145);
buttonRemove.Name = "buttonRemove";
- buttonRemove.Size = new Size(185, 59);
+ buttonRemove.Size = new Size(162, 44);
buttonRemove.TabIndex = 4;
buttonRemove.Text = "Удалить самолет";
buttonRemove.UseVisualStyleBackColor = true;
@@ -97,10 +91,9 @@
//
// buttonAddWarPlane
//
- buttonAddWarPlane.Location = new Point(7, 4);
- buttonAddWarPlane.Margin = new Padding(3, 4, 3, 4);
+ buttonAddWarPlane.Location = new Point(6, 27);
buttonAddWarPlane.Name = "buttonAddWarPlane";
- buttonAddWarPlane.Size = new Size(185, 69);
+ buttonAddWarPlane.Size = new Size(162, 52);
buttonAddWarPlane.TabIndex = 1;
buttonAddWarPlane.Text = "Добавление военного самолета";
buttonAddWarPlane.UseVisualStyleBackColor = true;
@@ -108,42 +101,28 @@
//
// button1
//
- button1.Location = new Point(7, 327);
- button1.Margin = new Padding(3, 4, 3, 4);
+ button1.Location = new Point(6, 245);
button1.Name = "button1";
- button1.Size = new Size(185, 40);
+ button1.Size = new Size(162, 30);
button1.TabIndex = 6;
button1.Text = "Обновить";
button1.UseVisualStyleBackColor = true;
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.Location = new Point(9, 148);
- maskedTextBoxPosition.Margin = new Padding(3, 4, 3, 4);
+ maskedTextBoxPosition.Location = new Point(8, 111);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
- maskedTextBoxPosition.Size = new Size(185, 27);
+ maskedTextBoxPosition.Size = new Size(162, 23);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonGoToCheck
//
- buttonGoToCheck.Location = new Point(7, 260);
- buttonGoToCheck.Margin = new Padding(3, 4, 3, 4);
+ buttonGoToCheck.Location = new Point(6, 195);
buttonGoToCheck.Name = "buttonGoToCheck";
- buttonGoToCheck.Size = new Size(185, 59);
+ buttonGoToCheck.Size = new Size(162, 44);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тест";
buttonGoToCheck.UseVisualStyleBackColor = true;
@@ -151,10 +130,9 @@
//
// buttonCreateCompany
//
- buttonCreateCompany.Location = new Point(7, 459);
- buttonCreateCompany.Margin = new Padding(3, 4, 3, 4);
+ buttonCreateCompany.Location = new Point(6, 344);
buttonCreateCompany.Name = "buttonCreateCompany";
- buttonCreateCompany.Size = new Size(185, 31);
+ buttonCreateCompany.Size = new Size(162, 23);
buttonCreateCompany.TabIndex = 8;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
@@ -170,18 +148,16 @@
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
- panelStorage.Location = new Point(3, 24);
- panelStorage.Margin = new Padding(3, 4, 3, 4);
+ panelStorage.Location = new Point(3, 19);
panelStorage.Name = "panelStorage";
- panelStorage.Size = new Size(193, 361);
+ panelStorage.Size = new Size(168, 271);
panelStorage.TabIndex = 7;
//
// buttonCollectionRemove
//
- buttonCollectionRemove.Location = new Point(3, 280);
- buttonCollectionRemove.Margin = new Padding(3, 4, 3, 4);
+ buttonCollectionRemove.Location = new Point(3, 210);
buttonCollectionRemove.Name = "buttonCollectionRemove";
- buttonCollectionRemove.Size = new Size(185, 31);
+ buttonCollectionRemove.Size = new Size(162, 23);
buttonCollectionRemove.TabIndex = 6;
buttonCollectionRemove.Text = "Удалить коллекцию";
buttonCollectionRemove.UseVisualStyleBackColor = true;
@@ -190,18 +166,17 @@
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
- listBoxCollection.Location = new Point(3, 147);
- listBoxCollection.Margin = new Padding(3, 4, 3, 4);
+ listBoxCollection.ItemHeight = 15;
+ listBoxCollection.Location = new Point(3, 110);
listBoxCollection.Name = "listBoxCollection";
- listBoxCollection.Size = new Size(185, 124);
+ listBoxCollection.Size = new Size(162, 94);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
- buttonCollectionAdd.Location = new Point(3, 108);
- buttonCollectionAdd.Margin = new Padding(3, 4, 3, 4);
+ buttonCollectionAdd.Location = new Point(3, 81);
buttonCollectionAdd.Name = "buttonCollectionAdd";
- buttonCollectionAdd.Size = new Size(185, 31);
+ buttonCollectionAdd.Size = new Size(162, 23);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
@@ -210,10 +185,9 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
- radioButtonList.Location = new Point(105, 75);
- radioButtonList.Margin = new Padding(3, 4, 3, 4);
+ radioButtonList.Location = new Point(92, 56);
radioButtonList.Name = "radioButtonList";
- radioButtonList.Size = new Size(80, 24);
+ radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
@@ -222,10 +196,9 @@
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
- radioButtonMassive.Location = new Point(3, 75);
- radioButtonMassive.Margin = new Padding(3, 4, 3, 4);
+ radioButtonMassive.Location = new Point(3, 56);
radioButtonMassive.Name = "radioButtonMassive";
- radioButtonMassive.Size = new Size(82, 24);
+ radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
@@ -233,18 +206,17 @@
//
// textBoxCollectionName
//
- textBoxCollectionName.Location = new Point(3, 36);
- textBoxCollectionName.Margin = new Padding(3, 4, 3, 4);
+ textBoxCollectionName.Location = new Point(3, 27);
textBoxCollectionName.Name = "textBoxCollectionName";
- textBoxCollectionName.Size = new Size(185, 27);
+ textBoxCollectionName.Size = new Size(162, 23);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
- labelCollectionName.Location = new Point(24, 12);
+ labelCollectionName.Location = new Point(21, 9);
labelCollectionName.Name = "labelCollectionName";
- labelCollectionName.Size = new Size(158, 20);
+ labelCollectionName.Size = new Size(125, 15);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
//
@@ -254,10 +226,9 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- comboBoxSelectorCompany.Location = new Point(7, 416);
- comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4);
+ comboBoxSelectorCompany.Location = new Point(6, 312);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
- comboBoxSelectorCompany.Size = new Size(185, 28);
+ comboBoxSelectorCompany.Size = new Size(162, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
@@ -265,21 +236,18 @@
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
- pictureBox.Margin = new Padding(3, 4, 3, 4);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(753, 884);
+ pictureBox.Size = new Size(659, 663);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
-
//
// FormWarPlaneCollection
//
- AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(952, 884);
+ ClientSize = new Size(833, 663);
Controls.Add(pictureBox);
Controls.Add(groupBox1);
- Margin = new Padding(3, 4, 3, 4);
Name = "FormWarPlaneCollection";
Text = "Коллекция военных самолетов";
groupBox1.ResumeLayout(false);
@@ -296,7 +264,6 @@
private GroupBox groupBox1;
private ComboBox comboBoxSelectorCompany;
private MaskedTextBox maskedTextBoxPosition;
- private Button buttonAddAirFighter;
private Button buttonAddWarPlane;
private PictureBox pictureBox;
private Button buttonRemove;
diff --git a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs
index 0a9b329..13b5741 100644
--- a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs
+++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs
@@ -44,28 +44,22 @@ public partial class FormWarPlaneCollection : Form
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;
}
- Random random = new();
- 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)
+ if (_company + warPlane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@@ -74,29 +68,10 @@ public partial class FormWarPlaneCollection : Form
{
MessageBox.Show("Не удалось добавить объект");
}
-
}
- private void ButtonAddWarPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarPlane));
- private void ButtonAddAirFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirFighter));
- ///
- /// Получение цвета
- ///
- /// Генератор случайных чисел
- ///
- 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)
{
diff --git a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.Designer.cs
index 9674aca..2394a96 100644
--- a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.Designer.cs
+++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.Designer.cs
@@ -33,29 +33,31 @@
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
- panelGray = new Panel();
+ panelGrey = new Panel();
panelBlue = new Panel();
panelWhite = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxAdditionalWing = new CheckBox();
checkBoxRocket = new CheckBox();
- numericUpDownWheight = new NumericUpDown();
+ numericUpDownWeight = new NumericUpDown();
labelWheight = new Label();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
- label = new Label();
+ labelModifiedObject = new Label();
labelSimpleObject = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
- panelObject = new Panel();
+ PanelObject = new Panel();
+ labelAdditionalColor = new Label();
+ labelBodyColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColor.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)numericUpDownWheight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
- panelObject.SuspendLayout();
+ PanelObject.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
@@ -63,16 +65,18 @@
groupBoxConfig.Controls.Add(groupBoxColor);
groupBoxConfig.Controls.Add(checkBoxAdditionalWing);
groupBoxConfig.Controls.Add(checkBoxRocket);
- groupBoxConfig.Controls.Add(numericUpDownWheight);
+ groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(labelWheight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelSpeed);
- groupBoxConfig.Controls.Add(label);
+ groupBoxConfig.Controls.Add(labelModifiedObject);
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Dock = DockStyle.Left;
groupBoxConfig.Location = new Point(0, 0);
+ groupBoxConfig.Margin = new Padding(3, 2, 3, 2);
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.TabStop = false;
groupBoxConfig.Text = "Параметры";
@@ -82,14 +86,16 @@
groupBoxColor.Controls.Add(panelPurple);
groupBoxColor.Controls.Add(panelYellow);
groupBoxColor.Controls.Add(panelBlack);
- groupBoxColor.Controls.Add(panelGray);
+ groupBoxColor.Controls.Add(panelGrey);
groupBoxColor.Controls.Add(panelBlue);
groupBoxColor.Controls.Add(panelWhite);
groupBoxColor.Controls.Add(panelGreen);
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.Size = new Size(335, 157);
+ groupBoxColor.Padding = new Padding(3, 2, 3, 2);
+ groupBoxColor.Size = new Size(293, 123);
groupBoxColor.TabIndex = 8;
groupBoxColor.TabStop = false;
groupBoxColor.Text = "Цвета";
@@ -97,73 +103,82 @@
// panelPurple
//
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.Size = new Size(58, 52);
+ panelPurple.Size = new Size(51, 39);
panelPurple.TabIndex = 7;
//
// panelYellow
//
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.Size = new Size(58, 52);
+ panelYellow.Size = new Size(51, 39);
panelYellow.TabIndex = 3;
//
// panelBlack
//
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.Size = new Size(58, 52);
+ panelBlack.Size = new Size(51, 39);
panelBlack.TabIndex = 6;
//
- // panelGray
+ // panelGrey
//
- panelGray.BackColor = Color.Gray;
- panelGray.Location = new Point(89, 99);
- panelGray.Name = "panelGray";
- panelGray.Size = new Size(58, 52);
- panelGray.TabIndex = 5;
+ panelGrey.BackColor = Color.Gray;
+ panelGrey.Location = new Point(78, 74);
+ panelGrey.Margin = new Padding(3, 2, 3, 2);
+ panelGrey.Name = "panelGrey";
+ panelGrey.Size = new Size(51, 39);
+ panelGrey.TabIndex = 5;
//
// panelBlue
//
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.Size = new Size(58, 52);
+ panelBlue.Size = new Size(51, 39);
panelBlue.TabIndex = 2;
//
// panelWhite
//
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.Size = new Size(58, 52);
+ panelWhite.Size = new Size(51, 39);
panelWhite.TabIndex = 4;
//
// panelGreen
//
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.Size = new Size(58, 52);
+ panelGreen.Size = new Size(51, 39);
panelGreen.TabIndex = 1;
//
// panelRed
//
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.Size = new Size(58, 52);
+ panelRed.Size = new Size(51, 39);
panelRed.TabIndex = 0;
//
// checkBoxAdditionalWing
//
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.Size = new Size(339, 24);
+ checkBoxAdditionalWing.Size = new Size(270, 19);
checkBoxAdditionalWing.TabIndex = 7;
checkBoxAdditionalWing.Text = "Признак наличия дополнительных крыльев";
checkBoxAdditionalWing.UseVisualStyleBackColor = true;
@@ -171,127 +186,167 @@
// checkBoxRocket
//
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.Size = new Size(196, 24);
+ checkBoxRocket.Size = new Size(156, 19);
checkBoxRocket.TabIndex = 6;
checkBoxRocket.Text = "Признак наличия ракет";
checkBoxRocket.UseVisualStyleBackColor = true;
//
- // numericUpDownWheight
+ // numericUpDownWeight
//
- numericUpDownWheight.Location = new Point(96, 63);
- numericUpDownWheight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
- numericUpDownWheight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
- numericUpDownWheight.Name = "numericUpDownWheight";
- numericUpDownWheight.Size = new Size(85, 27);
- numericUpDownWheight.TabIndex = 5;
- numericUpDownWheight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ numericUpDownWeight.Location = new Point(84, 47);
+ numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
+ numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
+ numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
+ numericUpDownWeight.Name = "numericUpDownWeight";
+ numericUpDownWeight.Size = new Size(74, 23);
+ numericUpDownWeight.TabIndex = 5;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWheight
//
labelWheight.AutoSize = true;
- labelWheight.Location = new Point(17, 70);
+ labelWheight.Location = new Point(15, 53);
labelWheight.Name = "labelWheight";
- labelWheight.Size = new Size(33, 20);
+ labelWheight.Size = new Size(26, 15);
labelWheight.TabIndex = 4;
labelWheight.Text = "Вес";
//
// 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.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
- numericUpDownSpeed.Size = new Size(85, 27);
+ numericUpDownSpeed.Size = new Size(74, 23);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
- labelSpeed.Location = new Point(17, 24);
+ labelSpeed.Location = new Point(15, 18);
labelSpeed.Name = "labelSpeed";
- labelSpeed.Size = new Size(73, 20);
+ labelSpeed.Size = new Size(59, 15);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость";
//
- // label
+ // labelModifiedObject
//
- label.BorderStyle = BorderStyle.FixedSingle;
- label.Location = new Point(459, 174);
- label.Name = "label";
- label.Size = new Size(106, 24);
- label.TabIndex = 1;
- label.Text = "Продвинутый";
- label.TextAlign = ContentAlignment.MiddleCenter;
- label.Click += labelObject_Click;
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(399, 233);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(93, 18);
+ labelModifiedObject.TabIndex = 1;
+ labelModifiedObject.Text = "Продвинутый";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
- labelSimpleObject.Location = new Point(357, 174);
+ labelSimpleObject.Location = new Point(304, 233);
labelSimpleObject.Name = "labelSimpleObject";
- labelSimpleObject.Size = new Size(96, 24);
+ labelSimpleObject.Size = new Size(84, 18);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
- labelSimpleObject.Click += labelObject_Click;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// 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.Size = new Size(181, 117);
+ pictureBoxObject.Size = new Size(176, 149);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
+ pictureBoxObject.DragDrop += PanelObject_DragDrop;
+ pictureBoxObject.DragEnter += PanelObject_DragEnter;
//
// 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.Size = new Size(94, 29);
+ buttonAdd.Size = new Size(82, 22);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
//
// 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.Size = new Size(94, 29);
+ buttonCancel.Size = new Size(82, 22);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отменить";
buttonCancel.UseVisualStyleBackColor = true;
//
- // panelObject
+ // PanelObject
//
- panelObject.AllowDrop = true;
- panelObject.Controls.Add(pictureBoxObject);
- panelObject.Location = new Point(591, 12);
- panelObject.Name = "panelObject";
- panelObject.Size = new Size(225, 161);
- panelObject.TabIndex = 4;
- panelObject.DragEnter += PanelObject_DragEnter;
+ PanelObject.AllowDrop = true;
+ PanelObject.Controls.Add(labelAdditionalColor);
+ PanelObject.Controls.Add(labelBodyColor);
+ PanelObject.Controls.Add(pictureBoxObject);
+ PanelObject.Location = new Point(517, 9);
+ PanelObject.Margin = new Padding(3, 2, 3, 2);
+ 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
//
- AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(819, 266);
- Controls.Add(panelObject);
+ ClientSize = new Size(717, 264);
+ Controls.Add(PanelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
+ Margin = new Padding(3, 2, 3, 2);
Name = "FormWarPlaneConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColor.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)numericUpDownWheight).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
- panelObject.ResumeLayout(false);
+ PanelObject.ResumeLayout(false);
ResumeLayout(false);
}
@@ -299,11 +354,11 @@
private GroupBox groupBoxConfig;
private Label labelSimpleObject;
- private Label label;
+ private Label labelModifiedObject;
private Label labelSpeed;
private NumericUpDown numericUpDownSpeed;
private Label labelWheight;
- private NumericUpDown numericUpDownWheight;
+ private NumericUpDown numericUpDownWeight;
private CheckBox checkBoxRocket;
private CheckBox checkBoxAdditionalWing;
private GroupBox groupBoxColor;
@@ -313,11 +368,13 @@
private Panel panelGreen;
private Panel panelPurple;
private Panel panelBlack;
- private Panel panelGray;
+ private Panel panelGrey;
private Panel panelWhite;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
- private Panel panelObject;
+ private Panel PanelObject;
+ private Label labelAdditionalColor;
+ private Label labelBodyColor;
}
}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.cs b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.cs
index 08e293e..71fc646 100644
--- a/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.cs
+++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.cs
@@ -1,4 +1,5 @@
using ProjectAirFighter.Drawning;
+using ProjectAirFighter.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -9,42 +10,166 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
-namespace ProjectAirFighter
+namespace ProjectAirFighter;
+
+///
+/// Форма конфигурации объекта
+///
+public partial class FormWarPlaneConfig : Form
{
- public partial class FormWarPlaneConfig : Form
+
+ ///
+ /// Объект - прорисовка военного самолета
+ ///
+ private DrawningWarPlane _warPlane = null;
+
+ ///
+ /// Событие для передачи объекта
+ ///
+ private event Action? WarPlaneDelegate;
+
+ ///
+ /// Конструктор
+ ///
+ public FormWarPlaneConfig()
{
- private DrawningWarPlane _warPlane;
- public FormWarPlaneConfig()
+ 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();
+
+
+ }
+
+
+ ///
+ /// Привязка внешнего метода к событию
+ ///
+ ///
+ public void AddEvent(Action warPlaneDelegate)
+ {
+ if (WarPlaneDelegate == null)
{
- InitializeComponent();
+ WarPlaneDelegate = warPlaneDelegate;
}
-
- ///
- ///
- ///
- ///
- ///
- private void labelObject_Click(object sender, EventArgs e)
+ else
{
- (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
-
- }
-
- ///
- ///
- ///
- ///
- ///
- private void PanelObject_DragEnter(object sender, DragEventArgs e)
- {
- if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
- {
- e.Effect = DragDropEffects.Copy;
- }
- else
- {
- e.Effect= DragDropEffects.None;
- }
+ WarPlaneDelegate += warPlaneDelegate;
}
}
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ ///
+
+ 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;
+ }
+
+ ///
+ /// Передаем информацию при нажатии Label
+ ///
+ ///
+ ///
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ private void PanelObject_DragEnter(object sender, DragEventArgs e)
+ {
+ e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
+ }
+
+
+ ///
+ /// Действие при приеме претаскиваеиой информации
+ ///
+ ///
+ ///
+ 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;
+ }
+
+ 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();
+ }
+ }
+
+
}
diff --git a/ProjectAirFighter/ProjectAirFighter/WarPlaneDelegate.cs b/ProjectAirFighter/ProjectAirFighter/WarPlaneDelegate.cs
new file mode 100644
index 0000000..45c3074
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/WarPlaneDelegate.cs
@@ -0,0 +1,6 @@
+using ProjectAirFighter.Drawning;
+
+
+namespace ProjectAirFighter;
+
+public delegate void WarPlaneDelegate(DrawningWarPlane warPlane);