diff --git a/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs b/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs
index 4297b43..c6f382f 100644
--- a/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs
+++ b/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs
@@ -111,7 +111,7 @@
this.labelRoundedEngines.TabIndex = 24;
this.labelRoundedEngines.Text = "Закругленный";
this.labelRoundedEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.labelRoundedEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelTypesOfEngines_MouseDown);
+ this.labelRoundedEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelsTypeOfEngines_MouseDown);
//
// labelRectEngines
//
@@ -122,7 +122,7 @@
this.labelRectEngines.TabIndex = 23;
this.labelRectEngines.Text = "Квадратный";
this.labelRectEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.labelRectEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelTypesOfEngines_MouseDown);
+ this.labelRectEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelsTypeOfEngines_MouseDown);
//
// labelArrowEngines
//
@@ -133,7 +133,7 @@
this.labelArrowEngines.TabIndex = 22;
this.labelArrowEngines.Text = "Стрелка";
this.labelArrowEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.labelArrowEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelTypesOfEngines_MouseDown);
+ this.labelArrowEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelsTypeOfEngines_MouseDown);
//
// numericUpDownCountEngines
//
@@ -147,7 +147,7 @@
this.numericUpDownCountEngines.Size = new System.Drawing.Size(79, 23);
this.numericUpDownCountEngines.TabIndex = 18;
this.numericUpDownCountEngines.Value = new decimal(new int[] {
- 9,
+ 2,
0,
0,
0});
@@ -371,6 +371,8 @@
this.labelTypesOfEngines.TabIndex = 3;
this.labelTypesOfEngines.Text = "Тип двигателей";
this.labelTypesOfEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelTypesOfEngines.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelTypesOfEngines_DragDrop);
+ this.labelTypesOfEngines.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelTypesOfEngines_DragEnter);
//
// labelDopColor
//
diff --git a/AirBomber/AirBomber/FormAirplaneConfig.cs b/AirBomber/AirBomber/FormAirplaneConfig.cs
index 8df327d..9359022 100644
--- a/AirBomber/AirBomber/FormAirplaneConfig.cs
+++ b/AirBomber/AirBomber/FormAirplaneConfig.cs
@@ -7,6 +7,7 @@ namespace AirBomber
///
public partial class FormAirplaneConfig : Form
{
+ private Type _currTypeEngines = typeof(DrawningAirplaneEngines);
///
/// Переменная-выбранная самолет
///
@@ -181,8 +182,12 @@ namespace AirBomber
EventAddAirplane?.Invoke(_airplane);
Close();
}
-
- private void labelTypesOfEngines_MouseDown(object sender, MouseEventArgs e)
+ ///
+ /// Создание DragAndDrop перемещения по нажатию мыши
+ ///
+ ///
+ ///
+ private void labelsTypeOfEngines_MouseDown(object sender, MouseEventArgs e)
{
string text = ((Label)sender)?.Text ?? string.Empty;
IAirplaneEngines typesOfEngines;
@@ -200,7 +205,26 @@ namespace AirBomber
default:
return;
}
+ _currTypeEngines = typesOfEngines.GetType();
(sender as Label).DoDragDrop(typesOfEngines, DragDropEffects.Move | DragDropEffects.Copy);
}
+
+ private void labelTypesOfEngines_DragDrop(object sender, DragEventArgs e)
+ {
+ var engines = (IAirplaneEngines)e.Data.GetData(_currTypeEngines);
+ engines.CountEngines = _airplane.DrawningEngines.CountEngines;
+ if (_airplane is DrawningAirBomber)
+ {
+ var a = (EntityAirBomber)_airplane.Airplane;
+ _airplane = new DrawningAirBomber(a.Speed, a.Weight, a.BodyColor, a.DopColor, a.HasBombs, a.HasFuelTanks, engines);
+ }
+ else if (_airplane is DrawningAirplane)
+ {
+ _airplane = new DrawningAirplane(_airplane.Airplane.Speed, _airplane.Airplane.Weight, _airplane.Airplane.BodyColor, engines);
+ }
+ DrawAirplane();
+ }
+
+ private void labelTypesOfEngines_DragEnter(object sender, DragEventArgs e) => setDragEffect(e, _currTypeEngines, _airplane != null);
}
}
\ No newline at end of file