Esempio n. 1
0
        void mergeSelectedRows()
        {
            if (importGridView.SelectedRows.Count < 2)
            {
                return;
            }

            RomMatch romMatch = importGridView.SelectedRows[importGridView.SelectedRows.Count - 1].DataBoundItem as RomMatch;

            if (romMatch == null)
            {
                return;
            }
            Game game = romMatch.Game;

            if (game == null)
            {
                return;
            }

            List <GameDisc> discs       = game.GetDiscs();
            List <Game>     removeGames = new List <Game>();

            for (int x = importGridView.SelectedRows.Count - 2; x > -1; x--)
            {
                RomMatch match = importGridView.SelectedRows[x].DataBoundItem as RomMatch;
                if (match == null || match.Game == null || match.Game.GetDiscs().Count > 1)
                {
                    continue;
                }

                GameDisc disc = new GameDisc(game)
                {
                    Path = match.Game.Path, LaunchFile = match.Game.LaunchFile, Number = discs.Count + 1
                };
                discs.Add(disc);
                removeGames.Add(match.Game);
            }
            lock (DB.Instance.SyncRoot)
            {
                DB.Instance.ExecuteTransaction(removeGames, removeGame =>
                {
                    importer.Remove(removeGame.GameID);
                    removeGame.Delete();
                });

                DB.Instance.ExecuteTransaction(discs, disc => disc.Save());
            }

            romMatch.ResetDisplayInfo();
        }
Esempio n. 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);
        }