Изменена отправка данных по DragAndDrop

This commit is contained in:
Данияр Аглиуллов 2022-10-19 17:21:13 +04:00
parent 0a5d9819bc
commit 67dde9fb10

View File

@ -7,7 +7,6 @@ namespace AirBomber
/// </summary> /// </summary>
public partial class FormAirplaneConfig : Form public partial class FormAirplaneConfig : Form
{ {
private Type _currTypeEngines = typeof(DrawningAirplaneEngines);
/// <summary> /// <summary>
/// Переменная-выбранная самолет /// Переменная-выбранная самолет
/// </summary> /// </summary>
@ -205,13 +204,13 @@ namespace AirBomber
default: default:
return; return;
} }
_currTypeEngines = typesOfEngines.GetType(); (sender as Label).DoDragDrop(Tuple.Create(typesOfEngines.GetType(), typesOfEngines), DragDropEffects.Move | DragDropEffects.Copy);
(sender as Label).DoDragDrop(typesOfEngines, DragDropEffects.Move | DragDropEffects.Copy);
} }
private void labelTypesOfEngines_DragDrop(object sender, DragEventArgs e) private void labelTypesOfEngines_DragDrop(object sender, DragEventArgs e)
{ {
var engines = (IAirplaneEngines)e.Data.GetData(_currTypeEngines); var data = (Tuple<Type, IAirplaneEngines>)e.Data.GetData(typeof(Tuple<Type, IAirplaneEngines>));
var engines = data.Item2;
engines.CountEngines = _airplane.DrawningEngines.CountEngines; engines.CountEngines = _airplane.DrawningEngines.CountEngines;
if (_airplane is DrawningAirBomber) if (_airplane is DrawningAirBomber)
{ {
@ -225,6 +224,6 @@ namespace AirBomber
DrawAirplane(); DrawAirplane();
} }
private void labelTypesOfEngines_DragEnter(object sender, DragEventArgs e) => setDragEffect(e, _currTypeEngines, _airplane != null); private void labelTypesOfEngines_DragEnter(object sender, DragEventArgs e) => setDragEffect(e, typeof(Tuple<Type, IAirplaneEngines>), _airplane != null);
} }
} }