示例#1
0
        //This only runs the first time the page is made, so when a user first logs in (due to page caching)
        protected override async void OnInitialize()//
        {
            base.OnInitialize();
            currentUserName = AppDataAccessor.GetUsername();
            BindableCollection <Season> downloadedSeasons = await DownloadAccessor.Instance.GetDownloadsModel(true);

            if (ServiceAccessor.ConnectedToInternet())
            {
                SeasonsDropDown = await GetSortedSeasons();
            }
            else
            {
                SeasonsDropDown = downloadedSeasons;
            }

            string savedSeasonId = AppDataAccessor.GetTeamContext().seasonID;

            if (savedSeasonId != null && SeasonsDropDown.Any())
            {
                SelectedSeason = SeasonsDropDown.Where(u => u.seasonId == savedSeasonId).FirstOrDefault() ?? SeasonsDropDown[0];
            }
            else
            {
                SelectedSeason = SeasonsDropDown.LastOrDefault(u => u.year >= DateTime.Now.Year) ?? SeasonsDropDown[0];
                AppDataAccessor.SetTeamContext(SelectedSeason.seasonId, SelectedSeason.owningTeam.teamID);
            }

            if (!SeasonsDropDown.Any())
            {
                //show message here if no seasons
            }
        }
示例#2
0
 private void saveAnglePreferences()
 {
     foreach (AngleType angleName in AngleTypes)
     {
         AppDataAccessor.SetAnglePreference(angleName.Name, angleName.IsChecked);
     }
 }
示例#3
0
        protected override void OnInitialize()
        {
            DownloadAccessor.Instance.DeleteTempData();
            base.OnInitialize();

            ButtonText             = "Login";
            FormVisibility         = "Visible";
            ProgressRingVisibility = "Collapsed";
            RememberMe             = false;

            //If Username exists in roaming settings, enter it for user
            String username = AppDataAccessor.GetUsername();

            if (username != null)
            {
                UserName = username;

                // Check to see if a password has been saved
                PasswordCredential cred = AppDataAccessor.GetPassword();
                if (cred != null)
                {
                    Password = cred.Password;
                    LoginAttempt();
                }
            }
        }
示例#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);
                    }
                }
            }
        }
示例#5
0
        private void getAnglePreferences()
        {
            foreach (AngleType angleName in AngleTypes)
            {
                bool?angleChecked = AppDataAccessor.GetAnglePreference(angleName.Name);

                if (angleChecked == null)
                {
                    angleName.IsChecked = true;
                }
                else
                {
                    angleName.IsChecked = (bool)angleChecked;
                }
            }
        }
示例#6
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null)
            {
                SplashScreen splash = (SplashScreen)e.Parameter;
                splash.Dismissed += new TypedEventHandler <SplashScreen, object>(DismissedEventHandler);

                AppDataAccessor.SetSplashScreen(splash);
                loginStackPanel.Margin = new Thickness(0, splash.ImageLocation.Top, 0, 0);
            }
            else
            {
                loginStackPanel.Margin = new Thickness(0, 0, 0, 0);
                FadeInForm.Begin();
                FadeInBackground.Begin();
            }

            // Set the login image here
            double height = 0;
            double width  = 0;
            double x      = 0;

            y = 0;

            Nullable <SplashScreenResponse> response = AppDataAccessor.GetSplashScreen();

            if (response != null)
            {
                height = response.Value.Height;
                width  = response.Value.Width;
                x      = response.Value.X;
                y      = response.Value.Y;
            }

            loginImage.Height = height;
            loginImage.Width  = Width;

            //If Username exists in roaming settings, enter it for user
            String username = AppDataAccessor.GetUsername();

            if (username != null)
            {
                //UserName.Text = username;
                UserName.SelectionStart  = UserName.Text.ToCharArray().Length;
                UserName.SelectionLength = 0;
            }
        }
示例#7
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;
        }
示例#8
0
 public void PlaybackButton_Click(int playbackTypeSelected)
 {
     playbackType = (PlaybackType)playbackTypeSelected;
     setPlaybackRadioButton();
     AppDataAccessor.SetPlaybackType((int)playbackType);
 }
