Example #1
0
        internal DesignerDataViewModel()
        {
            GameGroups = new ObservableCollection <GameGroup>();

            var           gameInfos          = new List <GameInformation>();
            var           rand               = new Random(DateTime.Now.Millisecond);
            GameDataStore emptyGameDataStore = new GameDataStore();

            gameInfos.Add(new GameInformation(emptyGameDataStore, "Jesus vs Kim", GameType.OfflineTwoPlayer, DateTime.Now - new TimeSpan(rand.Next(100000)), 4, true));
            gameInfos.Add(new GameInformation(emptyGameDataStore, "BenCohen", GameType.OfflineTwoPlayer, DateTime.Now - new TimeSpan(rand.Next(100000)), 7, true));
            gameInfos.Add(new GameInformation(emptyGameDataStore, "Jesse", GameType.OfflineTwoPlayer, DateTime.Now - new TimeSpan(rand.Next(100000)), 12, true));
            gameInfos.Add(new GameInformation(emptyGameDataStore, "Peter", GameType.OfflineTwoPlayer, DateTime.Now - new TimeSpan(rand.Next(100000)), 1, true));

            var activeGameGroup = new GameGroup(null, "Active Games", null, null, null);

            foreach (var gameInfo in gameInfos)
            {
                activeGameGroup.Items.Add(new Game(gameInfo));
            }

            var completedGameGroup = new GameGroup(null, "Completed Games", null, null, null);

            foreach (var gameInfo in gameInfos)
            {
                completedGameGroup.Items.Add(new Game(gameInfo));
            }

            GameGroups.Add(activeGameGroup);
            GameGroups.Add(completedGameGroup);
        }
Example #2
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"));
        }