Exemplo n.º 1
0
        internal void SaveGameState()
        {
            if (!GameLocked)
            {
                return;
            }

            Log.Info("Saving game state");

            var gameState = new GameState(GameLength, SelectedGenre, RoundNumber, RoundPoints);

            _applicationSettings.Set(Constants.Settings.GameState, gameState);
        }
Exemplo n.º 2
0
        public async Task Login(string selectedUserName, string pinCode)
        {
            try
            {
                _logger.Info("Authenticating user [{0}]", selectedUserName);

                var result = await _apiClient.AuthenticateUserAsync(selectedUserName, pinCode.ToHash());

                _logger.Info("Logged in as [{0}]", selectedUserName);

                LoggedInUser             = result.User;
                IsLoggedIn               = true;
                _apiClient.CurrentUserId = LoggedInUserId;

                _settingsService.Set(Constants.Settings.SelectedUserSetting, LoggedInUser);
                _settingsService.Save();
                _logger.Info("User [{0}] has been saved", selectedUserName);
            }
            catch (HttpException ex)
            {
                _logger.ErrorException("Login()", ex);
            }
        }
 public void SaveInstagramUser(InstagramTokenResponse userResponse)
 {
     InstagramTokenResponse = userResponse;
     _settingsService.Set(Constants.Settings.InstagramUser, InstagramTokenResponse);
     _settingsService.Save();
 }
Exemplo n.º 4
0
        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
        }