diff --git a/AirBomber/ClassDelegate.cs b/AirBomber/ClassDelegate.cs index 5a3db87..4446ad2 100644 --- a/AirBomber/ClassDelegate.cs +++ b/AirBomber/ClassDelegate.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using AirBomber.Drawnings; +using AirBomber.Drawnings; namespace AirBomber; -public delegate DrawningAirPlane ClassDelegate(); +/// +/// Делегар передачи объекта класса прорисовки +/// +/// +public delegate void AirPlaneDelegate(DrawningAirPlane airplane); diff --git a/AirBomber/Entities/EntityAirBomber.cs b/AirBomber/Entities/EntityAirBomber.cs index 925d6ea..370aaf2 100644 --- a/AirBomber/Entities/EntityAirBomber.cs +++ b/AirBomber/Entities/EntityAirBomber.cs @@ -9,6 +9,9 @@ namespace AirBomber.Entities public class EntityAirBomber : EntityAirPlane { public Color AdditionalColor { get; private set; } + + public void SetAdditionalColor(Color color) => AdditionalColor = color; + /// /// Признак (опция) наличия бомб /// diff --git a/AirBomber/Entities/EntityAirPlane.cs b/AirBomber/Entities/EntityAirPlane.cs index 7417b42..f358d6c 100644 --- a/AirBomber/Entities/EntityAirPlane.cs +++ b/AirBomber/Entities/EntityAirPlane.cs @@ -18,6 +18,9 @@ public class EntityAirPlane /// Вес /// public double Weight { get; private set; } + + public void SetBodyColor(Color color) => BodyColor = color; + /// /// Основной цвет /// diff --git a/AirBomber/FormAirPlaneCollection.cs b/AirBomber/FormAirPlaneCollection.cs index 3ba1ce8..805f200 100644 --- a/AirBomber/FormAirPlaneCollection.cs +++ b/AirBomber/FormAirPlaneCollection.cs @@ -47,40 +47,7 @@ namespace AirBomber /// Создание объекта класса-перемещения /// /// Тип создаваемого объекта - private void CreateObject(string type) - { - if (_company == null) - { - return; - } - DrawningAirPlane _drawningAirPlane; - Random random = new(); - switch (type) - { - case nameof(DrawningAirPlane): - _drawningAirPlane = new DrawningAirPlane(random.Next(30, 70), random.Next(100, 500), - GetColor(random)); - break; - case nameof(DrawningAirBomber): - _drawningAirPlane = new DrawningAirBomber(random.Next(30, 70), random.Next(100, 500), - GetColor(random), GetColor(random), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - break; - default: - return; - - } - - if (_company + _drawningAirPlane != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _company.Show(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + /// /// Добавление самолета @@ -90,10 +57,33 @@ namespace AirBomber private void buttonAddAirPlane_Click(object sender, EventArgs e) { FormAirPlaneConfig form = new(); + //TODO передать метод form.Show(); + form.AddEvent(SetAirPlane); } - + /// + /// Добавление самолета в коллекцию + /// + /// + private void SetAirPlane(DrawningAirPlane airplane) + { + if (_company == null || airplane == null) + { + return; + } + + if (_company + airplane != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _company.Show(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + + } /// /// Получение цвета diff --git a/AirBomber/FormAirPlaneConfig.Designer.cs b/AirBomber/FormAirPlaneConfig.Designer.cs index 45247b9..71dd09a 100644 --- a/AirBomber/FormAirPlaneConfig.Designer.cs +++ b/AirBomber/FormAirPlaneConfig.Designer.cs @@ -31,11 +31,11 @@ groupBoxConfig = new GroupBox(); groupBoxColors = new GroupBox(); panelPurple = new Panel(); + panelYellow = new Panel(); panelBlack = new Panel(); panelGray = new Panel(); - panelWhite = new Panel(); - panelYellow = new Panel(); panelBlue = new Panel(); + panelWhite = new Panel(); panelGreen = new Panel(); panelRed = new Panel(); checkBoxFuelTanks = new CheckBox(); @@ -46,11 +46,11 @@ labelSpeed = new Label(); labelModifiedObject = new Label(); labelSimpleObject = new Label(); - labelBodyColor = new Label(); pictureBoxObject = new PictureBox(); buttonAdd = new Button(); buttonCancel = new Button(); panelObject = new Panel(); + labelBodyColor = new Label(); labelAdditionalColor = new Label(); groupBoxConfig.SuspendLayout(); groupBoxColors.SuspendLayout(); @@ -73,8 +73,10 @@ groupBoxConfig.Controls.Add(labelSimpleObject); groupBoxConfig.Dock = DockStyle.Left; groupBoxConfig.Location = new Point(0, 0); + groupBoxConfig.Margin = new Padding(3, 4, 3, 4); groupBoxConfig.Name = "groupBoxConfig"; - groupBoxConfig.Size = new Size(682, 342); + groupBoxConfig.Padding = new Padding(3, 4, 3, 4); + groupBoxConfig.Size = new Size(629, 346); groupBoxConfig.TabIndex = 0; groupBoxConfig.TabStop = false; groupBoxConfig.Text = "Параметры"; @@ -82,149 +84,163 @@ // groupBoxColors // groupBoxColors.Controls.Add(panelPurple); + groupBoxColors.Controls.Add(panelYellow); groupBoxColors.Controls.Add(panelBlack); groupBoxColors.Controls.Add(panelGray); - groupBoxColors.Controls.Add(panelWhite); - groupBoxColors.Controls.Add(panelYellow); groupBoxColors.Controls.Add(panelBlue); + groupBoxColors.Controls.Add(panelWhite); groupBoxColors.Controls.Add(panelGreen); groupBoxColors.Controls.Add(panelRed); - groupBoxColors.Location = new Point(285, 12); + groupBoxColors.Location = new Point(360, 16); + groupBoxColors.Margin = new Padding(3, 4, 3, 4); groupBoxColors.Name = "groupBoxColors"; - groupBoxColors.Size = new Size(221, 127); - groupBoxColors.TabIndex = 8; + groupBoxColors.Padding = new Padding(3, 4, 3, 4); + groupBoxColors.Size = new Size(259, 149); + groupBoxColors.TabIndex = 11; groupBoxColors.TabStop = false; groupBoxColors.Text = "Цвета"; // // panelPurple // panelPurple.BackColor = Color.Purple; - panelPurple.Location = new Point(175, 81); + panelPurple.Location = new Point(201, 88); + panelPurple.Margin = new Padding(3, 4, 3, 4); panelPurple.Name = "panelPurple"; - panelPurple.Size = new Size(39, 40); - panelPurple.TabIndex = 1; - // - // panelBlack - // - panelBlack.BackColor = Color.Black; - panelBlack.Location = new Point(119, 81); - panelBlack.Name = "panelBlack"; - panelBlack.Size = new Size(39, 40); - panelBlack.TabIndex = 1; - // - // panelGray - // - panelGray.BackColor = Color.Gray; - panelGray.Location = new Point(63, 81); - panelGray.Name = "panelGray"; - panelGray.Size = new Size(39, 40); - panelGray.TabIndex = 1; - // - // panelWhite - // - panelWhite.BackColor = Color.White; - panelWhite.Location = new Point(7, 81); - panelWhite.Name = "panelWhite"; - panelWhite.Size = new Size(39, 40); - panelWhite.TabIndex = 9; + panelPurple.Size = new Size(39, 45); + panelPurple.TabIndex = 3; // // panelYellow // panelYellow.BackColor = Color.Yellow; - panelYellow.Location = new Point(175, 28); + panelYellow.Location = new Point(201, 29); + panelYellow.Margin = new Padding(3, 4, 3, 4); panelYellow.Name = "panelYellow"; - panelYellow.Size = new Size(39, 40); + panelYellow.Size = new Size(39, 45); panelYellow.TabIndex = 1; // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(137, 88); + panelBlack.Margin = new Padding(3, 4, 3, 4); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(39, 45); + panelBlack.TabIndex = 4; + // + // panelGray + // + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(77, 88); + panelGray.Margin = new Padding(3, 4, 3, 4); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(39, 45); + panelGray.TabIndex = 5; + // // panelBlue // panelBlue.BackColor = Color.Blue; - panelBlue.Location = new Point(119, 28); + panelBlue.Location = new Point(137, 29); + panelBlue.Margin = new Padding(3, 4, 3, 4); panelBlue.Name = "panelBlue"; - panelBlue.Size = new Size(39, 40); + panelBlue.Size = new Size(39, 45); panelBlue.TabIndex = 1; // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(17, 88); + panelWhite.Margin = new Padding(3, 4, 3, 4); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(39, 45); + panelWhite.TabIndex = 2; + // // panelGreen // panelGreen.BackColor = Color.Green; - panelGreen.Location = new Point(63, 28); + panelGreen.Location = new Point(77, 29); + panelGreen.Margin = new Padding(3, 4, 3, 4); panelGreen.Name = "panelGreen"; - panelGreen.Size = new Size(39, 40); + panelGreen.Size = new Size(39, 45); panelGreen.TabIndex = 1; // // panelRed // panelRed.BackColor = Color.Red; - panelRed.Location = new Point(7, 28); + panelRed.Location = new Point(17, 29); + panelRed.Margin = new Padding(3, 4, 3, 4); panelRed.Name = "panelRed"; - panelRed.Size = new Size(39, 40); + panelRed.Size = new Size(39, 45); panelRed.TabIndex = 0; panelRed.MouseDown += Panel_MouseDown; // // checkBoxFuelTanks // checkBoxFuelTanks.AutoSize = true; - checkBoxFuelTanks.Location = new Point(12, 178); + checkBoxFuelTanks.Location = new Point(14, 237); + checkBoxFuelTanks.Margin = new Padding(3, 4, 3, 4); checkBoxFuelTanks.Name = "checkBoxFuelTanks"; - checkBoxFuelTanks.Size = new Size(319, 19); + checkBoxFuelTanks.Size = new Size(312, 24); checkBoxFuelTanks.TabIndex = 7; - checkBoxFuelTanks.Text = "Признак наличия дополнительных топливных баков"; + checkBoxFuelTanks.Text = "Признак наличия доп. топливных баков"; checkBoxFuelTanks.UseVisualStyleBackColor = true; // // checkBoxBombs // checkBoxBombs.AutoSize = true; - checkBoxBombs.Location = new Point(12, 132); + checkBoxBombs.Location = new Point(14, 176); + checkBoxBombs.Margin = new Padding(3, 4, 3, 4); checkBoxBombs.Name = "checkBoxBombs"; - checkBoxBombs.Size = new Size(156, 19); + checkBoxBombs.Size = new Size(196, 24); checkBoxBombs.TabIndex = 6; checkBoxBombs.Text = "Признак наличия бомб"; checkBoxBombs.UseVisualStyleBackColor = true; // // numericUpDownWeight // - numericUpDownWeight.Location = new Point(80, 82); + numericUpDownWeight.Location = new Point(91, 109); + numericUpDownWeight.Margin = new Padding(3, 4, 3, 4); 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(88, 23); + numericUpDownWeight.Size = new Size(101, 27); numericUpDownWeight.TabIndex = 5; numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); // // labelWeight // labelWeight.AutoSize = true; - labelWeight.Location = new Point(12, 84); + labelWeight.Location = new Point(14, 112); labelWeight.Name = "labelWeight"; - labelWeight.Size = new Size(29, 15); + labelWeight.Size = new Size(36, 20); labelWeight.TabIndex = 4; labelWeight.Text = "Вес:"; // // numericUpDownSpeed // - numericUpDownSpeed.Location = new Point(80, 38); + numericUpDownSpeed.Location = new Point(91, 51); + numericUpDownSpeed.Margin = new Padding(3, 4, 3, 4); 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(88, 23); + numericUpDownSpeed.Size = new Size(101, 27); numericUpDownSpeed.TabIndex = 3; numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); // // labelSpeed // labelSpeed.AutoSize = true; - labelSpeed.Location = new Point(12, 40); + labelSpeed.Location = new Point(14, 53); labelSpeed.Name = "labelSpeed"; - labelSpeed.Size = new Size(62, 15); + labelSpeed.Size = new Size(76, 20); labelSpeed.TabIndex = 2; labelSpeed.Text = "Скорость:"; // // labelModifiedObject // labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; - labelModifiedObject.Location = new Point(486, 157); + labelModifiedObject.Location = new Point(466, 222); labelModifiedObject.Name = "labelModifiedObject"; - labelModifiedObject.Size = new Size(134, 40); + labelModifiedObject.Size = new Size(117, 53); labelModifiedObject.TabIndex = 1; labelModifiedObject.Text = "Продвинутый"; labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; @@ -233,37 +249,29 @@ // labelSimpleObject // labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; - labelSimpleObject.Location = new Point(337, 157); + labelSimpleObject.Location = new Point(330, 222); labelSimpleObject.Name = "labelSimpleObject"; - labelSimpleObject.Size = new Size(134, 40); + labelSimpleObject.Size = new Size(117, 53); labelSimpleObject.TabIndex = 0; labelSimpleObject.Text = "Простой"; labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; labelSimpleObject.MouseDown += labelObject_MouseDown; // - // labelBodyColor - // - labelBodyColor.BorderStyle = BorderStyle.FixedSingle; - labelBodyColor.Location = new Point(19, 15); - labelBodyColor.Name = "labelBodyColor"; - labelBodyColor.Size = new Size(69, 40); - labelBodyColor.TabIndex = 9; - labelBodyColor.Text = "Цвет"; - labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; - // // pictureBoxObject // - pictureBoxObject.Location = new Point(19, 81); + pictureBoxObject.Location = new Point(15, 69); + pictureBoxObject.Margin = new Padding(3, 4, 3, 4); pictureBoxObject.Name = "pictureBoxObject"; - pictureBoxObject.Size = new Size(169, 151); + pictureBoxObject.Size = new Size(194, 161); pictureBoxObject.TabIndex = 1; pictureBoxObject.TabStop = false; // // buttonAdd // - buttonAdd.Location = new Point(701, 271); + buttonAdd.Location = new Point(672, 254); + buttonAdd.Margin = new Padding(3, 4, 3, 4); buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(88, 40); + buttonAdd.Size = new Size(101, 53); buttonAdd.TabIndex = 2; buttonAdd.Text = "Добавить"; buttonAdd.UseVisualStyleBackColor = true; @@ -271,9 +279,10 @@ // // buttonCancel // - buttonCancel.Location = new Point(812, 271); + buttonCancel.Location = new Point(786, 254); + buttonCancel.Margin = new Padding(3, 4, 3, 4); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(89, 40); + buttonCancel.Size = new Size(102, 53); buttonCancel.TabIndex = 3; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; @@ -281,35 +290,53 @@ // panelObject // panelObject.AllowDrop = true; - panelObject.Controls.Add(labelAdditionalColor); panelObject.Controls.Add(labelBodyColor); + panelObject.Controls.Add(labelAdditionalColor); panelObject.Controls.Add(pictureBoxObject); - panelObject.Location = new Point(701, 12); + panelObject.Location = new Point(679, 0); + panelObject.Margin = new Padding(3, 4, 3, 4); panelObject.Name = "panelObject"; - panelObject.Size = new Size(200, 253); + panelObject.Size = new Size(222, 246); panelObject.TabIndex = 4; - panelObject.DragDrop += panelObject_DragDrop; - panelObject.DragEnter += panelObject_DragEnter; + panelObject.DragDrop += PanelObject_DragDrop; + panelObject.DragEnter += PanelObject_DragEnter; + // + // labelBodyColor + // + labelBodyColor.AllowDrop = true; + labelBodyColor.BorderStyle = BorderStyle.FixedSingle; + labelBodyColor.Location = new Point(15, 12); + labelBodyColor.Name = "labelBodyColor"; + labelBodyColor.Size = new Size(85, 43); + labelBodyColor.TabIndex = 2; + labelBodyColor.Text = "Цвет"; + labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; + labelBodyColor.DragDrop += LabelColors_DragDrop; + labelBodyColor.DragEnter += LabelColors_DragEnter; // // labelAdditionalColor // + labelAdditionalColor.AllowDrop = true; labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; - labelAdditionalColor.Location = new Point(111, 15); + labelAdditionalColor.Location = new Point(123, 12); labelAdditionalColor.Name = "labelAdditionalColor"; - labelAdditionalColor.Size = new Size(77, 40); - labelAdditionalColor.TabIndex = 10; + labelAdditionalColor.Size = new Size(85, 43); + labelAdditionalColor.TabIndex = 3; labelAdditionalColor.Text = "Доп. Цвет"; labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop; + labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter; // // FormAirPlaneConfig // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(913, 342); + ClientSize = new Size(909, 346); Controls.Add(panelObject); Controls.Add(buttonCancel); Controls.Add(buttonAdd); Controls.Add(groupBoxConfig); + Margin = new Padding(3, 4, 3, 4); Name = "FormAirPlaneConfig"; Text = "Создание объекта"; groupBoxConfig.ResumeLayout(false); @@ -333,20 +360,20 @@ private NumericUpDown numericUpDownSpeed; private Label labelSpeed; private CheckBox checkBoxFuelTanks; - private GroupBox groupBoxColors; - private Panel panelRed; - private Panel panelYellow; - private Panel panelBlue; - private Panel panelGreen; - private Panel panelPurple; - private Panel panelBlack; - private Panel panelGray; - private Panel panelWhite; private PictureBox pictureBoxObject; private Button buttonAdd; private Button buttonCancel; private Panel panelObject; - private Label labelBodyColor; private Label labelAdditionalColor; + private GroupBox groupBoxColors; + private Panel panelPurple; + private Panel panelYellow; + private Panel panelBlack; + private Panel panelGray; + private Panel panelBlue; + private Panel panelWhite; + private Panel panelGreen; + private Panel panelRed; + private Label labelBodyColor; } } \ No newline at end of file diff --git a/AirBomber/FormAirPlaneConfig.cs b/AirBomber/FormAirPlaneConfig.cs index f603fe1..1d6b0d1 100644 --- a/AirBomber/FormAirPlaneConfig.cs +++ b/AirBomber/FormAirPlaneConfig.cs @@ -1,13 +1,5 @@ using AirBomber.Drawnings; -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; +using AirBomber.Entities; namespace AirBomber; @@ -16,17 +8,23 @@ namespace AirBomber; /// public partial class FormAirPlaneConfig : Form { - /// /// Объект - прорисовка самолета /// - private DrawningAirPlane _airplane = null; + private DrawningAirPlane? _airplane = null; + + /// + /// События для передачи объекта + /// + private event Action AirPlaneDelegate; /// /// Конструктор /// public FormAirPlaneConfig() { + InitializeComponent(); + panelRed.MouseDown += Panel_MouseDown; panelGreen.MouseDown += Panel_MouseDown; panelBlue.MouseDown += Panel_MouseDown; @@ -36,47 +34,57 @@ public partial class FormAirPlaneConfig : Form panelBlack.MouseDown += Panel_MouseDown; panelPurple.MouseDown += Panel_MouseDown; - InitializeComponent(); + buttonCancel.Click += (sender, e) => Close(); } /// - /// Прорисовка объекта + /// Привязка внешнего метода к событию /// - private void DrawObject() + /// + public void AddEvent(Action airplaneDelegate) { - Bitmap bpm = new(pictureBoxObject.Width, pictureBoxObject.Height); - Graphics g = Graphics.FromImage(bpm); + AirPlaneDelegate += airplaneDelegate; + } + + /// + /// Прорисовка объекта + /// + private void DrawObject() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); _airplane?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); _airplane?.SetPosition(5, 5); - pictureBoxObject.Image = bpm; + _airplane?.DrawTransport(gr); + pictureBoxObject.Image = bmp; } /// - /// Передаем информацию при нажатии на Label - /// - /// - /// + /// Передаем информацию при нажатии на 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) + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + 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) + /// Действия при приеме перетаскиваемой информации + /// + /// + /// + private void PanelObject_DragDrop(object sender, DragEventArgs e) { switch (e.Data?.GetData(DataFormats.Text)?.ToString()) { @@ -88,22 +96,80 @@ public partial class FormAirPlaneConfig : Form Color.Black, checkBoxBombs.Checked, checkBoxFuelTanks.Checked); break; } - + labelBodyColor.BackColor = Color.Empty; + labelAdditionalColor.BackColor = Color.Empty; DrawObject(); } /// - /// Передаем информацию при нажатии на Panel - /// - /// - /// - private void Panel_MouseDown(object? sender, MouseEventArgs e) + /// Передаем информацию при нажатии на Panel + /// + /// + /// + private void Panel_MouseDown(object? sender, MouseEventArgs e) { - + // TODO отправка цвета в Drag&Drop + (sender as Control)?.DoDragDrop((sender as Control)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy); } - private void ButtonAdd_Click(object sender, EventArgs e) + // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) + 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 labelBodyColor_DragDrop(object sender, DragEventArgs e) + { + if (_airplane != null) + { + _airplane.EntityAirPlane.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + DrawObject(); + } + } + + private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) + { + if (_airplane is DrawningAirBomber) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } + + private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_airplane?.EntityAirPlane is EntityAirBomber _airbomber) + { + _airbomber.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); + } + DrawObject(); + + } + /// + /// Передача объекта + /// + /// + /// + private void ButtonAdd_Click(object sender, EventArgs e) + { + if (_airplane != null) + { + AirPlaneDelegate?.Invoke(_airplane); + Close(); + } } } + diff --git a/AirBomber/FormAirPlaneConfig.resx b/AirBomber/FormAirPlaneConfig.resx index a395bff..af32865 100644 --- a/AirBomber/FormAirPlaneConfig.resx +++ b/AirBomber/FormAirPlaneConfig.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object]