Допзадание

This commit is contained in:
Ctepa 2024-04-08 14:19:04 +03:00
parent 30131211c3
commit 26ecf356b8

View File

@ -1,5 +1,6 @@
using AntiAircraftGun.Drawnings;
using AntiAircraftGun.Entities;
using System;
namespace AntiAircraftGun;
/// <summary>
@ -63,7 +64,21 @@ public partial class FormGunConfig : Form
/// <param name="e"></param>
private void LabelOblect_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
Label label=sender as Label;
if(label.Name== "labelSimpleOblect")
{
label.DoDragDrop(new DrawningGun((int)numericUpDownSpeed.Value,
(double)numericUpDownWeight.Value, Color.White), DragDropEffects.Copy);
}
else
{
Random random = new Random();
label.DoDragDrop(new
DrawningAntiAircraftGun((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
Color.White,
Color.Black, random.Next(10, 100),
checkBoxHatch.Checked, checkBoxRadar.Checked), DragDropEffects.Copy);
}
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
@ -72,7 +87,7 @@ public partial class FormGunConfig : Form
/// <param name="e"></param>
private void PanelObjects_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
e.Effect = DragDropEffects.Copy;
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
@ -81,20 +96,13 @@ public partial class FormGunConfig : Form
/// <param name="e"></param>
private void PanelObjects_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
if ((DrawningGun)e.Data.GetData(typeof(DrawningGun)) != null)
{
case "labelSimpleOblect":
_gun = new DrawningGun((int)numericUpDownSpeed.Value,
(double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
Random random = new Random();
_gun = new
DrawningAntiAircraftGun((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
Color.White,
Color.Black, random.Next(10, 100),
checkBoxHatch.Checked, checkBoxRadar.Checked);
break;
_gun = (DrawningGun)e.Data.GetData(typeof(DrawningGun));
}
else
{
_gun = (DrawningAntiAircraftGun)e.Data.GetData(typeof(DrawningAntiAircraftGun));
}
DrawObject();
}
@ -150,5 +158,6 @@ public partial class FormGunConfig : Form
}
// TODO Реализовать логику смены цветов: основного и дополнительного(для продвинутого объекта)
}