private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { DragInfo.Destination.Parent = this; DragInfo.Destination.Slot = getSlot(sender); DragInfo.Destination.Offset = getPKXOffset(DragInfo.Destination.Slot); DragInfo.Destination.Box = CB_BoxSelect.SelectedIndex; // Check for In-Dropped files (PKX,SAV,ETC) string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Directory.Exists(files[0])) { return; } if (SAV.getIsSlotLocked(DragInfo.Destination.Box, DragInfo.Destination.Slot)) { DragInfo.Destination.Slot = -1; // Invalidate WinFormsUtil.Alert("Unable to set to locked slot."); return; } if (DragInfo.Source.Offset < 0) // file { if (files.Length <= 0) { return; } string file = files[0]; FileInfo fi = new FileInfo(file); if (!PKX.getIsPKM(fi.Length) && !MysteryGift.getIsMysteryGift(fi.Length)) { return; } byte[] data = File.ReadAllBytes(file); MysteryGift mg = MysteryGift.getMysteryGift(data, fi.Extension); PKM temp = mg != null?mg.convertToPKM(SAV) : PKMConverter.getPKMfromBytes(data, prefer: SAV.Generation); string c; PKM pk = PKMConverter.convertToFormat(temp, SAV.PKMType, out c); if (pk == null) { WinFormsUtil.Error(c); Console.WriteLine(c); return; } string[] errata = SAV.IsPKMCompatible(pk); if (errata.Length > 0) { string concat = string.Join(Environment.NewLine, errata); if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, concat, "Continue?")) { Console.WriteLine(c); Console.WriteLine(concat); return; } } DragInfo.SetPKM(pk, false); getQuickFiller(SlotPictureBoxes[DragInfo.Destination.Slot], pk); Console.WriteLine(c); } else { PKM pkz = DragInfo.GetPKM(true); if (!DragInfo.Source.IsValid) { } // not overwritable, do nothing else if (ModifierKeys == Keys.Alt && DragInfo.Destination.IsValid) // overwrite { // Clear from slot if (DragInfo.SameBox) { getQuickFiller(SlotPictureBoxes[DragInfo.Source.Slot], SAV.BlankPKM); // picturebox } DragInfo.SetPKM(SAV.BlankPKM, true); } else if (ModifierKeys != Keys.Control && DragInfo.Destination.IsValid) // move { // Load data from destination PKM pk = ((PictureBox)sender).Image != null ? DragInfo.GetPKM(false) : SAV.BlankPKM; // Set destination pokemon image to source picture box if (DragInfo.SameBox) { getQuickFiller(SlotPictureBoxes[DragInfo.Source.Slot], pk); } // Set destination pokemon data to source slot DragInfo.SetPKM(pk, true); } else if (DragInfo.SameBox) // clone { getQuickFiller(SlotPictureBoxes[DragInfo.Source.Slot], pkz); } // Copy from temp to destination slot. DragInfo.SetPKM(pkz, false); getQuickFiller(SlotPictureBoxes[DragInfo.Destination.Slot], pkz); e.Effect = DragDropEffects.Link; Cursor = DefaultCursor; } if (DragInfo.Source.IsParty || DragInfo.Destination.IsParty) { parent.setParty(); } if (DragInfo.Source.Parent == null) // another instance or file { parent.notifyBoxViewerRefresh(); DragInfo.Reset(); } }