示例#1
0
        public void LoadingProposal(GameRom game)
        {
            Search searchedGame = new Search();

            if (CurrentScrapeSource == ScraperSource.IGDB)
            {
                if (game.IGDBID < 1)
                {
                    searchedGame = dialogService.SearchSteamGridDBByName(game.Name, CurrentScrapeSource);
                    if (searchedGame != null)
                    {
                        game.IGDBID = searchedGame.id;
                    }
                }
            }
            else if (CurrentScrapeSource == ScraperSource.SGDB)
            {
                if (game.SGDBID < 1)
                {
                    searchedGame = dialogService.SearchSteamGridDBByName(game.Name, CurrentScrapeSource);
                    if (searchedGame != null)
                    {
                        game.SGDBID = searchedGame.id;
                    }
                }
            }

            if (searchedGame != null)
            {
                ResultImgs = new ObservableCollection <string>();
                if (CurrentScraperType == ScraperType.Logo)
                {
                    var result = steamGridDBService.GetLogoForId(game.SGDBID);
                    if (result != null)
                    {
                        foreach (var img in result)
                        {
                            ResultImgs.Add(img.url);
                        }
                    }
                }
                else if (CurrentScraperType == ScraperType.ArtWork)
                {
                    IEnumerable <ImgResult> result;
                    if (CurrentScrapeSource == ScraperSource.SGDB)
                    {
                        result = steamGridDBService.GetHeroesForId(game.SGDBID);
                        if (result != null)
                        {
                            foreach (var img in result)
                            {
                                ResultImgs.Add(img.url);
                            }
                        }
                    }
                    else if (CurrentScrapeSource == ScraperSource.IGDB)
                    {
                        var detailart = iGDBService.GetArtworksByGameId(game.IGDBID);
                        var detailsch = iGDBService.GetScreenshotsByGameId(game.IGDBID);
                        if (detailart != null)
                        {
                            var resultartigdb = detailart.Select(x => iGDBService.GetArtWorkLink(x.image_id));
                            foreach (var img in resultartigdb)
                            {
                                ResultImgs.Add(img);
                            }
                        }
                        if (detailsch != null)
                        {
                            var resultschigdb = detailsch.Select(x => iGDBService.GetArtWorkLink(x.image_id));
                            foreach (var img in resultschigdb)
                            {
                                ResultImgs.Add(img);
                            }
                        }
                    }
                }
                else if (CurrentScraperType == ScraperType.Banner)
                {
                    var result = steamGridDBService.GetGridBannerForId(game.SGDBID);
                    if (result != null)
                    {
                        foreach (var img in result)
                        {
                            ResultImgs.Add(img.url);
                        }
                    }
                }
                else if (CurrentScraperType == ScraperType.Boxart)
                {
                    if (CurrentScrapeSource == ScraperSource.SGDB)
                    {
                        var result = steamGridDBService.GetGridBoxartForId(game.SGDBID);
                        if (result != null)
                        {
                            foreach (var img in result)
                            {
                                ResultImgs.Add(img.url);
                            }
                        }
                    }
                    else if (CurrentScrapeSource == ScraperSource.IGDB)
                    {
                        var detail = iGDBService.GetDetailsGame(game.IGDBID);
                        ResultImgs.Add(iGDBService.GetCoverLink(detail.cover.image_id));
                    }
                }
                NBImg            = ResultImgs.Count;
                SelectedImgIndex = 0;
            }
        }