diff --git a/ProjectAirFighter/ProjectAirFighter/AdNum.cs b/ProjectAirFighter/ProjectAirFighter/AdNum.cs deleted file mode 100644 index fb0c08c..0000000 --- a/ProjectAirFighter/ProjectAirFighter/AdNum.cs +++ /dev/null @@ -1,16 +0,0 @@ -using ProjectAirFighter.Drawning; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Metadata.Ecma335; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectAirFighter; - -public class AdNum - where T : DrawningAirFighter -{ - public void Nothing(){ - } -} diff --git a/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs index c6984d2..81fd5c2 100644 --- a/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs @@ -4,21 +4,6 @@ /// public class EntityAirFighter : EntityWarPlane { - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public double Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - /// /// Дополнительный цвет /// @@ -48,6 +33,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 new file mode 100644 index 0000000..2394a96 --- /dev/null +++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.Designer.cs @@ -0,0 +1,380 @@ +namespace ProjectAirFighter +{ + partial class FormWarPlaneConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + groupBoxConfig = new GroupBox(); + groupBoxColor = new GroupBox(); + panelPurple = new Panel(); + panelYellow = new Panel(); + panelBlack = new Panel(); + panelGrey = new Panel(); + panelBlue = new Panel(); + panelWhite = new Panel(); + panelGreen = new Panel(); + panelRed = new Panel(); + checkBoxAdditionalWing = new CheckBox(); + checkBoxRocket = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + labelWheight = new Label(); + numericUpDownSpeed = new NumericUpDown(); + labelSpeed = new Label(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + pictureBoxObject = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + PanelObject = new Panel(); + labelAdditionalColor = new Label(); + labelBodyColor = new Label(); + groupBoxConfig.SuspendLayout(); + groupBoxColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + PanelObject.SuspendLayout(); + SuspendLayout(); + // + // groupBoxConfig + // + groupBoxConfig.Controls.Add(groupBoxColor); + groupBoxConfig.Controls.Add(checkBoxAdditionalWing); + groupBoxConfig.Controls.Add(checkBoxRocket); + groupBoxConfig.Controls.Add(numericUpDownWeight); + groupBoxConfig.Controls.Add(labelWheight); + groupBoxConfig.Controls.Add(numericUpDownSpeed); + groupBoxConfig.Controls.Add(labelSpeed); + 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.Padding = new Padding(3, 2, 3, 2); + groupBoxConfig.Size = new Size(498, 264); + groupBoxConfig.TabIndex = 0; + groupBoxConfig.TabStop = false; + groupBoxConfig.Text = "Параметры"; + // + // groupBoxColor + // + groupBoxColor.Controls.Add(panelPurple); + groupBoxColor.Controls.Add(panelYellow); + groupBoxColor.Controls.Add(panelBlack); + groupBoxColor.Controls.Add(panelGrey); + groupBoxColor.Controls.Add(panelBlue); + groupBoxColor.Controls.Add(panelWhite); + groupBoxColor.Controls.Add(panelGreen); + groupBoxColor.Controls.Add(panelRed); + groupBoxColor.Location = new Point(192, 9); + groupBoxColor.Margin = new Padding(3, 2, 3, 2); + groupBoxColor.Name = "groupBoxColor"; + groupBoxColor.Padding = new Padding(3, 2, 3, 2); + groupBoxColor.Size = new Size(293, 123); + groupBoxColor.TabIndex = 8; + groupBoxColor.TabStop = false; + groupBoxColor.Text = "Цвета"; + // + // panelPurple + // + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(237, 74); + panelPurple.Margin = new Padding(3, 2, 3, 2); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(51, 39); + panelPurple.TabIndex = 7; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(237, 20); + panelYellow.Margin = new Padding(3, 2, 3, 2); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(51, 39); + panelYellow.TabIndex = 3; + // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(154, 74); + panelBlack.Margin = new Padding(3, 2, 3, 2); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(51, 39); + panelBlack.TabIndex = 6; + // + // panelGrey + // + 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(154, 20); + panelBlue.Margin = new Padding(3, 2, 3, 2); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(51, 39); + panelBlue.TabIndex = 2; + // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(5, 74); + panelWhite.Margin = new Padding(3, 2, 3, 2); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(51, 39); + panelWhite.TabIndex = 4; + // + // panelGreen + // + panelGreen.BackColor = Color.Green; + panelGreen.Location = new Point(78, 20); + panelGreen.Margin = new Padding(3, 2, 3, 2); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(51, 39); + panelGreen.TabIndex = 1; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(5, 20); + panelRed.Margin = new Padding(3, 2, 3, 2); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(51, 39); + panelRed.TabIndex = 0; + // + // checkBoxAdditionalWing + // + checkBoxAdditionalWing.AutoSize = true; + checkBoxAdditionalWing.Location = new Point(6, 234); + checkBoxAdditionalWing.Margin = new Padding(3, 2, 3, 2); + checkBoxAdditionalWing.Name = "checkBoxAdditionalWing"; + checkBoxAdditionalWing.Size = new Size(270, 19); + checkBoxAdditionalWing.TabIndex = 7; + checkBoxAdditionalWing.Text = "Признак наличия дополнительных крыльев"; + checkBoxAdditionalWing.UseVisualStyleBackColor = true; + // + // checkBoxRocket + // + checkBoxRocket.AutoSize = true; + checkBoxRocket.Location = new Point(6, 195); + checkBoxRocket.Margin = new Padding(3, 2, 3, 2); + checkBoxRocket.Name = "checkBoxRocket"; + checkBoxRocket.Size = new Size(156, 19); + checkBoxRocket.TabIndex = 6; + checkBoxRocket.Text = "Признак наличия ракет"; + checkBoxRocket.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + 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(15, 53); + labelWheight.Name = "labelWheight"; + labelWheight.Size = new Size(26, 15); + labelWheight.TabIndex = 4; + labelWheight.Text = "Вес"; + // + // numericUpDownSpeed + // + 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(74, 23); + numericUpDownSpeed.TabIndex = 3; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(15, 18); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(59, 15); + labelSpeed.TabIndex = 2; + labelSpeed.Text = "Скорость"; + // + // labelModifiedObject + // + 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(304, 233); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(84, 18); + labelSimpleObject.TabIndex = 0; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += LabelObject_MouseDown; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(12, 38); + pictureBoxObject.Margin = new Padding(3, 2, 3, 2); + pictureBoxObject.Name = "pictureBoxObject"; + 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(517, 236); + buttonAdd.Margin = new Padding(3, 2, 3, 2); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(82, 22); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(623, 236); + buttonCancel.Margin = new Padding(3, 2, 3, 2); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(82, 22); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + // + // PanelObject + // + 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(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + 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)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + PanelObject.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxConfig; + private Label labelSimpleObject; + private Label labelModifiedObject; + private Label labelSpeed; + private NumericUpDown numericUpDownSpeed; + private Label labelWheight; + private NumericUpDown numericUpDownWeight; + private CheckBox checkBoxRocket; + private CheckBox checkBoxAdditionalWing; + private GroupBox groupBoxColor; + private Panel panelRed; + private Panel panelYellow; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelPurple; + private Panel panelBlack; + private Panel panelGrey; + private Panel panelWhite; + private PictureBox pictureBoxObject; + private Button buttonAdd; + private Button buttonCancel; + 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 new file mode 100644 index 0000000..0ac8a84 --- /dev/null +++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.cs @@ -0,0 +1,178 @@ +using ProjectAirFighter.Drawning; +using ProjectAirFighter.Entities; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectAirFighter; + +/// +/// Форма конфигурации объекта +/// +public partial class FormWarPlaneConfig : Form +{ + + /// + /// Объект - прорисовка военного самолета + /// + private DrawningWarPlane _warPlane = null; + + /// + /// Событие для передачи объекта + /// + private event Action? WarPlaneDelegate; + + /// + /// Конструктор + /// + 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) + { + WarPlaneDelegate = warPlaneDelegate; + } + else + { + 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 (_warPlane?.EntityWarPlane is EntityAirFighter _airFighter) + { + 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/FormWarPlaneConfig.resx b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file 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);