示例#1
0
        private void HandleMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || e.Clicks != 1)
            {
                return;
            }

            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 index = getSlot(sender);

            if (index >= parent.pokemonlist.Count)
            {
                return;
            }
            Cursor.Current = Cursors.Hand;

            byte[] dragdata = new PokemonList(parent.pokemonlist[index]).GetBytes();


            string filename = RBY_Encoding.GetString(parent.pokemonlist[index].Nickname, parent.pokemonlist[index] is JPK1) + " - " +
                              RBY_Encoding.GetString(parent.pokemonlist[index].OT_Name, parent.pokemonlist[index] is JPK1) + (parent.pokemonlist[index] is JPK1 ? ".jpk1" : ".pk1");

            string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));

            try
            {
                File.WriteAllBytes(newfile, dragdata);
                sender_parent = parent;
                sender_slot   = index;
                DoDragDrop(new DataObject(DataFormats.FileDrop, new [] { newfile }), DragDropEffects.Move);
            }
            catch (ArgumentException x)
            { Util.Error("Drag & Drop Error:", x.ToString()); }
            File.Delete(newfile);
            sender_slot   = 0;
            sender_parent = null;
        }
示例#2
0
        private void HandleDelete(object sender, EventArgs e)
        {
            int index            = getSlot(sender);
            PokemonListPanel PLC =
                (((sender as ToolStripItem)?.GetCurrentParent() as ContextMenuStrip)?.SourceControl).Parent as
                PokemonListPanel;

            if (PLC == this)
            {
                PLC.delete(index);
            }
        }
示例#3
0
        private void HandleView(object sender, EventArgs e)
        {
            int              index = getSlot(sender);
            MainForm         mf    = FindForm() as MainForm;
            PokemonListPanel PLC   =
                (((sender as ToolStripItem)?.GetCurrentParent() as ContextMenuStrip)?.SourceControl).Parent as
                PokemonListPanel;

            if (PLC == this)
            {
                PLC.view(index, mf);
            }
        }
示例#4
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;
                }
            }
        }
示例#5
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);
                    }
                }
            }
        }
示例#6
0
        private void InitializeControls()
        {
            MoveDataSource = new List <Util.cbItem>();
            foreach (PK1.MoveType m in Enum.GetValues(typeof(PK1.MoveType)).Cast <PK1.MoveType>())
            {
                MoveDataSource.Add(new Util.cbItem {
                    Text = Tables.ID_To_MoveName[(int)m], Value = (int)m
                });
            }
            MoveDataSource = MoveDataSource.OrderBy(cb => cb.Text).ToList();

            foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 })
            {
                cb.DisplayMember = "Text";
                cb.ValueMember   = "Value";
                cb.DataSource    = new BindingSource(MoveDataSource, null);
            }

            SpeciesDataSource = new List <Util.cbItem>();
            foreach (PK1.SpeciesType m in Enum.GetValues(typeof(PK1.SpeciesType)).Cast <PK1.SpeciesType>())
            {
                if (m != PK1.SpeciesType.Missingno)
                {
                    SpeciesDataSource.Add(new Util.cbItem {
                        Text = Tables.ID_To_Name[(int)m], Value = (int)m
                    });
                }
            }
            SpeciesDataSource = SpeciesDataSource.OrderBy(cb => cb.Text).ToList();

            CB_Species.DisplayMember = "Text";
            CB_Species.ValueMember   = "Value";
            CB_Species.DataSource    = new BindingSource(SpeciesDataSource, null);
            CB_Species.SelectedValue = 1;

            foreach (TabPage tp in tabMain.TabPages)
            {
                tp.Select();
            }
            tabMain.SelectTab(tabMain.TabPages[0]);

            TB_OT.Font       = Util.Pokered_US;
            TB_Nickname.Font = Util.Pokered_US;
            TB_SaveName.Font = Util.Pokered_US;
            TB_Rival.Font    = Util.Pokered_US;

            PLC_Box = new PokemonListPanel(new PokemonList(PokemonList.CapacityType.Stored), mnuVSD)
            {
                Location = new Point(16, 35)
            };
            PLC_Party = new PokemonListPanel(new PokemonList(PokemonList.CapacityType.Party), mnuVSD)
            {
                Location = new Point(16, 35)
            };
            PLC_DayCare = new PokemonListPanel(new PokemonList(PokemonList.CapacityType.Daycare), mnuVSD, PokemonList.CAPACITY_DAYCARE)
            {
                Location = new Point(16, 214)
            };

            Tab_BoxDaycare.Controls.Add(PLC_Box);
            Tab_PartyMisc.Controls.Add(PLC_Party);
            Tab_BoxDaycare.Controls.Add(PLC_DayCare);
            foreach (TabPage tp in tabBoxMulti.TabPages)
            {
                tp.Select();
                tp.Enabled = false;
            }
            tabBoxMulti.SelectTab(tabBoxMulti.TabPages[0]);

            foreach (string badge in new[] { "Boulder", "Cascade", "Thunder", "Rainbow", "Soul", "Marsh", "Volcano", "Earth" })
            {
                CLB_Badges.Items.Add(badge);
            }

            foreach (Control c in new Control[] { this, PB_DragOut, tabMain })
            {
                c.AllowDrop  = true;
                c.DragDrop  += MF_DragDrop;
                c.DragEnter += MF_DragEnter;
            }

            foreach (TabPage tp in tabMain.Controls)
            {
                tp.AllowDrop  = true;
                tp.DragDrop  += MF_DragDrop;
                tp.DragEnter += MF_DragEnter;

                foreach (Control c in tp.Controls)
                {
                    c.AllowDrop  = true;
                    c.DragDrop  += MF_DragDrop;
                    c.DragEnter += MF_DragEnter;
                }
            }

            PB_DragOut.MouseDown += PB_MouseDown;
        }