private void CheckIfUserSignedIn() { var user = _settingsService.Get <UserDto>(Constants.Settings.SelectedUserSetting); if (user != null) { LoggedInUser = user; IsLoggedIn = true; _apiClient.CurrentUserId = LoggedInUserId; } }
internal void RestoreGameState() { var gameState = _applicationSettings.Get <GameState>(Constants.Settings.GameState, null); if (gameState == null) { return; } Log.Info("Previous game state exists, restoring"); GameLength = gameState.GameLength; SelectedGenre = gameState.GameGenre; RoundNumber = gameState.RoundNumber; RoundPoints = gameState.CurrentScore; GameLocked = true; }
private void GetUserSettings() { InstagramTokenResponse = _settingsService.Get <InstagramTokenResponse>(Constants.Settings.InstagramUser); FourSquareAccessToken = _settingsService.Get <string>(Constants.Settings.FourSquareUser); }
private async Task <bool> CheckForGameData() { var genres = _settingsService.Get("Genres", default(List <Genre>)); if (genres != default(List <Genre>)) { await _asyncStorageService.WriteAllTextAsync(Constants.GenreDataFile, await JsonConvert.SerializeObjectAsync(genres)); _settingsService.Reset("Genres"); } else { if (!await _asyncStorageService.FileExistsAsync(Constants.GenreDataFile)) { return(false); } var genreJson = await _asyncStorageService.ReadAllTextAsync(Constants.GenreDataFile); genres = await JsonConvert.DeserializeObjectAsync <List <Genre> >(genreJson); if (genres == null || !genres.Any()) { return(false); } var allGenreCheck = genres.FirstOrDefault(x => x.Name.Equals(GameViewModel.AllGenres)); if (allGenreCheck == default(Genre)) { genres.Insert(0, new Genre { Name = GameViewModel.AllGenres }); } var comedyGenreCheck = genres.FirstOrDefault(x => x.Name.Equals("Comedy")); if (comedyGenreCheck != default(Genre)) { genres.Remove(comedyGenreCheck); } } Genres = genres; App.SettingsWrapper.AppSettings.DefaultGenre = Genres.FirstOrDefault(x => x.Name.Equals(App.SettingsWrapper.AppSettings.DefaultGenre.Name)); if (SimpleIoc.Default.GetInstance <GameViewModel>() == null) { return(false); } Messenger.Default.Send(new NotificationMessage(genres, Constants.Messages.HereAreTheGenresMsg)); if (!await _asyncStorageService.FileExistsAsync(Constants.GameDataFile)) { return(false); } var tracksJson = await _asyncStorageService.ReadAllTextAsync(Constants.GameDataFile); try { var tracks = await JsonConvert.DeserializeObjectAsync <List <Product> >(tracksJson); if (tracks.Any()) { Messenger.Default.Send(new NotificationMessage(tracks, Constants.Messages.HereAreTheTracksMsg)); return(true); } } catch (Exception ex) { Log.ErrorException("Deserializing tracks", ex); } return(false); }
public MainViewModel(IMainModel mainModel, INavigationService navigationService, IMessageBoxService messageBoxService, IApplicationSettingsService applicationSettingsService, IShellTileService shellTileService) { _mainModel = mainModel; _navigationService = navigationService; _messageBoxService = messageBoxService; _applicationSettingsService = applicationSettingsService; _shellTileService = shellTileService; NewAccountCommand = new RelayCommand(() => { _navigationService.NavigateTo("/View/AuthorizationPage.xaml"); }); RemoveAccountCommand = new RelayCommand<AccountViewModel>(account => { _mainModel.AvailableAccounts.Remove(account.Model); _mainModel.Save(); RefreshAccountsList(); }); OpenAccountCommand = new RelayCommand<AccountViewModel>(account => { _mainModel.CurrentAccount = account.Model; _mainModel.ExecuteInitialLoad = true; _navigationService.NavigateTo("/View/ExplorerPage.xaml"); }); ShowAboutCommand = new RelayCommand(() => { _navigationService.NavigateTo("/View/AboutPage.xaml"); }); PageLoadedCommand = new RelayCommand(() => { _mainModel.CurrentAccount = null; if (!_applicationSettingsService.Get<bool>("AcceptedDisclaimer", false)) { _applicationSettingsService.Set("AcceptedDisclaimer", true); _applicationSettingsService.Save(); _messageBoxService.Show("You are advised to read the GDrive disclaimer before you continue.\n\nWould you like to read it now?\n\nYou can always find it later in the About page.", "Welcome to GDrive", new[] { "now", "later" }, buttonIndex => { if (buttonIndex == 0) { _navigationService.NavigateTo("/View/AboutPage.xaml?disclaimer=true"); } }); } }); MessengerInstance.Register<AvailableAccountsChangedMessage>(this, message => { RefreshAccountsList(); }); #if !WP8 DispatcherHelper.RunAsync(UpdateTiles); #endif }
public override void WireMessages() { Messenger.Default.Register <NotificationMessage>(this, async m => { if (m.Notification.Equals(Constants.Messages.SplashAnimationFinishedMsg)) { App.Settings.ConnectionDetails = new ConnectionDetails { PortNo = 8096 }; var doNotShowFirstRun = _applicationSettings.Get(Constants.Settings.DoNotShowFirstRun, false); if (!doNotShowFirstRun) { _navigationService.NavigateTo(Constants.Pages.FirstRun.WelcomeView); return; } SetProgressBar(AppResources.SysTrayLoadingSettings); #if !DEBUG //try //{ // if (!ApplicationManifest.Current.App.Title.ToLower().Contains("beta")) // { // var marketPlace = new MarketplaceInformationService(); // var appInfo = await marketPlace.GetAppInformationAsync(ApplicationManifest.Current.App.ProductId); // if (new Version(appInfo.Entry.Version) > new Version(ApplicationManifest.Current.App.Version) && // MessageBox.Show("There is a newer version, would you like to install it now?", "Update Available", MessageBoxButton.OKCancel) == MessageBoxResult.OK) // { // new MarketplaceDetailService().Show(); // } // } //} //catch (Exception ex) //{ // Log.ErrorException("GetAppInformationAsync()", ex); //} #endif // Get settings from storage var connectionDetails = _applicationSettings.Get <ConnectionDetails>(Constants.Settings.ConnectionSettings); if (connectionDetails == null) { var messageBox = new CustomMessageBox { Caption = "No connection details", Message = "No connection settings have been set, would you like to set them now?", LeftButtonContent = "yes", RightButtonContent = "no", IsFullScreen = false }; messageBox.Dismissed += (sender, args) => { if (args.Result == CustomMessageBoxResult.LeftButton) { _navigationService.NavigateTo(Constants.Pages.SettingsViewConnection); } }; messageBox.Show(); } else { App.Settings.ConnectionDetails = connectionDetails; // Get and set the app specific settings var specificSettings = _applicationSettings.Get <SpecificSettings>(Constants.Settings.SpecificSettings); if (specificSettings != null) { Utils.CopyItem(specificSettings, App.SpecificSettings); } // See if we can find and communicate with the server if (_navigationService.IsNetworkAvailable && App.Settings.ConnectionDetails != null) { SetProgressBar(AppResources.SysTrayGettingServerDetails); await Utils.GetServerConfiguration(_apiClient, Log); // Server has been found if (App.Settings.ServerConfiguration != null) { await SetPushSettings(); SetProgressBar(AppResources.SysTrayAuthenticating); Utils.CheckProfiles(_navigationService); } else { App.ShowMessage(AppResources.ErrorCouldNotFindServer); _navigationService.NavigateTo(Constants.Pages.SettingsViewConnection); } } SetProgressBar(); } } }); }