コード例 #1
0
ファイル: SAV_Database.cs プロジェクト: cybercarrot/PKHeX
        private void clickSet(object sender, EventArgs e)
        {
            // Don't care what slot was clicked, just add it to the database
            if (!m_parent.verifiedPKX())
            {
                return;
            }

            PK6 pk = new PK6(m_parent.preparepkx());

            if (!Directory.Exists(DatabasePath))
            {
                Directory.CreateDirectory(DatabasePath);
            }

            string path = Path.Combine(DatabasePath, Util.CleanFileName(pk.FileName));

            if (RawDB.Any(p => p.Identifier == path))
            {
                Util.Alert("File already exists in database!");
                return;
            }

            File.WriteAllBytes(path, pk.Data.Take(PK6.SIZE_STORED).ToArray());
            pk.Identifier = path;

            RawDB.Add(pk);
            RawDB = new List <PK6>(RawDB.Distinct());     // just in case
            Results.Add(pk);
            Results = new List <PK6>(Results.Distinct()); // just in case
            // Refresh database view.
            L_Count.Text = String.Format(Counter, Results.Count);
            FillPKXBoxes(SCR_Box.Value);
            Util.Alert("Added Pokémon from tabs to database.", "Please refresh the search to ensure it shows up; it may be at the bottom of the results.");
        }
コード例 #2
0
ファイル: SAV_Database.cs プロジェクト: Tzukkeli/PKHeX
        private void clickSet(object sender, EventArgs e)
        {
            // Don't care what slot was clicked, just add it to the database
            if (!m_parent.verifiedPKX())
            {
                return;
            }

            PK6 pk = m_parent.preparepkx();

            if (!Directory.Exists(DatabasePath))
            {
                Directory.CreateDirectory(DatabasePath);
            }

            string path = Path.Combine(DatabasePath, Util.CleanFileName(pk.FileName));

            if (RawDB.Any(p => p.Identifier == path))
            {
                Util.Alert("File already exists in database!");
                return;
            }

            File.WriteAllBytes(path, pk.Data.Take(PK6.SIZE_STORED).ToArray());
            pk.Identifier = path;

            int pre = RawDB.Count;

            RawDB.Add(pk);
            RawDB = new List <PK6>(RawDB.Distinct()); // just in case
            int post = RawDB.Count;

            if (pre == post)
            {
                Util.Alert("Pokémon already exists in database."); return;
            }
            Results.Add(pk);

            // Refresh database view.
            L_Count.Text = string.Format(Counter, Results.Count);
            slotSelected = Results.Count - 1;
            slotColor    = Properties.Resources.slotSet;
            if ((SCR_Box.Maximum + 1) * 6 < Results.Count)
            {
                SCR_Box.Maximum += 1;
            }
            SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - PKXBOXES.Length / 6 + 1);
            FillPKXBoxes(SCR_Box.Value);
            Util.Alert("Added Pokémon from tabs to database.");
        }