示例#9
0
        protected override async void OnActivate()
        {
            base.OnActivate();

            AppDataAccessor.SetLastViewed(Parameter.playlist.name, DateTime.Now.ToString("g"), Parameter.playlist.playlistId, Parameter.playlist.thumbnailLocation);
            Clips = Parameter.playlist.clips.ToList();

            FilteredClips = new ObservableCollection <Clip>(Clips);
            if (FilteredClips.Any())
            {
                getAngleNames();
                SelectedClip      = FilteredClips.First();
                SelectedClipIndex = 0;
                Angle nextAngle = SelectedClip.angles.FirstOrDefault(angle => angle.angleType.IsChecked);
                SelectedAngle = (nextAngle != null && nextAngle.isPreloaded) ? new Angle(nextAngle.clipAngleId, nextAngle.preloadFile) : nextAngle;
                if (listView != null)
                {
                    listView.SelectedItem = SelectedClip;
                }
            }

            getMoreClips();

            GridHeaders  = Parameter.playlist.displayColumns;
            PlaylistName = Parameter.playlist.name;

            int?playbackTypeResult = AppDataAccessor.GetPlaybackType();

            if (playbackTypeResult == null)
            {
                AppDataAccessor.SetPlaybackType((int)PlaybackType.next);
                playbackType = PlaybackType.next;
            }
            else
            {
                playbackType = (PlaybackType)playbackTypeResult;
            }
            setPlaybackRadioButton();

            dispRequest = new DisplayRequest();
            dispRequest.RequestActive();

            FiltersList = new List <FilterViewModel>();

            preloadCTS = new CancellationTokenSource();
            preloadCT  = preloadCTS.Token;
            initialClipPreload();

            bool downloadFound = false;
            BindableCollection <Playlist> downloadedPlaylists = DownloadAccessor.Instance.downloadedPlaylists;

            foreach (Playlist p in downloadedPlaylists)
            {
                if (p.playlistId == Parameter.playlist.playlistId)
                {
                    downloadFound = true;
                    break;
                }
            }
            DownloadAccessor.Instance.progressCallback = new Progress <DownloadOperation>(ProgressCallback);
            DownloadedVisibility = Visibility.Collapsed;
            if (DownloadAccessor.Instance.Downloading)
            {
                LoadActiveDownloadsAsync();
                ProgressGridVisibility   = Visibility.Visible;
                DownloadButtonVisibility = Visibility.Collapsed;
            }
            else
            {
                ProgressGridVisibility = Visibility.Collapsed;
                if (!downloadFound)
                {
                    DownloadButtonVisibility = Visibility.Visible;
                }
                else
                {
                    DownloadButtonVisibility = Visibility.Collapsed;
                    DownloadedVisibility     = Visibility.Visible;
                }
            }

            List <Angle> filteredAngles = SelectedClip.angles.Where(angle => angle.angleType.IsChecked).ToList <Angle>();

            if (filteredAngles.Count == 1)
            {
                filteredAngles.First().angleType.CheckBoxEnabled = false;
            }
            else if (filteredAngles.Count == 0)
            {
                NoAnglesText = "No angles are selected. Please select an angle to view this clip.";
            }
        }
示例#10
0
        public async void LoginAttempt()
        {
            // Attempt to get the debug urls from a config file
            InitResponse initResponse = await ServiceAccessor.Init();

            if (initResponse.status == SERVICE_RESPONSE.SUCCESS)
            {
                if (Password == null || Password == "")
                {
                    Password = initResponse.Password;
                }
                if (UserName == null || UserName == "")
                {
                    UserName = initResponse.Username;
                }
            }

            // Get the username and password from the view
            string loginArgs = JsonConvert.SerializeObject(new LoginSender {
                Username = UserName, Password = Password
            });

            // Show the user a call is being made in the background
            ButtonText             = "loading";
            FormVisibility         = "Collapsed";
            ProgressRingVisibility = "Visible";

            LoginResponse response = await ServiceAccessor.Login(loginArgs);

            if (response.status == SERVICE_RESPONSE.SUCCESS)
            {
                if (AppDataAccessor.GetUsername() != userName)
                {
                    AppDataAccessor.SetUsername(UserName);
                }
                if (RememberMe)
                {
                    AppDataAccessor.SetPassword(Password);
                    AppDataAccessor.SetLoginDate(DateTime.Now.ToString());
                }
                navigationService.NavigateToViewModel <HubViewModel>();
            }
            else if (response.status == SERVICE_RESPONSE.NULL_RESPONSE)
            {
                LoginFeedback = "Connection with server failed, please try again";
            }
            else if (response.status == SERVICE_RESPONSE.CREDENTIALS)
            {
                LoginFeedback = "Invalid Username or Password";
            }
            else if (response.status == SERVICE_RESPONSE.NO_CONNECTION)
            {
                DateTime LastLogin = new DateTime();
                string   loginDate = AppDataAccessor.GetLoginDate();
                if (loginDate != null)
                {
                    await Task.Run(() => LastLogin = DateTime.Parse(AppDataAccessor.GetLoginDate()));//need an async task in order to the page to navigate

                    TimeSpan ts = DateTime.Now - LastLogin;
                    if (ts.Days <= 14)
                    {
                        navigationService.NavigateToViewModel <HubViewModel>();
                    }
                    else
                    {
                        APIExceptionDialog.ShowNoInternetConnectionLoginDialog(null, null);
                    }
                }
                else
                {
                    APIExceptionDialog.ShowNoInternetConnectionLoginDialog(null, null);
                }
            }

            // Dismiss the loading indicator
            ButtonText             = "Login";
            FormVisibility         = "Visible";
            ProgressRingVisibility = "Collapsed";
        }