예제 #1
0
        private void clickDelete(object sender, EventArgs e)
        {
            string name = (sender is ToolStripItem)
                ? ((sender as ToolStripItem).Owner as ContextMenuStrip).SourceControl.Name
                : (sender as PictureBox).Name;

            int index   = Array.FindIndex(PKXBOXES, p => p.Name == name);
            var dataArr = Results.Skip(SCR_Box.Value * RES_MIN).Take(RES_MAX).ToArray();

            if (index >= dataArr.Length)
            {
                System.Media.SystemSounds.Exclamation.Play();
            }
            else
            {
                var    pk   = dataArr[index];
                string path = pk.Identifier;

                if (path.Contains(Path.DirectorySeparatorChar))
                {
                    // Data from Database: Delete file from disk
                    File.Delete(path);
                }
                else
                {
                    // Data from Box: Delete from save file
                    string[] split  = pk.Identifier.Split(':');
                    int      box    = Convert.ToInt32(split[0].Substring(1)) - 1;
                    int      slot   = Convert.ToInt32(split[1]) - 1;
                    int      spot   = box * 30 + slot;
                    int      offset = Main.SAV.Box + spot * PK6.SIZE_STORED;
                    var      pkSAV  = Main.SAV.getPK6Stored(offset);

                    if (pkSAV.Data.SequenceEqual(pk.Data))
                    {
                        Main.SAV.setEK6Stored(Main.blankEK6, offset);
                        m_parent.setPKXBoxes();
                    }
                    else
                    {
                        Util.Error("Database slot data does not match save data!", "Don't move Pokémon after initializing the Database, please re-open the Database viewer.");
                        return;
                    }
                }
                // Remove from database.
                RawDB.Remove(pk);
                Results.Remove(pk);
                // Refresh database view.
                L_Count.Text = String.Format(Counter, Results.Count);
                slotSelected = -1;
                FillPKXBoxes(SCR_Box.Value);
                System.Media.SystemSounds.Asterisk.Play();
            }
        }
예제 #2
0
        private void clickDelete(object sender, EventArgs e)
        {
            sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
            int index = Array.IndexOf(PKXBOXES, sender);

            var dataArr = Results.Skip(SCR_Box.Value * RES_MIN).Take(RES_MAX).ToArray();

            if (index >= dataArr.Length)
            {
                System.Media.SystemSounds.Exclamation.Play();
            }
            else
            {
                var    pk   = dataArr[index];
                string path = pk.Identifier;

                if (path.Contains(Path.DirectorySeparatorChar))
                {
                    // Data from Database: Delete file from disk
                    File.Delete(path);
                }
                else
                {
                    // Data from Box: Delete from save file
                    int box    = pk.Box - 1;
                    int slot   = pk.Slot - 1;
                    int offset = Main.SAV.getBoxOffset(box) + slot * Main.SAV.SIZE_STORED;
                    PKM pkSAV  = Main.SAV.getStoredSlot(offset);

                    if (pkSAV.Data.SequenceEqual(pk.Data))
                    {
                        Main.SAV.setStoredSlot(Main.SAV.BlankPKM, offset);
                        m_parent.setPKXBoxes();
                    }
                    else
                    {
                        Util.Error("Database slot data does not match save data!", "Don't move Pokémon after initializing the Database, please re-open the Database viewer.");
                        return;
                    }
                }
                // Remove from database.
                RawDB.Remove(pk);
                Results.Remove(pk);
                // Refresh database view.
                L_Count.Text = string.Format(Counter, Results.Count);
                slotSelected = -1;
                FillPKXBoxes(SCR_Box.Value);
                System.Media.SystemSounds.Asterisk.Play();
            }
        }