2019-08-21 02:50:28 +00:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
|
|
|
|
|
|
public sealed class DragManager
|
2019-08-21 02:50:28 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public SlotChangeInfo<Cursor, PictureBox> Info { get; private set; } = new();
|
|
|
|
|
public event DragEventHandler? RequestExternalDragDrop;
|
|
|
|
|
public void RequestDD(object sender, DragEventArgs e) => RequestExternalDragDrop?.Invoke(sender, e);
|
2019-08-21 02:50:28 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public void SetCursor(Form? f, Cursor? z)
|
|
|
|
|
{
|
|
|
|
|
if (f != null)
|
|
|
|
|
f.Cursor = z;
|
|
|
|
|
Info.Cursor = z;
|
|
|
|
|
}
|
2019-08-21 02:50:28 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public void ResetCursor(Form? sender)
|
|
|
|
|
{
|
|
|
|
|
SetCursor(sender, Cursors.Default);
|
|
|
|
|
}
|
2019-08-21 02:50:28 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
|
|
|
|
Info = new SlotChangeInfo<Cursor, PictureBox>();
|
|
|
|
|
}
|
2019-08-21 02:50:28 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public void Reset() => Info.Reset();
|
2019-08-21 02:50:28 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public Point MouseDownPosition { private get; set; }
|
|
|
|
|
public bool CanStartDrag => Info.LeftMouseIsDown && !Cursor.Position.Equals(MouseDownPosition);
|
|
|
|
|
}
|