Drag & Drop within box

Big thanks to Codemonkey85 for the template code and implementation
strategy.
This commit is contained in:
Kurt 2014-11-25 20:43:02 -08:00
parent c7d6127bb8
commit c274310b3d
2 changed files with 136 additions and 0 deletions

View file

@ -2792,6 +2792,9 @@
this.bpkx30.TabIndex = 59;
this.bpkx30.TabStop = false;
this.bpkx30.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx30.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx30.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx30.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx29
//
@ -2803,6 +2806,9 @@
this.bpkx29.TabIndex = 58;
this.bpkx29.TabStop = false;
this.bpkx29.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx29.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx29.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx29.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx28
//
@ -2814,6 +2820,9 @@
this.bpkx28.TabIndex = 57;
this.bpkx28.TabStop = false;
this.bpkx28.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx28.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx28.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx28.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx27
//
@ -2825,6 +2834,9 @@
this.bpkx27.TabIndex = 56;
this.bpkx27.TabStop = false;
this.bpkx27.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx27.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx27.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx27.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx26
//
@ -2836,6 +2848,9 @@
this.bpkx26.TabIndex = 55;
this.bpkx26.TabStop = false;
this.bpkx26.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx26.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx26.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx26.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx25
//
@ -2847,6 +2862,9 @@
this.bpkx25.TabIndex = 54;
this.bpkx25.TabStop = false;
this.bpkx25.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx25.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx25.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx25.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx24
//
@ -2858,6 +2876,9 @@
this.bpkx24.TabIndex = 53;
this.bpkx24.TabStop = false;
this.bpkx24.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx24.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx24.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx24.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx23
//
@ -2869,6 +2890,9 @@
this.bpkx23.TabIndex = 52;
this.bpkx23.TabStop = false;
this.bpkx23.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx23.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx23.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx23.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx22
//
@ -2880,6 +2904,9 @@
this.bpkx22.TabIndex = 51;
this.bpkx22.TabStop = false;
this.bpkx22.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx22.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx22.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx22.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx21
//
@ -2891,6 +2918,9 @@
this.bpkx21.TabIndex = 50;
this.bpkx21.TabStop = false;
this.bpkx21.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx21.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx21.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx21.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx20
//
@ -2902,6 +2932,9 @@
this.bpkx20.TabIndex = 49;
this.bpkx20.TabStop = false;
this.bpkx20.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx20.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx20.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx20.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx19
//
@ -2913,6 +2946,9 @@
this.bpkx19.TabIndex = 48;
this.bpkx19.TabStop = false;
this.bpkx19.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx19.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx19.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx19.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx18
//
@ -2924,6 +2960,9 @@
this.bpkx18.TabIndex = 47;
this.bpkx18.TabStop = false;
this.bpkx18.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx18.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx18.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx18.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx17
//
@ -2935,6 +2974,9 @@
this.bpkx17.TabIndex = 46;
this.bpkx17.TabStop = false;
this.bpkx17.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx17.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx17.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx17.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx16
//
@ -2946,6 +2988,9 @@
this.bpkx16.TabIndex = 45;
this.bpkx16.TabStop = false;
this.bpkx16.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx16.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx16.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx16.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx15
//
@ -2957,6 +3002,9 @@
this.bpkx15.TabIndex = 44;
this.bpkx15.TabStop = false;
this.bpkx15.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx15.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx15.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx15.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx14
//
@ -2968,6 +3016,9 @@
this.bpkx14.TabIndex = 43;
this.bpkx14.TabStop = false;
this.bpkx14.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx14.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx14.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx14.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx13
//
@ -2979,6 +3030,9 @@
this.bpkx13.TabIndex = 42;
this.bpkx13.TabStop = false;
this.bpkx13.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx13.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx13.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx13.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx12
//
@ -2990,6 +3044,9 @@
this.bpkx12.TabIndex = 41;
this.bpkx12.TabStop = false;
this.bpkx12.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx12.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx12.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx12.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx11
//
@ -3001,6 +3058,9 @@
this.bpkx11.TabIndex = 40;
this.bpkx11.TabStop = false;
this.bpkx11.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx11.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx11.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx11.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx10
//
@ -3012,6 +3072,9 @@
this.bpkx10.TabIndex = 39;
this.bpkx10.TabStop = false;
this.bpkx10.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx10.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx10.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx10.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx9
//
@ -3023,6 +3086,9 @@
this.bpkx9.TabIndex = 38;
this.bpkx9.TabStop = false;
this.bpkx9.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx9.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx9.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx9.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx8
//
@ -3034,6 +3100,9 @@
this.bpkx8.TabIndex = 37;
this.bpkx8.TabStop = false;
this.bpkx8.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx8.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx8.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx8.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx7
//
@ -3045,6 +3114,9 @@
this.bpkx7.TabIndex = 36;
this.bpkx7.TabStop = false;
this.bpkx7.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx7.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx7.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx7.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx6
//
@ -3056,6 +3128,9 @@
this.bpkx6.TabIndex = 35;
this.bpkx6.TabStop = false;
this.bpkx6.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx6.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx6.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx5
//
@ -3067,6 +3142,9 @@
this.bpkx5.TabIndex = 34;
this.bpkx5.TabStop = false;
this.bpkx5.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx5.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx5.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx5.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx4
//
@ -3078,6 +3156,9 @@
this.bpkx4.TabIndex = 33;
this.bpkx4.TabStop = false;
this.bpkx4.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx4.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx4.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx3
//
@ -3089,6 +3170,9 @@
this.bpkx3.TabIndex = 32;
this.bpkx3.TabStop = false;
this.bpkx3.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx3.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx3.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx2
//
@ -3100,6 +3184,9 @@
this.bpkx2.TabIndex = 31;
this.bpkx2.TabStop = false;
this.bpkx2.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx2.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx2.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bpkx1
//
@ -3111,6 +3198,9 @@
this.bpkx1.TabIndex = 30;
this.bpkx1.TabStop = false;
this.bpkx1.Click += new System.EventHandler(this.slotModifier_Click);
this.bpkx1.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop);
this.bpkx1.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter);
this.bpkx1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// B_BoxRight
//

