diff --git a/AirFighter/AirFighter/Entities/EntityAirFighter.cs b/AirFighter/AirFighter/Entities/EntityAirFighter.cs index 85d17d8..c377bfd 100644 --- a/AirFighter/AirFighter/Entities/EntityAirFighter.cs +++ b/AirFighter/AirFighter/Entities/EntityAirFighter.cs @@ -7,7 +7,7 @@ public class EntityAirFighter : EntityMilitaryAircraft { public Color AdditionalColor { get; private set; } - public void ChooseAdditionalColor(Color additionalColor) + public void SetAdditionalColor(Color additionalColor) { AdditionalColor = additionalColor; } diff --git a/AirFighter/AirFighter/Entities/EntityMilitaryAircraft.cs b/AirFighter/AirFighter/Entities/EntityMilitaryAircraft.cs index 09acc5f..5887593 100644 --- a/AirFighter/AirFighter/Entities/EntityMilitaryAircraft.cs +++ b/AirFighter/AirFighter/Entities/EntityMilitaryAircraft.cs @@ -11,7 +11,7 @@ public class EntityMilitaryAircraft public Color BodyColor { get; private set; } - public void ChooseBodyColor(Color bodyColor) + public void SetBodyColor(Color bodyColor) { BodyColor = bodyColor; } diff --git a/AirFighter/AirFighter/FormMilitaryAircraftConfig.Designer.cs b/AirFighter/AirFighter/FormMilitaryAircraftConfig.Designer.cs index b9f959e..754c7ef 100644 --- a/AirFighter/AirFighter/FormMilitaryAircraftConfig.Designer.cs +++ b/AirFighter/AirFighter/FormMilitaryAircraftConfig.Designer.cs @@ -163,21 +163,21 @@ // checkBoxRockets // checkBoxRockets.AutoSize = true; - checkBoxRockets.Location = new Point(12, 154); + checkBoxRockets.Location = new Point(6, 154); checkBoxRockets.Name = "checkBoxRockets"; - checkBoxRockets.Size = new Size(318, 24); + checkBoxRockets.Size = new Size(339, 24); checkBoxRockets.TabIndex = 7; - checkBoxRockets.Text = "Признак наличия дополнительных ракет"; + checkBoxRockets.Text = "Признак наличия дополнительных крыльев"; checkBoxRockets.UseVisualStyleBackColor = true; // // checkBoxWings // checkBoxWings.AutoSize = true; - checkBoxWings.Location = new Point(12, 124); + checkBoxWings.Location = new Point(6, 124); checkBoxWings.Name = "checkBoxWings"; - checkBoxWings.Size = new Size(339, 24); + checkBoxWings.Size = new Size(318, 24); checkBoxWings.TabIndex = 6; - checkBoxWings.Text = "Признак наличия дополнительных крыльев"; + checkBoxWings.Text = "Признак наличия дополнительных ракет"; checkBoxWings.UseVisualStyleBackColor = true; // // numericUpDownWeight @@ -282,27 +282,29 @@ // // labelAdditionalColor // + labelAdditionalColor.AllowDrop = true; labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; - labelAdditionalColor.Location = new Point(100, 12); + labelAdditionalColor.Location = new Point(100, 9); labelAdditionalColor.Name = "labelAdditionalColor"; - labelAdditionalColor.Size = new Size(88, 24); + labelAdditionalColor.Size = new Size(88, 36); labelAdditionalColor.TabIndex = 2; labelAdditionalColor.Text = "Доп. цвет"; labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; - labelAdditionalColor.DragDrop += LabelColor_DragDrop; - labelAdditionalColor.DragEnter += LabelColor_DragEnter; + labelAdditionalColor.DragDrop += LabelColors_DragDrop; + labelAdditionalColor.DragEnter += LabelColors_DragEnter; // // labelBodyColor // + labelBodyColor.AllowDrop = true; labelBodyColor.BorderStyle = BorderStyle.FixedSingle; - labelBodyColor.Location = new Point(3, 12); + labelBodyColor.Location = new Point(3, 9); labelBodyColor.Name = "labelBodyColor"; - labelBodyColor.Size = new Size(88, 24); + labelBodyColor.Size = new Size(88, 36); labelBodyColor.TabIndex = 1; labelBodyColor.Text = "Цвет"; labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; - labelBodyColor.DragDrop += LabelColor_DragDrop; - labelBodyColor.DragEnter += LabelColor_DragEnter; + labelBodyColor.DragDrop += LabelColors_DragDrop; + labelBodyColor.DragEnter += LabelColors_DragEnter; // // FormMilitaryAircraftConfig // diff --git a/AirFighter/AirFighter/FormMilitaryAircraftConfig.cs b/AirFighter/AirFighter/FormMilitaryAircraftConfig.cs index d598be3..d686449 100644 --- a/AirFighter/AirFighter/FormMilitaryAircraftConfig.cs +++ b/AirFighter/AirFighter/FormMilitaryAircraftConfig.cs @@ -41,14 +41,7 @@ public partial class FormMilitaryAircraftConfig : Form /// public void AddEvent(Action militaryAircraftDelegate) { - if (MilitaryAircraftDelegate == null) - { - MilitaryAircraftDelegate = militaryAircraftDelegate; - } - else - { - MilitaryAircraftDelegate += militaryAircraftDelegate; - } + MilitaryAircraftDelegate += militaryAircraftDelegate; } /// @@ -71,8 +64,6 @@ public partial class FormMilitaryAircraftConfig : Form /// private void LabelObject_MouseDown(object sender, MouseEventArgs e) { - //var label = sender as Label; - //label.DoDragDrop(label.Name, DragDropEffects.Move); (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy); } @@ -83,14 +74,7 @@ public partial class FormMilitaryAircraftConfig : Form /// private void PanelObject_DragEnter(object sender, DragEventArgs e) { - if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } + e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None; } /// @@ -118,31 +102,22 @@ public partial class FormMilitaryAircraftConfig : Form /// /// /// 2 - private void Panel_MouseDown(object? sender, MouseEventArgs e) + private void Panel_MouseDown(object sender, MouseEventArgs e) { (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); } - // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) + // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) - /// - /// Проверка получаемой информации (ее типа на соответствие требуемому) - /// - /// - /// - private void LabelColor_DragEnter(object sender, DragEventArgs e) + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + private void LabelColors_DragEnter(object sender, DragEventArgs e) { - //if (e.Data?.GetDataPresent(typeof(Color)) ?? false) - //{ - // e.Effect = DragDropEffects.Copy; - //} - //else - //{ - // e.Effect = DragDropEffects.None; - //} - e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None; } @@ -151,27 +126,28 @@ public partial class FormMilitaryAircraftConfig : Form /// /// /// - private void LabelColor_DragDrop(object sender, DragEventArgs e) + private void LabelColors_DragDrop(object sender, DragEventArgs e) { if (_militaryAircraft == null) { return; } Label label = (Label)sender; - switch (((Label)sender).Name) + Color newColor = (Color)e.Data.GetData(typeof(Color).ToString()); + switch (label.Name) { case "labelBodyColor": - _militaryAircraft.EntityMilitaryAircraft.ChooseBodyColor((Color)e.Data.GetData(typeof(Color))); + _militaryAircraft.EntityMilitaryAircraft.SetBodyColor(newColor); + DrawObject(); break; case "labelAdditionalColor": if (_militaryAircraft is DrawningAirFighter) { - return; + (_militaryAircraft.EntityMilitaryAircraft as EntityAirFighter).SetAdditionalColor(newColor); + DrawObject(); } - (_militaryAircraft.EntityMilitaryAircraft as EntityAirFighter).ChooseAdditionalColor((Color)e.Data.GetData(typeof(Color))); break; } - DrawObject(); }