示例#1
0
        /// <summary>
        /// Selects a specific game for which to view the store.
        /// </summary>
        /// <param name="game">The selected game.</param>
        private void SelectGame(Game game)
        {
            // Deselect current game
            this.SelectedGame         = null;
            this.Libraries            = null;
            this.IsLibraryListLoading = true;
            this.ActiveLibrary        = null;
            this.RaisePropertyChanged(nameof(this.Libraries));

            BrowseViewModel.GetInstance().Navigate(NavigationPage.LibrarySelect);

            Task.Run(() =>
            {
                try
                {
                    StoreViewModel.GetInstance().SelectGame(game);

                    // Select new game
                    AccessTokens accessTokens       = SettingsViewModel.GetInstance().AccessTokens;
                    IEnumerable <Library> libraries = SqualrApi.GetLibraries(accessTokens.AccessToken, game.GameId);

                    this.Libraries = new ObservableCollection <Library>(libraries);
                    this.RaisePropertyChanged(nameof(this.Libraries));

                    this.SelectedGame = game;
                }
                catch (Exception ex)
                {
                    OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Error loading libraries", ex);
                    BrowseViewModel.GetInstance().Navigate(NavigationPage.GameSelect);
                }
                finally
                {
                    this.IsLibraryListLoading = false;
                }
            });
        }