View file

@ -155,6 +155,12 @@ namespace PKHeX
ToolTip dragoutTip2 = new ToolTip();
dragoutTip1.SetToolTip(dragout, "PK6 QuickSave");
dragoutTip2.SetToolTip(eragout, "EK6 QuickSave");
// Box Drag & Drop
for (int i = 0; i < 30; i++)
pba[i].AllowDrop = true;
tabMain.AllowDrop = true;
#endregion
#region Finish Up
@ -6070,6 +6076,46 @@ namespace PKHeX
updateIVs(null, null); // Prompt an update for the characteristics
}
private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e)
{
PictureBox pb = (PictureBox)(sender);
if (pb.Image == null)
return;
int slot = getSlot(sender);
int offset = getPKXOffset(slot);
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
Array.Copy(savefile, offset, pkm_from, 0, 0xE8);
pkm_from_offset = offset;
(sender as PictureBox).DoDragDrop(pkm_from, DragDropEffects.Move);
}
}
private void pbBoxSlot_DragDrop(object sender, DragEventArgs e)
{
try {
if ((sender as TabControl).Name != "")
populateFields(pkm_from);
} catch { }
PictureBox pb = (PictureBox)(sender);
int slot = getSlot(sender);
int offset = getPKXOffset(slot);
if (ModifierKeys == Keys.Alt)
Array.Copy(PKX.encryptArray(new Byte[0xE8]), 0, savefile, pkm_from_offset, 0xE8);
if (ModifierKeys != Keys.Control)
Array.Copy(savefile, offset, savefile, pkm_from_offset, 0xE8); // Copy from new slot to old slot.
Array.Copy(pkm_from, 0, savefile, offset, 0xE8); // Copy from temp slot to new.
setPKXBoxes();
}
private void pbBoxSlot_DragEnter(object sender, DragEventArgs e)
{
if (e.Data != null)
e.Effect = DragDropEffects.Move;
}
private byte[] pkm_from = new Byte[0xE8];
private int pkm_from_offset;
}
#region Structs & Classes
public class cbItem