mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Update drag&drop
remove hover-tooltip keycombo reuse logic for move/drop
This commit is contained in:
parent
f82e545ab0
commit
fc63a863d5
3 changed files with 49 additions and 78 deletions
|
@ -243,44 +243,9 @@ namespace PKHeX.WinForms.Controls
|
|||
private void BoxSlot_MouseClick(object sender, MouseEventArgs e) => M?.MouseClick(sender, e);
|
||||
private void BoxSlot_MouseUp(object sender, MouseEventArgs e) => M?.MouseUp(sender, e);
|
||||
private void BoxSlot_MouseDown(object sender, MouseEventArgs e) => M?.MouseDown(sender, e);
|
||||
private void BoxSlot_MouseMove(object sender, MouseEventArgs e) => M?.MouseMove(sender, e);
|
||||
private void BoxSlot_DragEnter(object sender, DragEventArgs e) => M?.DragEnter(sender, e);
|
||||
private void BoxSlot_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) => M?.QueryContinueDrag(sender, e);
|
||||
private void BoxSlot_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (M == null || M.DragActive)
|
||||
return;
|
||||
|
||||
// Abort if there is no Pokemon in the given slot.
|
||||
PictureBox pb = (PictureBox)sender;
|
||||
if (pb.Image == null)
|
||||
return;
|
||||
int slot = GetSlot(pb);
|
||||
if (slot >= SlotCount || SAV.IsSlotLocked(CurrentBox, slot))
|
||||
return;
|
||||
|
||||
bool encrypt = ModifierKeys == Keys.Control;
|
||||
M.HandleMovePKM(pb, slot, CurrentBox, encrypt);
|
||||
}
|
||||
private void BoxSlot_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (M == null)
|
||||
return;
|
||||
|
||||
// Abort if there is no Pokemon in the given slot.
|
||||
PictureBox pb = (PictureBox)sender;
|
||||
int slot = GetSlot(pb);
|
||||
if (slot >= SlotCount || SAV.IsSlotLocked(CurrentBox, slot))
|
||||
{
|
||||
SystemSounds.Asterisk.Play();
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
M.DragInfo.Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
bool overwrite = ModifierKeys == Keys.Alt;
|
||||
bool clone = ModifierKeys == Keys.Control;
|
||||
M.DragInfo.Destination = GetSlotData(pb);
|
||||
M.HandleDropPKM(sender, e, overwrite, clone);
|
||||
}
|
||||
private void BoxSlot_DragDrop(object sender, DragEventArgs e) => M?.DragDrop(sender, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,12 +102,12 @@ namespace PKHeX.WinForms.Controls
|
|||
pb.MouseEnter += M.MouseEnter;
|
||||
pb.MouseLeave += M.MouseLeave;
|
||||
pb.MouseClick += M.MouseClick;
|
||||
pb.MouseMove += BoxSlot_MouseMove;
|
||||
pb.MouseMove += M.MouseMove;
|
||||
pb.MouseDown += M.MouseDown;
|
||||
pb.MouseUp += M.MouseUp;
|
||||
|
||||
pb.DragEnter += M.DragEnter;
|
||||
pb.DragDrop += BoxSlot_DragDrop;
|
||||
pb.DragDrop += M.DragDrop;
|
||||
pb.QueryContinueDrag += M.QueryContinueDrag;
|
||||
pb.GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
|
||||
pb.AllowDrop = true;
|
||||
|
@ -1113,43 +1113,6 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
|
||||
// DragDrop
|
||||
private void BoxSlot_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (M == null || M.DragActive)
|
||||
return;
|
||||
|
||||
// Abort if there is no Pokemon in the given slot.
|
||||
PictureBox pb = (PictureBox)sender;
|
||||
if (pb.Image == null)
|
||||
return;
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
var src = view.GetSlotData(pb);
|
||||
if (!src.Editable || SAV.IsSlotLocked(src.Box, src.Slot))
|
||||
return;
|
||||
bool encrypt = ModifierKeys == Keys.Control;
|
||||
M.HandleMovePKM(pb, src.Slot, src.Box, encrypt);
|
||||
}
|
||||
private void BoxSlot_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (M == null)
|
||||
return;
|
||||
|
||||
PictureBox pb = (PictureBox)sender;
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
var src = view.GetSlotData(pb);
|
||||
if (!src.Editable || SAV.IsSlotLocked(src.Box, src.Slot))
|
||||
{
|
||||
SystemSounds.Asterisk.Play();
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
M.DragInfo.Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
bool overwrite = ModifierKeys == Keys.Alt;
|
||||
bool clone = ModifierKeys == Keys.Control;
|
||||
M.DragInfo.Destination = src;
|
||||
M.HandleDropPKM(sender, e, overwrite, clone);
|
||||
}
|
||||
private void MultiDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
// iterate over all tabs to see if a tab switch should occur when drag/dropping
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace PKHeX.WinForms.Controls
|
|||
public readonly List<BoxEditor> Boxes = new List<BoxEditor>();
|
||||
public readonly List<ISlotViewer<PictureBox>> OtherSlots = new List<ISlotViewer<PictureBox>>();
|
||||
public event DragEventHandler RequestExternalDragDrop;
|
||||
private readonly ToolTip ShowSet = new ToolTip {InitialDelay = 200, IsBalloon = true};
|
||||
private readonly ToolTip ShowSet = new ToolTip {InitialDelay = 400, IsBalloon = false};
|
||||
|
||||
public SlotChangeManager(SAVEditor se)
|
||||
{
|
||||
|
@ -38,6 +38,9 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
public void Reset() { DragInfo = new SlotChangeInfo(SAV); ColorizedBox = ColorizedSlot = -1; }
|
||||
public bool DragActive => DragInfo.DragDropInProgress || !DragInfo.LeftMouseIsDown;
|
||||
public bool CanStartDrag => DragInfo.LeftMouseIsDown && !Cursor.Position.Equals(MouseDownPosition);
|
||||
private Point MouseDownPosition { get; set; }
|
||||
|
||||
public void SetCursor(Cursor z, object sender)
|
||||
{
|
||||
if (SE != null)
|
||||
|
@ -59,7 +62,7 @@ namespace PKHeX.WinForms.Controls
|
|||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
var data = view.GetSlotData(pb);
|
||||
var pk = SAV.GetStoredSlot(data.Offset);
|
||||
if (pk.Species > 0 && Control.ModifierKeys.HasFlag(Keys.Control) && Control.ModifierKeys.HasFlag(Keys.Shift))
|
||||
if (pk.Species > 0)
|
||||
ShowSet.SetToolTip(pb, pk.ShowdownText);
|
||||
else
|
||||
ShowSet.RemoveAll();
|
||||
|
@ -89,7 +92,10 @@ namespace PKHeX.WinForms.Controls
|
|||
public void MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
DragInfo.LeftMouseIsDown = true;
|
||||
MouseDownPosition = Cursor.Position;
|
||||
}
|
||||
if (e.Button == MouseButtons.Right)
|
||||
DragInfo.RightMouseIsDown = true;
|
||||
}
|
||||
|
@ -111,6 +117,43 @@ namespace PKHeX.WinForms.Controls
|
|||
if (DragInfo.DragDropInProgress)
|
||||
SetCursor((Cursor)DragInfo.Cursor, sender);
|
||||
}
|
||||
public void MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (DragActive)
|
||||
return;
|
||||
|
||||
if (!CanStartDrag)
|
||||
return;
|
||||
|
||||
// Abort if there is no Pokemon in the given slot.
|
||||
PictureBox pb = (PictureBox)sender;
|
||||
if (pb.Image == null)
|
||||
return;
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
var src = view.GetSlotData(pb);
|
||||
if (!src.Editable || SAV.IsSlotLocked(src.Box, src.Slot))
|
||||
return;
|
||||
bool encrypt = Control.ModifierKeys == Keys.Control;
|
||||
HandleMovePKM(pb, src.Slot, src.Box, encrypt);
|
||||
}
|
||||
public void DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
PictureBox pb = (PictureBox)sender;
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
var src = view.GetSlotData(pb);
|
||||
if (!src.Editable || SAV.IsSlotLocked(src.Box, src.Slot))
|
||||
{
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
DragInfo.Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
bool overwrite = Control.ModifierKeys == Keys.Alt;
|
||||
bool clone = Control.ModifierKeys == Keys.Control;
|
||||
DragInfo.Destination = src;
|
||||
HandleDropPKM(sender, e, overwrite, clone);
|
||||
}
|
||||
|
||||
private static ISlotViewer<T> GetViewParent<T>(T pb) where T : Control
|
||||
=> WinFormsUtil.FindFirstControlOfType<ISlotViewer<T>>(pb);
|
||||
|
|
Loading…
Add table
Reference in a new issue