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