Исправил AllowDrop

This commit is contained in:
gettterot 2024-04-17 15:24:49 +04:00
parent 2ab72ce5de
commit 0e0b374521
2 changed files with 50 additions and 13 deletions

View File

@ -89,6 +89,7 @@
// //
// labelBodyColor // labelBodyColor
// //
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle; labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); labelBodyColor.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point);
labelBodyColor.Location = new Point(20, 14); labelBodyColor.Location = new Point(20, 14);
@ -102,6 +103,7 @@
// //
// labelAdditionslColor // labelAdditionslColor
// //
labelAdditionslColor.AllowDrop = true;
labelAdditionslColor.BorderStyle = BorderStyle.FixedSingle; labelAdditionslColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionslColor.Location = new Point(146, 14); labelAdditionslColor.Location = new Point(146, 14);
labelAdditionslColor.Name = "labelAdditionslColor"; labelAdditionslColor.Name = "labelAdditionslColor";

View File

@ -1,6 +1,7 @@
 
using ProjectLiner.Drawnings; using ProjectLiner.Drawnings;
using ProjectLiner.Entities; using ProjectLiner.Entities;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
namespace ProjectLiner; namespace ProjectLiner;
@ -120,35 +121,69 @@ public partial class FormLinerConfig : Form
} }
} }
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_commonLiner == null)
return;
_commonLiner.EntityCommonLiner?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
/// <summary>
/// Передача основного цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelBodyColor_DragEnter(object sender, DragEventArgs e) private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data.GetDataPresent(typeof(Color))) if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy; e.Effect = DragDropEffects.Copy;
}
else else
{
e.Effect = DragDropEffects.None; e.Effect = DragDropEffects.None;
}
} }
/// <summary>
/// Прорисовка основным цветом
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_commonLiner != null)
{
_commonLiner.EntityCommonLiner?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
}
/// <summary>
/// Прорисовка дополнительным цветом
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{ {
if (_commonLiner?.EntityCommonLiner is EntityLiner _liner) if (_commonLiner?.EntityCommonLiner is EntityLiner _liner)
_liner?.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); {
_liner.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
}
DrawObject(); DrawObject();
} }
/// <summary>
/// Передача дополнительного цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data.GetDataPresent(typeof(Color))) if (_commonLiner is DrawningLiner)
e.Effect = DragDropEffects.Copy; {
else if (e.Data.GetDataPresent(typeof(Color)))
e.Effect = DragDropEffects.None; {
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
} }
} }