public IEnumerable<IResult> ExecuteSearch() {
            var search = new SearchGames {
                SearchText = SearchText
            }.AsResult();

            yield return Show.Busy();
            yield return search;

            var resultCount = search.Response.Count();

            if(resultCount == 0)
                SearchResults = noResults.WithTitle(SearchText);
            else if(resultCount == 1 && search.Response.First().Title == SearchText) {
                var getGame = new GetGame {
                    Id = search.Response.First().Id
                }.AsResult();

                yield return getGame;
                yield return Show.Child<ExploreGameViewModel>()
                    .In<IShell>()
                    .Configured(x => x.WithGame(getGame.Response));
            }
            else SearchResults = results.With(search.Response);

            yield return Show.NotBusy();
        }
        public IEnumerable<IResult> ExecuteSearch()
        {
            //TALK: AsResult (extension method) wraps our SearchGames query into a new 
            // QueryResult<IEnumerable<SearchResult>> 
            QueryResult<IEnumerable<SearchResult>> search = new SearchGames
                                                                {
                                                                    SearchText = SearchText
                                                                }.AsResult();

            yield return Show.Busy();
            yield return search;

            int resultCount = search.Response.Count();

            if (resultCount == 0)
                SearchResults = _noResults.WithTitle(SearchText);
            else if (resultCount == 1 && search.Response.First().Title == SearchText)
            {
                QueryResult<GameDTO> getGame = new GetGame
                                                   {
                                                       Id = search.Response.First().Id
                                                   }.AsResult();

                yield return getGame;
                yield return Show.Child<ExploreGameViewModel>()
                    .In<IShell>()
                    .Configured(x => x.WithGame(getGame.Response));
            }
            else SearchResults = _results.With(search.Response);

            yield return Show.NotBusy();
        }
