private void buttonSearch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                resultsView.Clear();

                var engine  = new ScraperEngine();
                var results = AsyncHelper.RunSync <List <Game> >(() => engine.SearchAsync((Scraper)comboScraper.SelectedItem, (Platform)comboPlatform.SelectedItem,
                                                                                          textQuery.Text.Trim(), this.GameToMatch.GameFilename));
                if (results.Count > 0)
                {
                    resultsView.Load(this.CatalogEditor, results);
                }
                else
                {
                    resultsView.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBoxHelper.ShowError(this, ex);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
Exemplo n.º 2
0
        public MatchGamesDialog(CatalogEditor catalogEditor)
        {
            InitializeComponent();
            App.SetWindowFont(this);
            this.Closing += MatchGamesDialog_Closing;

            this.CatalogEditor = catalogEditor;
            this.Games         = this.CatalogEditor.GatherIncompleteGames();

            foreach (var scraper in ScraperEngine.GatherScrapers(this.CatalogEditor.Config.FolderPath))
            {
                comboScraper.Items.Add(scraper);
            }
            if (comboScraper.Items.Count > 0)
            {
                comboScraper.SelectedIndex = 0;
            }
        }
        public async Task LoadAsync(Game game)
        {
            // Record.
            this.GameToMatch = game;
            textQuery.Text   = await ScraperEngine.GetGameNameAsync(game.Platform, game.GameFilename);

            comboPlatform.SelectedItem = game.Platform;

            // Load the scrapers.
            var scrapers = ScraperEngine.GatherScrapers(this.CatalogEditor.Config.FolderPath);

            if (scrapers.Count > 0)
            {
                foreach (var scraper in scrapers)
                {
                    comboScraper.Items.Add(scraper);
                }
                comboScraper.SelectedIndex = 0;
            }
        }
Exemplo n.º 4
0
        private async Task MatchNowAsync(DoWorkEventArgs e)
        {
            int index  = 0;
            var engine = new ScraperEngine();

            // Match.
            foreach (var game in this.GamesToMatch)
            {
                // Exit if cancellation pending.
                if (this.BackgroundWorker.CancellationPending)
                {
                    break;
                }

                index++;
                ReportProgress(index, "Matching " + index + "/" + this.GamesToMatch.Count + ": " + game.GameFilename + "...");
                try
                {
                    var query = await ScraperEngine.GetGameNameAsync(game.Platform, game.GameFilename);

                    var matchedGame = await engine.SearchExactAsync(this.Scraper, game.Platform, query, game.GameFilename);

                    if (matchedGame != null)
                    {
                        await this.CatalogEditor.MatchGameAsync(game, matchedGame,
                                                                await HttpHelper.DownloadFileContentsAsync(matchedGame.ImageFilePath));

                        ReportProgress(index, "MATCHED\n");
                    }
                    else
                    {
                        ReportProgress(index, "Not Matched\n");
                    }
                }
                catch (Exception ex)
                {
                    ReportProgress(index, "ERROR: " + ex.Message + "\n");
                }
            }
        }