コード例 #1
0
        private void delDiscButton_Click(object sender, EventArgs e)
        {
            if (discGridView.SelectedRows.Count < 1)
            {
                return;
            }

            if (MessageBox.Show("Are you sure you want to delete the selected discs\r\nand add them to the ignored files list?", "Delete discs?", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            List <GameDisc> discs       = new List <GameDisc>();
            List <int>      indices     = new List <int>();
            bool            currentDisc = false;

            for (int x = 0; x < discGridView.SelectedRows.Count; x++)
            {
                DataGridViewRow row = discGridView.SelectedRows[x];
                if (!currentDisc)
                {
                    currentDisc = ((GameDisc)row.DataBoundItem).Selected;
                }
                indices.Add(row.Index);
            }

            int selectedIndex = indices.Count > 0 ? indices[0] : 0;

            DB.Instance.ExecuteTransaction(indices, index =>
            {
                GameDisc disc = discGridView.Rows[index].DataBoundItem as GameDisc;
                if (disc != null)
                {
                    Options.Instance.AddIgnoreFile(disc.Path);
                    disc.Delete();
                }
                discBindingSource.RemoveAt(index);
            });

            if (discBindingSource.Count > 0)
            {
                updateDiscNumbers();
                if (selectedIndex > discBindingSource.Count - 1)
                {
                    selectedIndex = discBindingSource.Count - 1;
                }

                DataGridViewRow row = discGridView.Rows[selectedIndex];
                row.Selected = true;
                if (currentDisc)
                {
                    ((GameDisc)row.DataBoundItem).Selected = true;
                }
            }

            saveDiscs = true;
        }
コード例 #2
0
        void unMergeSelectedRow()
        {
            if (importGridView.SelectedRows.Count != 1)
            {
                return;
            }

            DataGridViewRow selectedRow = importGridView.SelectedRows[0];
            RomMatch        romMatch    = selectedRow.DataBoundItem as RomMatch;

            if (romMatch == null)
            {
                return;
            }
            List <GameDisc> discs = romMatch.Game.GetDiscs();

            if (discs.Count < 2)
            {
                return;
            }
            romMatch.ResetDisplayInfo();
            romMatch.Game.CurrentDiscNum = 1;
            romMatch.Game.SaveGamePlayInfo();
            List <Game> newGames = new List <Game>();

            for (int x = 0; x < discs.Count; x++)
            {
                GameDisc disc = discs[x];
                disc.Delete();
                if (x > 0)
                {
                    Game newGame = new Game(disc.Path, romMatch.Game.ParentEmulator)
                    {
                        LaunchFile = disc.LaunchFile
                    };
                    newGame.Save();
                    newGames.Add(newGame);
                    importerBindingSource.Insert(selectedRow.Index + x, new RomMatch(newGame)
                    {
                        BindingSourceIndex = romMatch.BindingSourceIndex + x
                    });
                }
            }
            importer.AddGames(newGames);
        }