Example #1
0
        // Clicked Label Shortcuts //
        private void clickQR(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Alt)
            {
                // Fetch data from QR code...
                byte[] ekx = Util.getQRData();

                if (ekx == null) return;

                if (ekx.Length != 232) { Util.Alert("Decoded data not 232 bytes.", String.Format("QR Data Size: {0}", ekx.Length)); }
                else try
                    {
                        byte[] pkx = PKX.decryptArray(ekx);
                        if (PKX.verifychk(pkx)) { Array.Copy(pkx, buff, 0xE8); populateFields(buff); }
                        else Util.Alert("Invalid checksum in QR data.");
                    }
                    catch { Util.Alert("Error loading decrypted data."); }
            }
            else
            {
                if (!verifiedPKX()) return;
                byte[] pkx = preparepkx();
                byte[] ekx = PKX.encryptArray(pkx);

                Array.Resize(ref ekx, 232);
                const string server = "http://loadcode.projectpokemon.org/b1s1.html#"; // Rehosted with permission from LC/MS -- massive thanks!
                Image qr = Util.getQRImage(ekx, server);

                if (qr == null) return;

                PKX data = new PKX(pkx, "Tabs");
                string[] r = PKX.getPKXSummary(data);
                new QR(qr, dragout.Image, r[0], r[1], r[2], "PKHeX @ ProjectPokemon.org").ShowDialog();
            }
        }
Example #2
0
        // Decrypted Export
        private void dragout_MouseDown(object sender, MouseEventArgs e)
        {
            if (!verifiedPKX()) { return; }
            {
                // Create Temp File to Drag
                string basepath = Application.StartupPath;
                Cursor.Current = Cursors.Hand;

                // Make a new file name
                byte[] dragdata = preparepkx();
                PKX pkx = new PKX(dragdata, "Tabs");
                string filename = pkx.Nickname;
                if (filename != pkx.Species)
                    filename += " (" + pkx.Species + ")";
                filename += " - " + pkx.PID;

                filename += (e.Button == MouseButtons.Right) ? ".ek6" : ".pk6";
                dragdata = (e.Button == MouseButtons.Right) ? PKX.encryptArray(preparepkx()) : preparepkx();
                // Strip out party stats (if they are there)
                Array.Resize(ref dragdata, 232);
                // Make file
                string newfile = Path.Combine(basepath, Util.CleanFileName(filename));
                try
                {
                    File.WriteAllBytes(newfile, dragdata);

                    string[] filesToDrag = { newfile };
                    dragout.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move);
                    File.Delete(newfile);
                }
                catch (Exception x)
                { Util.Error("Drag & Drop Error", x.ToString()); }
                File.Delete(newfile);
            }
        }
Example #3
0
        // Drag & Drop within Box
        private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e)
        {
            if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Alt || ModifierKeys == Keys.Shift || ModifierKeys == (Keys.Control | Keys.Alt))
            { clickSlot(sender, e); return; }
            PictureBox pb = (PictureBox)(sender);
            if (pb.Image == null)
                return;

            pkm_from_slot = getSlot(sender);
            int offset = getPKXOffset(pkm_from_slot);
            if (e.Button != MouseButtons.Left || e.Clicks != 1) return;
            // Create Temp File to Drag
            string basepath = Application.StartupPath;
            Cursor.Current = Cursors.Hand;

            // Prepare Data
            Array.Copy(savefile, offset, pkm_from, 0, 0xE8);
            pkm_from_offset = offset;

            // Make a new file name based off the PID
            byte[] dragdata = PKX.decryptArray(pkm_from);
            Array.Resize(ref dragdata, 0xE8);
            PKX pkx = new PKX(dragdata, "Boxes");
            string filename = pkx.Nickname;
            if (filename != pkx.Species)
                filename += " (" + pkx.Species + ")";
            filename += " - " + pkx.PID + ".pk6";

            // Make File
            string newfile = Path.Combine(basepath, Util.CleanFileName(filename));
            try
            {
                File.WriteAllBytes(newfile, dragdata);

                string[] filesToDrag = { newfile };
                DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move);
                File.Delete(newfile); // after drop, delete the temporary file
            }
            catch (ArgumentException x)
            { Util.Error("Drag & Drop Error:", x.ToString()); }
            File.Delete(newfile);
            pkm_from_offset = 0;
        }
Example #4
0
        internal static string[] getPKXSummary(PKX data)
        {
            string[] response = new string[3];
            // Summarize
            string filename = data.Nickname;
            if (filename != data.Species)
                filename += " (" + data.Species + ")";
            response[0] = String.Format("{0} [{4}] lv{3} @ {1} -- {2}", filename, data.HeldItem, data.Nature, data.Level, data.Ability);
            response[1] = String.Format("{0} / {1} / {2} / {3}", data.Move1, data.Move2, data.Move3, data.Move4);
            response[2] = String.Format(
                "IVs:{0}{1}{2}{3}{4}{5}"
                + Environment.NewLine + Environment.NewLine +
                "EVs:{6}{7}{8}{9}{10}{11}",
                Environment.NewLine + data.HP_IV.ToString("00"),
                Environment.NewLine + data.ATK_IV.ToString("00"),
                Environment.NewLine + data.DEF_IV.ToString("00"),
                Environment.NewLine + data.SPA_IV.ToString("00"),
                Environment.NewLine + data.SPD_IV.ToString("00"),
                Environment.NewLine + data.SPE_IV.ToString("00"),
                Environment.NewLine + data.HP_EV.ToString("00"),
                Environment.NewLine + data.ATK_EV.ToString("00"),
                Environment.NewLine + data.DEF_EV.ToString("00"),
                Environment.NewLine + data.SPA_EV.ToString("00"),
                Environment.NewLine + data.SPD_EV.ToString("00"),
                Environment.NewLine + data.SPE_EV.ToString("00"));

            return response;
        }