private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { DragInfo.slotDestination = this; DragInfo.slotDestinationSlotNumber = getSlot(sender); DragInfo.slotDestinationOffset = getPKXOffset(DragInfo.slotDestinationSlotNumber); DragInfo.slotDestinationBoxNumber = 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 (DragInfo.slotSourceOffset < 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); string c; PKM pk = PKMConverter.convertToFormat(temp, SAV.PKMType, out c); if (pk == null) { Util.Error(c); Console.WriteLine(c); return; } string[] errata = verifyPKMtoSAV(pk); if (errata.Length > 0) { string concat = string.Join(Environment.NewLine, errata); if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, concat, "Continue?")) { Console.WriteLine(c); Console.WriteLine(concat); return; } } SAV.setStoredSlot(pk, DragInfo.slotDestinationOffset); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pk); Console.WriteLine(c); } else { PKM pkz = SAV.getStoredSlot(DragInfo.slotSourceOffset); if (!DragInfo.SourceValid) { } // not overwritable, do nothing else if (ModifierKeys == Keys.Alt && DragInfo.DestinationValid) // overwrite { // Clear from slot if (DragInfo.SameBox) { getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], SAV.BlankPKM); // picturebox } SAV.setStoredSlot(SAV.BlankPKM, DragInfo.slotSourceOffset); } else if (ModifierKeys != Keys.Control && DragInfo.DestinationValid) // move { // Load data from destination PKM pk = ((PictureBox)sender).Image != null ? SAV.getStoredSlot(DragInfo.slotDestinationOffset) : SAV.BlankPKM; // Set destination pokemon image to source picture box if (DragInfo.SameBox) { getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pk); } // Set destination pokemon data to source slot SAV.setStoredSlot(pk, DragInfo.slotSourceOffset); } else if (DragInfo.SameBox) // clone { getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pkz); } // Copy from temp to destination slot. SAV.setStoredSlot(pkz, DragInfo.slotDestinationOffset); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pkz); e.Effect = DragDropEffects.Link; Cursor = DefaultCursor; } if (DragInfo.slotSource == null) // another instance or file { parent.notifyBoxViewerRefresh(); DragInfo.Reset(); } }