Ejemplo n.º 1
0
        public async void GameSelected(ItemClickEventArgs eventArgs)
        {
            PageIsEnabled          = false;
            ProgressRingIsActive   = true;
            ProgressRingVisibility = Visibility.Visible;

            GameViewModel gameViewModel = (GameViewModel)eventArgs.ClickedItem;
            Season        seasonToPass  = new Season()
            {
                name = selectedSeason.name, owningTeam = selectedSeason.owningTeam, seasonId = selectedSeason.seasonId, year = selectedSeason.year, games = new BindableCollection <Game>()
            };                                                                                                                                                                                                               //Because we're changing the games in this season, we need to make a copy.

            seasonToPass.games.Add(gameViewModel.GameModel);

            if (!gameViewModel.IsLastViewed)
            {
                try
                {
                    await gameViewModel.FetchPlaylists;
                    navigationService.NavigateToViewModel <SectionViewModel>(new PageParameter {
                        season = seasonToPass, hubGroups = Groups, playlist = new Playlist()
                    });

                    if (gameViewModel.IsNextGame)
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel, Logger.LOG_GAME_NEXT);
                    }
                    else if (gameViewModel.IsPreviousGame)
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel, Logger.LOG_GAME_PREVIOUS);
                    }
                    else
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel);
                    }
                }
                catch
                {
                    navigationService.NavigateToViewModel <ErrorViewModel>();
                }
            }
            else
            {
                Playlist downloadedPlaylist = DownloadAccessor.Instance.downloadedPlaylists.Where(u => u.playlistId == gameViewModel.GameModel.gameId).FirstOrDefault();
                if (downloadedPlaylist != null)
                {
                    navigationService.NavigateToViewModel <VideoPlayerViewModel>(new PageParameter {
                        season = seasonToPass, hubGroups = Groups, playlist = downloadedPlaylist
                    });
                    Logger.Instance.LogLastViewedClick(downloadedPlaylist);
                }
                else
                {
                    ClipResponse response = await ServiceAccessor.GetPlaylistClipsAndHeaders(gameViewModel.GameModel.gameId);

                    Playlist lastViewedPlaylist = new Playlist {
                        playlistId = gameViewModel.GameModel.gameId, name = gameViewModel.GameModel.opponent, thumbnailLocation = gameViewModel.Thumbnail, clips = response.clips, displayColumns = response.DisplayColumns, clipCount = response.clips.Count
                    };
                    navigationService.NavigateToViewModel <VideoPlayerViewModel>(new PageParameter {
                        season = seasonToPass, hubGroups = Groups, playlist = lastViewedPlaylist
                    });
                    Logger.Instance.LogLastViewedClick(lastViewedPlaylist);
                }
            }
        }
Ejemplo n.º 2
0
        private void PopulateGroups()
        {
            BindableCollection<HubGroupViewModel> NewGroups = new BindableCollection<HubGroupViewModel>();

            //If these aren't set here, if there is no schedule, these still link to another season's next and last games.
            _previousGame = null;
            _nextGame = null;

            games = selectedSeason.games;
            if (ServiceAccessor.ConnectedToInternet())
            {
                games = selectedSeason.games;

                GetNextPreviousGames();
                NextGameVM.Games = new BindableCollection<GameViewModel>();
                LastGameVM.Games = new BindableCollection<GameViewModel>();

                if (_previousGame != null)
                {
                    GameViewModel previous = new GameViewModel(_previousGame, true, isPreviousGame: true);
                    previous.FetchPlaylists = previous.FetchThumbnailsAndPlaylistCounts();
                    previous.IsLargeView = true;
                    LastGameVM.Games.Add(previous);
                }
                if (_nextGame != null)
                {
                    GameViewModel next = new GameViewModel(_nextGame, true, isNextGame: true);
                    next.IsLargeView = true;
                    next.FetchPlaylists = next.FetchThumbnailsAndPlaylistCounts();
                    NextGameVM.Games.Add(next);
                }

                LastViewedResponse response = AppDataAccessor.GetLastViewed();
                if (response.ID != null)
                {
                    NewGroups.Add(LastViewedVM);
                }

                if (NextGameVM.Games.Count() > 0)
                {
                    NewGroups.Add(NextGameVM);
                }
                if (LastGameVM.Games.Count() > 0)
                {
                    NewGroups.Add(LastGameVM);
                }
            }

            if (games != null)
            {
                HubGroupViewModel schedule = new HubGroupViewModel() { Name = "Schedule", Games = new BindableCollection<GameViewModel>() };
                HubGroupViewModel otherItems = new HubGroupViewModel() { Name = "Other", Games = new BindableCollection<GameViewModel>() };
                foreach (Game g in games)
                {
                    GameViewModel gamevm = new GameViewModel(g);
                    gamevm.FetchPlaylists = gamevm.FetchThumbnailsAndPlaylistCounts();
                    if (g.Classification == 1)
                    {
                        schedule.Games.Add(gamevm);
                    }
                    else
                    { 
                        otherItems.Games.Add(gamevm);
                    }
                }
                if (schedule.Games.Count > 0)
                {
                    NewGroups.Add(schedule);
                }
                if (otherItems.Games.Count > 0)
                {
                    NewGroups.Add(otherItems);
                }
            }

            ProgressRingVisibility = Visibility.Collapsed;
            ProgressRingIsActive = false;

            if (NewGroups.Count == 0)
            {
                NoScheduleEntriesText = "There are no schedule entries for this season";
            }
            else
            {
                NoScheduleEntriesText = "";
            }

            Groups = NewGroups;
        }