Example #3
0
        public IEnumerable <IResult> ExecuteSearch()
        {
            var search = new SearchGames {
                SearchText = SearchText
            }.AsResult();

            yield return(Show.Busy());

            yield return(search);

            var resultCount = search.Response.Count();

            if (resultCount == 0)
            {
                SearchResults = noResults.WithTitle(SearchText);
            }
            else if (resultCount == 1 && search.Response.First().Title == SearchText)
            {
                var getGame = new GetGame {
                    Id = search.Response.First().Id
                }.AsResult();

                yield return(getGame);

                yield return(Show.Child <ExploreGameViewModel>()
                             .In <IShell>()
                             .Configured(x => x.WithGame(getGame.Response)));
            }
            else
            {
                SearchResults = results.With(search.Response);
            }

            yield return(Show.NotBusy());
        }
        /// <summary>
        /// Scans for games asynchronous.
        /// </summary>
        /// <param name="searchOptions">The search options.</param>
        private async void ScanForGamesAsync(SearchOptions searchOptions)
        {
            SearchGames.Clear();

            foreach (var system in _hyperspinManager.Systems)
            {
                //xml path for system
                var dbPath = Path.Combine(_settingsRepo.HypermintSettings.HsPath, "Databases", system.Name, $"{system.Name}.xml");

                //only scan if xml exists
                if (File.Exists(dbPath))
                {
                    try
                    {
                        var games = await _hsXmlPRovider.SearchXmlAsync(_settingsRepo.HypermintSettings.HsPath, system.Name, dbPath, searchOptions.SearchString);

                        foreach (var game in games)
                        {
                            //Get the wheel image if game has one or set to no image.
                            var wheelImage = Path.Combine(_settingsRepo.HypermintSettings.HsPath, "Media", system.Name, "Images\\Wheel\\" + game.RomName + ".png");
                            if (!File.Exists(wheelImage))
                            {
                                wheelImage = _noWheelImage;
                            }

                            SearchGames.Add(new GameSearch {
                                Game = game, WheelImage = wheelImage
                            });
                        }

                        GamesFoundCount = searchedGames.Count;

                        currentPage = 1;
                        pageCount   = GamesFoundCount / 5;
                        if (GamesFoundCount % 5 != 0)
                        {
                            pageCount++;
                        }

                        PageInfo = currentPage + " | " + pageCount + "      Games found: " + GamesFoundCount;

                        FilteredGames = new ListCollectionView(searchedGames.Take(5).ToList());

                        FilteredGames.CurrentChanged += FilteredGames_CurrentChanged;
                    }

                    catch (Exception ex) { _ea.GetEvent <ErrorMessageEvent>().Publish($"Error searching: {ex.Message}"); }
                }
            }
        }
        private async void RefreshStreamPanel(TwitchList <Stream> p_followed, bool p_isHost, List <string> p_hosters = null)
        {
            for (int i = 0; i < p_followed.List.Count; i++)
            {
                Stream stream = p_followed.List[i];
                if (stream != null)
                {
                    // Create images preview.
                    System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                    string url = stream.Preview.Large;
                    Uri    uri = new Uri(url);
                    var    bmp = new BitmapImage();
                    bmp.BeginInit();
                    bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                    bmp.UriSource     = uri;
                    bmp.EndInit();
                    img.Source = bmp;

                    // Create Images cover.
                    System.Windows.Controls.Image img2 = new System.Windows.Controls.Image();
                    img2.HorizontalAlignment = HorizontalAlignment.Right;
                    img2.VerticalAlignment   = VerticalAlignment.Bottom;
                    img2.Stretch             = Stretch.None;
                    try
                    {
                        SearchGames sGame = await TwitchClient.SearchGamesAsyncV5(stream.Game);

                        Game game = sGame.Games[0];
                        img2.ToolTip = game.Name;
                        Uri         uri2 = new Uri(game.Box.Small);
                        BitmapImage bmp2 = new BitmapImage(uri2);
                        img2.Source = bmp2;
                    }
                    catch
                    {
                        img2.ToolTip = "I AM ERROR";
                        Uri         uri2 = new Uri(stream.Preview.Small);
                        BitmapImage bmp2 = new BitmapImage(uri2);
                        img2.Source = bmp2;
                    }

                    // Create grid.
                    Grid grid = new Grid();
                    grid.Margin = new Thickness(0, 10, 0, 0);
                    grid.Children.Add(img);
                    grid.Children.Add(img2);

                    // Create Textblock
                    string viewers   = stream.Viewers + " viewers";
                    double fps       = stream.AverageFps;
                    string framerate = String.Empty;
                    if (fps > 50)
                    {
                        framerate = "60";
                    }
                    string quality = " - Max quality: " + stream.VideoHeight + "p" + framerate;
                    string hoster  = String.Empty;
                    if (p_hosters != null)
                    {
                        hoster = "Hosted by " + p_hosters[i] + Environment.NewLine;
                    }
                    TextBlock title = new TextBlock();
                    title.Text         = hoster + viewers + quality + Environment.NewLine + stream.Channel.Status;
                    title.Height       = 60;
                    title.FontSize     = 15;
                    title.TextWrapping = TextWrapping.Wrap;
                    title.FontWeight   = FontWeights.Bold;
                    title.FontFamily   = Globals.OldNewspaperTypes;

                    // Create buttons.
                    Button myButton = new Button();
                    myButton.Content             = stream.Channel.Name;
                    myButton.FontFamily          = Globals.OldNewspaperTypes;
                    myButton.Click              += new RoutedEventHandler(startLoadedStream_Click);
                    myButton.MouseRightButtonUp += new MouseButtonEventHandler(CopyPastUsername_RightClick);

                    // Add image and button in the right panel.
                    if (p_isHost)
                    {
                        switch (i % 4)
                        {
                        case 0:
                            panelHostRight1.Children.Add(grid);
                            panelHostRight1.Children.Add(title);
                            panelHostRight1.Children.Add(myButton);
                            break;

                        case 1:
                            panelHostRight2.Children.Add(grid);
                            panelHostRight2.Children.Add(title);
                            panelHostRight2.Children.Add(myButton);
                            break;

                        case 2:
                            panelHostRight3.Children.Add(grid);
                            panelHostRight3.Children.Add(title);
                            panelHostRight3.Children.Add(myButton);
                            break;

                        case 3:
                            panelHostRight4.Children.Add(grid);
                            panelHostRight4.Children.Add(title);
                            panelHostRight4.Children.Add(myButton);
                            break;
                        }
                    }
                    else
                    {
                        switch (i % 4)
                        {
                        case 0:
                            panelRight1.Children.Add(grid);
                            panelRight1.Children.Add(title);
                            panelRight1.Children.Add(myButton);
                            break;

                        case 1:
                            panelRight2.Children.Add(grid);
                            panelRight2.Children.Add(title);
                            panelRight2.Children.Add(myButton);
                            break;

                        case 2:
                            panelRight3.Children.Add(grid);
                            panelRight3.Children.Add(title);
                            panelRight3.Children.Add(myButton);
                            break;

                        case 3:
                            panelRight4.Children.Add(grid);
                            panelRight4.Children.Add(title);
                            panelRight4.Children.Add(myButton);
                            break;
                        }
                    }
                }
            }
            if (p_isHost)
            {
                loaderHost.Visibility = Visibility.Hidden;
                m_loadingHost         = false;
            }
            else
            {
                loaderStream.Visibility = Visibility.Hidden;
                m_loadingChannel        = false;
            }
        }
Example #6
0
        public IEnumerable<IResult> ExecuteSearch()
        {
            var search = new SearchGames
            {
                SearchText = SearchText
            }.AsResult();

            yield return Show.Busy();
            yield return search;

            var hits = search.Response.Hits;

            if (hits.Count() == 0)
                SearchResults = _noResults.WithTitle(SearchText);
            else if (hits.Count() == 1 && hits.First().Title == SearchText)
            {
                var getGame = new GetGame
                {
                    Id = hits.First().Id
                }.AsResult();

                yield return getGame;
                yield return Show.Screen<ExploreGameViewModel>()
                    .Configured(x => x.WithGame(getGame.Response));
            }
            else SearchResults = _results.With(hits);

            yield return Show.NotBusy();
        }