コード例 #1
0
    public void RefreshCategorizedVisibility()
    {
        lock (GameCategories)
        {
            try
            {
                // Get the master category
                var master = GameCategories.First(x => x.IsMaster);

                // Set the master category visibility
                master.IsVisible = false;

                // Set the categories visibility
                GameCategories.Where(x => !x.IsMaster).ForEach(x => x.IsVisible = Data.UI_CategorizeGames);

                // Set the selected index
                SelectedCategoryIndex = Data.UI_CategorizeGames ? GameCategories.FindItemIndex(x => !x.IsMaster) : GameCategories.FindItemIndex(x => x == master);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Refreshing game category visibility");

                throw;
            }
        }
    }
コード例 #2
0
        /// <summary>
        /// Refreshes the visibility of the categories based on if the games should be categorized
        /// </summary>
        /// <returns>The task</returns>
        public async Task RefreshCategorizedVisibilityAsync()
        {
            using (await AsyncLock.LockAsync())
            {
                try
                {
                    // Get the master category
                    var master = GameCategories.FindItem(x => x.IsMaster);

                    // Set the master category visibility
                    master.IsVisible = false;

                    // Set the categories visibility
                    GameCategories.Where(x => !x.IsMaster).ForEach(x => x.IsVisible = Data.CategorizeGames);

                    // Set the selected index
                    SelectedCategoryIndex = Data.CategorizeGames ? GameCategories.FindItemIndex(x => !x.IsMaster) : GameCategories.FindItemIndex(x => x == master);
                }
                catch (Exception ex)
                {
                    ex.HandleError("Refreshing game category visibility");

                    throw;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Refreshes the added game
        /// </summary>
        /// <returns>The task</returns>
        public async Task RefreshGameAsync(Games game)
        {
            RL.Logger?.LogInformationSource($"The displayed game {game} is being refreshed...");

            using (await AsyncLock.LockAsync())
            {
                try
                {
                    // Make sure the game has been added
                    if (!game.IsAdded())
                    {
                        throw new Exception("Only added games can be refreshed individually");
                    }

                    if (Application.Current.Dispatcher == null)
                    {
                        throw new Exception("Dispatcher can not be NULL");
                    }

                    // Get the display view model
                    var displayVM = game.GetGameInfo().GetDisplayViewModel();

                    // Refresh the game in every category it's available in
                    foreach (var category in GameCategories.Where(x => x.Games.Contains(game)))
                    {
                        RL.Logger?.LogTraceSource($"The displayed game {game} in {category.DisplayName} is being refreshed...");

                        // Get the collection containing the game
                        var collection = category.InstalledGames.Any(x => x.Game == game) ? category.InstalledGames : category.NotInstalledGames;

                        // Get the game index
                        var index = collection.FindItemIndex(x => x.Game == game);

                        // Make sure we got a valid index
                        if (index == -1)
                        {
                            RL.Logger?.LogWarningSource($"The displayed game {game} in {category.DisplayName} could not be refreshed due to not existing in either game collection");

                            return;
                        }

                        // Refresh the game
                        Application.Current.Dispatcher.Invoke(() => collection[index] = displayVM);

                        RL.Logger?.LogTraceSource($"The displayed game {game} in {category.DisplayName} has been refreshed");
                    }
                }
                catch (Exception ex)
                {
                    ex.HandleCritical("Refreshing game", game);
                    throw;
                }
            }

            RL.Logger?.LogInformationSource($"The displayed game {game} has been refreshed");
        }
コード例 #4
0
    public async Task RefreshGameAsync(Games game)
    {
        Logger.Info("The displayed game {0} is being refreshed...", game);

        using (await AsyncLock.LockAsync())
        {
            try
            {
                // Make sure the game has been added
                if (!game.IsAdded())
                {
                    throw new Exception("Only added games can be refreshed individually");
                }

                // Get the display view model
                var displayVM = game.GetGameInfo().GetDisplayViewModel();

                // Refresh the game in every category it's available in
                foreach (var category in GameCategories.Where(x => x.Games.Contains(game)))
                {
                    Logger.Trace("The displayed game {0} in {1} is being refreshed...", game, category.DisplayName);

                    // Get the collection containing the game
                    var collection = category.InstalledGames.Any(x => x.Game == game) ? category.InstalledGames : category.NotInstalledGames;

                    // Get the game index
                    var index = collection.FindItemIndex(x => x.Game == game);

                    // Make sure we got a valid index
                    if (index == -1)
                    {
                        Logger.Warn("The displayed game {0} in {1} could not be refreshed due to not existing in either game collection", game, category.DisplayName);

                        return;
                    }

                    // Refresh the game
                    collection[index] = displayVM;

                    Logger.Trace("The displayed game {0} in {1} has been refreshed", game, category.DisplayName);
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex, "Refreshing game {0}", game);
                throw;
            }
        }

        Logger.Info("The displayed game {0} has been refreshed", game);
    }