Esempio n. 1
0
        private void HandleSet(object sender, EventArgs e)
        {
            int              index  = getSlot(sender);
            MainForm         mf     = FindForm() as MainForm;
            PK1              to_set = mf.pk1;
            PokemonListPanel PLC    = (((sender as ToolStripItem)?.GetCurrentParent() as ContextMenuStrip)?.SourceControl).Parent as PokemonListPanel;

            if (PLC == this)
            {
                PLC.set(index, to_set);
                if (mf.modify_dex)
                {
                    mf.sav.Pokedex_Seen[Tables.ID_To_Dex[to_set.Species]]       =
                        mf.sav.Pokedex_Caught[Tables.ID_To_Dex[to_set.Species]] = true;
                }
            }
        }
Esempio n. 2
0
        private void HandleDragDrop(object sender, DragEventArgs e)
        {
            Control c = sender as Control;

            if (!(c.FindForm() is MainForm))
            {
                return;
            }
            MainForm mf = c.FindForm() as MainForm;

            if (mf.getInChildForm())
            {
                return;
            }
            if (!(c.Parent is PokemonListPanel))
            {
                return;
            }
            PokemonListPanel parent = c.Parent as PokemonListPanel;
            int slot = getSlot(sender);

            // Check for In-Dropped files
            object[] files = (object[])e.Data.GetData(DataFormats.FileDrop);
            if (e.Effect == DragDropEffects.Copy)
            {
                if (files.Length <= 0)
                {
                    return;
                }
                FileInfo fi = new FileInfo((string)files[0]);
                if ((int)fi.Length == PokemonList.GetDataLength(PokemonList.CapacityType.Single) && !mf.JP_Mode)
                {
                    byte[] data = File.ReadAllBytes((string)files[0]);
                    if (data[0] == 1 && data[2] == 0xFF && data[1] == data[3]) // PK1
                    {
                        parent.set(slot, new PokemonList(data)[0]);
                    }
                    else
                    {
                        mf.openFile((string)files[0]);
                    }
                }
                else if ((int)fi.Length == PokemonList.GetDataLength(PokemonList.CapacityType.Single, true) && mf.JP_Mode)
                {
                    byte[] data = File.ReadAllBytes((string)files[0]);
                    if (data[0] == 1 && data[2] == 0xFF && data[1] == data[3]) // JPK1
                    {
                        parent.set(slot, new PokemonList(data, PokemonList.CapacityType.Single, true)[0]);
                    }
                    else
                    {
                        mf.openFile((string)files[0]);
                    }
                }
                else
                {
                    mf.openFile((string)files[0]);
                }
            }
            else if (e.Effect == DragDropEffects.Move)
            {
                if (files.Length != 1)
                {
                    return;
                }
                if (sender_parent == null)
                {
                    FileInfo fi = new FileInfo((string)files[0]);
                    if ((int)fi.Length == PokemonList.GetDataLength(PokemonList.CapacityType.Single) && !mf.JP_Mode)
                    {
                        byte[] data = File.ReadAllBytes((string)files[0]);
                        if (data[0] == 1 && data[2] == 0xFF && data[1] == data[3]) // PK1
                        {
                            parent.set(slot, new PokemonList(data)[0]);
                        }
                        else
                        {
                            mf.openFile((string)files[0]);
                        }
                    }
                    else if ((int)fi.Length == PokemonList.GetDataLength(PokemonList.CapacityType.Single, true) && mf.JP_Mode)
                    {
                        byte[] data = File.ReadAllBytes((string)files[0]);
                        if (data[0] == 1 && data[2] == 0xFF && data[1] == data[3]) // JPK1
                        {
                            parent.set(slot, new PokemonList(data, PokemonList.CapacityType.Single, true)[0]);
                        }
                        else
                        {
                            mf.openFile((string)files[0]);
                        }
                    }
                    else
                    {
                        mf.openFile((string)files[0]);
                    }
                }
                else
                {
                    PK1 temp  = parent.pokemonlist[slot];
                    int count = parent.pokemonlist.Count;
                    parent.set(slot, sender_parent.pokemonlist[sender_slot]);
                    if (slot < count)
                    {
                        sender_parent.set(sender_slot, temp);
                    }
                }
            }
        }