Ejemplo n.º 3
0
        private void PopulateGroups()
        {
            BindableCollection <HubGroupViewModel> NewGroups = new BindableCollection <HubGroupViewModel>();

            //If these aren't set here, if there is no schedule, these still link to another season's next and last games.
            _previousGame = null;
            _nextGame     = null;

            games = selectedSeason.games;
            if (ServiceAccessor.ConnectedToInternet())
            {
                games = selectedSeason.games;

                GetNextPreviousGames();
                NextGameVM.Games = new BindableCollection <GameViewModel>();
                LastGameVM.Games = new BindableCollection <GameViewModel>();

                if (_previousGame != null)
                {
                    GameViewModel previous = new GameViewModel(_previousGame, true, isPreviousGame: true);
                    previous.FetchPlaylists = previous.FetchThumbnailsAndPlaylistCounts();
                    previous.IsLargeView    = true;
                    LastGameVM.Games.Add(previous);
                }
                if (_nextGame != null)
                {
                    GameViewModel next = new GameViewModel(_nextGame, true, isNextGame: true);
                    next.IsLargeView    = true;
                    next.FetchPlaylists = next.FetchThumbnailsAndPlaylistCounts();
                    NextGameVM.Games.Add(next);
                }

                LastViewedResponse response = AppDataAccessor.GetLastViewed();
                if (response.ID != null)
                {
                    NewGroups.Add(LastViewedVM);
                }

                if (NextGameVM.Games.Count() > 0)
                {
                    NewGroups.Add(NextGameVM);
                }
                if (LastGameVM.Games.Count() > 0)
                {
                    NewGroups.Add(LastGameVM);
                }
            }

            if (games != null)
            {
                HubGroupViewModel schedule = new HubGroupViewModel()
                {
                    Name = "Schedule", Games = new BindableCollection <GameViewModel>()
                };
                HubGroupViewModel otherItems = new HubGroupViewModel()
                {
                    Name = "Other", Games = new BindableCollection <GameViewModel>()
                };
                foreach (Game g in games)
                {
                    GameViewModel gamevm = new GameViewModel(g);
                    gamevm.FetchPlaylists = gamevm.FetchThumbnailsAndPlaylistCounts();
                    if (g.Classification == 1)
                    {
                        schedule.Games.Add(gamevm);
                    }
                    else
                    {
                        otherItems.Games.Add(gamevm);
                    }
                }
                if (schedule.Games.Count > 0)
                {
                    NewGroups.Add(schedule);
                }
                if (otherItems.Games.Count > 0)
                {
                    NewGroups.Add(otherItems);
                }
            }

            ProgressRingVisibility = Visibility.Collapsed;
            ProgressRingIsActive   = false;

            if (NewGroups.Count == 0)
            {
                NoScheduleEntriesText = "There are no schedule entries for this season";
            }
            else
            {
                NoScheduleEntriesText = "";
            }

            Groups = NewGroups;
        }
Ejemplo n.º 4
0
        protected override void OnActivate()//called every page load
        {
            base.OnActivate();
            if (currentUserName != AppDataAccessor.GetUsername())
            {
                Groups = new BindableCollection<HubGroupViewModel>();//clears old page after logout
                OnInitialize();
            }
            SettingsPane.GetForCurrentView().CommandsRequested += CharmsData.SettingCharmManager_HubCommandsRequested;

            ProgressRingVisibility = Visibility.Collapsed;
            ProgressRingIsActive = false;

            PageIsEnabled = true;
            LastViewedResponse response = AppDataAccessor.GetLastViewed();
            if (response.ID != null && ServiceAccessor.ConnectedToInternet())
            {
                Game LastViewedGame = new Game { gameId = response.ID, opponent = response.name, date = DateTime.Parse(response.timeStamp) };//this is actually a playlist - not a game
                GameViewModel lastViewed = new GameViewModel(LastViewedGame, true, isLastviewed:true);
                lastViewed.Thumbnail = response.thumbnail;
                lastViewed.Stretch = "UniformToFill";
                LastViewedVM = new HubGroupViewModel() { Name = "Last Viewed", Games = new BindableCollection<GameViewModel>() };
                LastViewedVM.Games.Add(lastViewed);

                if (Groups.Count == 0 && (NoScheduleEntriesText == null || NoScheduleEntriesText == ""))
                {
                    ProgressRingVisibility = Visibility.Visible;
                    ProgressRingIsActive = true;
                }

                if (Groups.Count >= 3)
                {
                    
                    HubGroupViewModel oldLastViewed = Groups.Where(u => u.Name == "Last Viewed").FirstOrDefault();
                    if (oldLastViewed != null)
                    {
                        Groups[Groups.IndexOf(oldLastViewed)] = LastViewedVM;
                    }
                    else
                    {
                        Groups.Insert(1, LastViewedVM);
                    }
                }
            }
        }