void updatePositions() { if (!updateEmuPositions) return; List<Emulator> emus = new List<Emulator>(); foreach (ListViewItem item in emulatorListView.Items) { Emulator emu = item.Tag as Emulator; if (emu.Position != item.Index) { emu.Position = item.Index; emus.Add(emu); } } var handler = new BackgroundTaskHandler<Emulator>() { Items = emus }; handler.StatusDelegate = o => { return string.Format("Updating {0} position...", o.Title); }; handler.ActionDelegate = o => { o.SavePosition(); }; using (Conf_ProgressDialog dlg = new Conf_ProgressDialog(handler)) dlg.ShowDialog(); updateEmuPositions = false; }
void delRomButton_Click(object sender, EventArgs e) { if (dBListView.SelectedItems.Count == 0) return; DialogResult dlg = MessageBox.Show( "Are you sure you want to delete the selected Game(s) and add them to the ignored files list?", "Delete Game(s)?", MessageBoxButtons.YesNo ); if (dlg != DialogResult.Yes) return; selectedListItem = null; saveSelectedGame = false; saveThumbs = false; savePCSettings = false; saveDiscs = false; List<Game> games = new List<Game>(); foreach (ListViewItem item in dBListView.SelectedItems) games.Add((Game)item.Tag); BackgroundTaskHandler<Game> handler = new BackgroundTaskHandler<Game>() { Items = games }; handler.StatusDelegate = game => { return "removing " + game.Title; }; handler.ActionDelegate = game => { foreach (GameDisc disc in game.Discs) EmulatorsCore.Options.AddIgnoreFile(disc.Path); game.Delete(); }; using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler)) progressDlg.ShowDialog(); dBListView.SelectedItems.Clear(); UpdatePanel(); }
void delRomButton_Click(object sender, EventArgs e) { if (importGridView.SelectedRows.Count < 1) return; if (MessageBox.Show( "Are you sure you want to delete the selected Game(s) and add them to the ignored files list?", "Delete Game(s)?", MessageBoxButtons.YesNo) != DialogResult.Yes) return; List<Game> games = new List<Game>(); foreach (DataGridViewRow row in importGridView.SelectedRows) { RomMatch match = row.DataBoundItem as RomMatch; if (match != null && match.Game != null) games.Add(match.Game); } BackgroundTaskHandler<Game> handler = new BackgroundTaskHandler<Game>() { Items = games }; handler.StatusDelegate = game => { return "removing " + game.Title; }; handler.ActionDelegate = game => { foreach (GameDisc disc in game.Discs) EmulatorsCore.Options.AddIgnoreFile(disc.Path); game.Delete(); }; using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler)) progressDlg.ShowDialog(); }
void sendToImporter(IEnumerable<Game> games) { Importer importer = Importer; if (importer == null) return; BackgroundTaskHandler handler = new BackgroundTaskHandler(); handler.StatusDelegate = () => { return "sending to Importer..."; }; handler.ActionDelegate = () => { importer.AddGames(games); }; using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler)) progressDlg.ShowDialog(); }
void ignoreButton_Click(object sender, EventArgs e) { if (importGridView.SelectedRows.Count < 1) return; List<RomMatch> matches = new List<RomMatch>(); foreach (DataGridViewRow row in importGridView.SelectedRows) { RomMatch match = row.DataBoundItem as RomMatch; if (match != null) matches.Add(match); } if (matches.Count == 0) return; else if (matches.Count == 1) importer.Ignore(matches[0]); else { BackgroundTaskHandler handler = new BackgroundTaskHandler(); handler.StatusDelegate = () => { return "Ignoring roms..."; }; handler.ActionDelegate = () => { importer.Ignore(matches); }; using (Conf_ProgressDialog dlg = new Conf_ProgressDialog(handler)) dlg.ShowDialog(); } updateButtons(); }