示例#1
0
 public MainViewModel()
 {
     InstantiateCommands();
     GamesRecievier = GameModelDatabaseRecieverFactory.Factory.GetInstance();
     Games          = new ObservableCollection <GameModel>(GamesRecievier.GetAll());
     DataContext    = this;
 }
示例#2
0
        private void DeleteGame(object sender)
        {
            if (sender == null)
            {
                return;
            }
            var canDelete = MessageBox.Show("Do you want delete this game from your list?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (canDelete == MessageBoxResult.Yes)
            {
                GamesRecievier.Delete(sender as GameModel);
                Games = new ObservableCollection <GameModel>(GamesRecievier.GetAll());
            }
        }
示例#3
0
        //Gamelist updated depending on list option change
        public void ChooseList(object sender)
        {
            switch (sender)
            {
            case "0":
                Label = "All Games";
                Games = new ObservableCollection <GameModel>(GamesRecievier.GetAll());
                break;

            case "1":
                Label = "Played Games";
                var playedGames = GamesRecievier.GetAll().Where(x => x.GetStatus == GameModel.Status.Played).ToList();
                Games = new ObservableCollection <GameModel>(playedGames);

                break;

            case "2":
                Label = "Playing Games";
                var playingGames = GamesRecievier.GetAll().Where(x => x.GetStatus == GameModel.Status.Playing).ToList();
                Games = new ObservableCollection <GameModel>(playingGames);
                break;

            case "3":
                Label = "Not Played Games";
                var notPlayedGames = GamesRecievier.GetAll().Where(x => x.GetStatus == GameModel.Status.Not_Played).ToList();
                Games = new ObservableCollection <GameModel>(notPlayedGames);
                break;

            case "4":
                Label = "Upcoming Games";
                var upcomingGames = GamesRecievier.GetAll().Where(x => x.FirstReleaseDate >= Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds)).ToList();
                Games = new ObservableCollection <GameModel>(upcomingGames);
                break;

            default:
                MessageBox.Show("Pick List");
                break;
            }
        }