From 11aab91eeef9bfbb86e56e45bb259600fe1e4fca Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 30 May 2017 19:17:37 -0700 Subject: [PATCH] Fix drag&drop exception immediately after dropping the file, move the mouse outside of the box slots DoDragDrop re-performs the drop event at the same coordinate as the mouse; if the mouse isn't outside of the box area it'll do nothing, thus the need to create a new event to fire. Closes #1178 --- PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs | 1 + PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs index 7d2b18663..3ec7b3e89 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs @@ -96,6 +96,7 @@ public void EnableDragDrop(DragEventHandler enter, DragEventHandler drop) tab.DragEnter += enter; tab.DragDrop += drop; } + M.RequestExternalDragDrop += drop; } // Generic Subfunctions // diff --git a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs index 9a0aa0f64..a922e80c3 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs @@ -24,6 +24,7 @@ public class SlotChangeManager public int colorizedbox = -1; public int colorizedslot = -1; public Image colorizedcolor; + public event DragEventHandler RequestExternalDragDrop; public SlotChangeManager(SAVEditor se) { @@ -201,7 +202,7 @@ public void HandleDropPKM(object sender, DragEventArgs e, bool overwrite, bool c } if (DragInfo.Source.Offset < 0) // external source { - TryLoadFiles(files); + TryLoadFiles(files, e); return; } @@ -210,7 +211,7 @@ public void HandleDropPKM(object sender, DragEventArgs e, bool overwrite, bool c if (DragInfo.Source.Parent == null) // internal file DragInfo.Reset(); } - private void TryLoadFiles(string[] files) + private void TryLoadFiles(string[] files, DragEventArgs e) { if (files.Length <= 0) return; @@ -218,7 +219,7 @@ private void TryLoadFiles(string[] files) FileInfo fi = new FileInfo(file); if (!PKX.getIsPKM(fi.Length) && !MysteryGift.getIsMysteryGift(fi.Length)) { - SE.ParentForm?.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { file }), DragDropEffects.Move); + RequestExternalDragDrop?.Invoke(this, e); // pass thru return; }