Релизована логика изменения типов двигателей у самолета
This commit is contained in:
parent
639df36fd9
commit
0a5d9819bc
10
AirBomber/AirBomber/FormAirplaneConfig.Designer.cs
generated
10
AirBomber/AirBomber/FormAirplaneConfig.Designer.cs
generated
@ -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
|
||||
//
|
||||
|
@ -7,6 +7,7 @@ namespace AirBomber
|
||||
/// </summary>
|
||||
public partial class FormAirplaneConfig : Form
|
||||
{
|
||||
private Type _currTypeEngines = typeof(DrawningAirplaneEngines);
|
||||
/// <summary>
|
||||
/// Переменная-выбранная самолет
|
||||
/// </summary>
|
||||
@ -181,8 +182,12 @@ namespace AirBomber
|
||||
EventAddAirplane?.Invoke(_airplane);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void labelTypesOfEngines_MouseDown(object sender, MouseEventArgs e)
|
||||
/// <summary>
|
||||
/// Создание DragAndDrop перемещения по нажатию мыши
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user