示例#1
0
        /// <summary>
        /// Initialize the groups of active and completed games. Fetches the games from disk
        /// and adds them to the apporpiate GameGroup.
        /// </summary>
        private async void GetGameGroups()
        {
            var activeGames = await _dataService.GetActiveGamesAsync();
            var completedGames = await _dataService.GetCompletedGamesAsync();

            var activeGameGroup = new GameGroup(null, "Active Games", null, null, null);
            foreach (var game in activeGames)
            {
                var gameInfo = await _dataService.GetGameInformationAsync(game.GameID);
                activeGameGroup.Items.Add(new Game(gameInfo));
            }

            var completedGameGroup = new GameGroup(null, "Completed Games", null, null, null);
            foreach (var game in completedGames)
            {
                var gameInfo = await _dataService.GetGameInformationAsync(game.GameID);
                completedGameGroup.Items.Add(new Game(gameInfo));
            }

            _gameGroups.Add(activeGameGroup);
            _gameGroups.Add(completedGameGroup);

            OnPropertyChanged(new PropertyChangedEventArgs("GameGroups"));
        }