This commit is contained in:
Baryshev Dmitry 2024-05-02 14:12:07 +04:00
parent 5e702200a2
commit d802aa0ec6

View File

@ -72,88 +72,89 @@ public partial class FormTruckConfig : Form
} }
///// <summary> /// <summary>
///// Передаем информацию при нажатии на Label(Объект) /// Передаем информацию при нажатии на Label(Объект)
///// </summary> /// </summary>
///// <param name="sender"></param> /// <param name="sender"></param>
///// <param name="e"></param> /// <param name="e"></param>
//private void LabelObject_MouseDown(object sender, MouseEventArgs e)
//{
// (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
//}
///// <summary>
///// Проверка получаемой информации(Объект) (ее типа на соответствие требуемому)
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void PanelObject_DragEnter(object sender, DragEventArgs e)
//{
// e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
//}
///// <summary>
///// Действия при приеме перетаскиваемой информации
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void PanelObject_DragDrop(object sender, DragEventArgs e)
//{
// switch (e.Data?.GetData(DataFormats.Text)?.ToString())
// {
// case "labelSimpleObject":
// _truck = new DrawningTruck((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
// break;
// case "labelModifiedObject":
// _truck = new DrawningDumpTruck((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, Color.Black,
// checkBoxAwning.Checked, checkBoxTent.Checked);
// break;
// }
// DrawObject();
//}
private void LabelObject_MouseDown(object sender, MouseEventArgs e) private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{ {
Label? label = sender as Label; (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
if (label?.Name == "labelSimpleObject")
{
label?.DoDragDrop(new DrawningTruck((int)numericUpDownSpeed.Value,
(double)numericUpDownWeight.Value, Color.White), DragDropEffects.Copy);
}
else
{
label?.DoDragDrop(new DrawningDumpTruck((int)numericUpDownSpeed.Value,
(double)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxAwning.Checked, checkBoxTent.Checked), DragDropEffects.Copy);
}
} }
/// <summary>
/// Проверка получаемой информации(Объект) (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e) private void PanelObject_DragDrop(object sender, DragEventArgs e)
{ {
if ((DrawningTruck?)e.Data.GetData(typeof(DrawningTruck)) != null) switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{ {
_truck = (DrawningTruck?)e.Data.GetData(typeof(DrawningTruck)); case "labelSimpleObject":
} _truck = new DrawningTruck((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
else if ((DrawningDumpTruck?)e.Data.GetData(typeof(DrawningDumpTruck)) != null) break;
{
_truck = (DrawningDumpTruck?)e.Data.GetData(typeof(DrawningDumpTruck)); case "labelModifiedObject":
_truck = new DrawningDumpTruck((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, Color.Black,
checkBoxAwning.Checked, checkBoxTent.Checked);
break;
} }
DrawObject(); DrawObject();
}
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if ((e.Data.GetDataPresent(typeof(DrawningTruck))) || e.Data.GetDataPresent(typeof(DrawningDumpTruck)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
} }
//допка
//private void LabelObject_MouseDown(object sender, MouseEventArgs e)
//{
// Label? label = sender as Label;
// if (label?.Name == "labelSimpleObject")
// {
// label?.DoDragDrop(new DrawningTruck((int)numericUpDownSpeed.Value,
// (double)numericUpDownWeight.Value, Color.White), DragDropEffects.Copy);
// }
// else
// {
// label?.DoDragDrop(new DrawningDumpTruck((int)numericUpDownSpeed.Value,
// (double)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxAwning.Checked, checkBoxTent.Checked), DragDropEffects.Copy);
// }
//}
//private void PanelObject_DragDrop(object sender, DragEventArgs e)
//{
// if ((DrawningTruck?)e.Data.GetData(typeof(DrawningTruck)) != null)
// {
// _truck = (DrawningTruck?)e.Data.GetData(typeof(DrawningTruck));
// }
// else if ((DrawningDumpTruck?)e.Data.GetData(typeof(DrawningDumpTruck)) != null)
// {
// _truck = (DrawningDumpTruck?)e.Data.GetData(typeof(DrawningDumpTruck));
// }
// DrawObject();
//}
//private void PanelObject_DragEnter(object sender, DragEventArgs e)
//{
// if ((e.Data.GetDataPresent(typeof(DrawningTruck))) || e.Data.GetDataPresent(typeof(DrawningDumpTruck)))
// {
// e.Effect = DragDropEffects.Copy;
// }
// else
// {
// e.Effect = DragDropEffects.None;
// }
//}
/// <summary> /// <summary>
/// Панель отправка цвета при нажатии на Panel /// Панель отправка цвета при нажатии на Panel