private void OnNavigateToExtraSettingsCommand()
 {
     _settings.Load();
     _interactionService.Interact(ApplicationInteractionProviders.ExtraSettingsInteractionProvider, viewModel =>
     {
         viewModel.Title = "Дополнительные настройки";
         viewModel.AcknowledgeEnabled            = _settings.AcknowledgeEnabled;
         viewModel.FullTimeout                   = _settings.FullTimeoutPeriod;
         viewModel.PartialTimeout                = _settings.PartialTimeoutPeriod;
         viewModel.QueryTimeout                  = _settings.QueryTimeoutPeriod;
         viewModel.MinuteRepeatInterval          = _settings.MillisecondRepeatInterval / (60 * 1000);
         viewModel.NumberOfLightingCommandRepeat = _settings.NumberOfLightingCommandRepeat;
     }, viewModel =>
     {
         if (viewModel.Result == MessageBoxResult.OK)
         {
             _settings.AcknowledgeEnabled            = viewModel.AcknowledgeEnabled;
             _settings.FullTimeoutPeriod             = viewModel.FullTimeout;
             _settings.PartialTimeoutPeriod          = viewModel.PartialTimeout;
             _settings.QueryTimeoutPeriod            = viewModel.QueryTimeout;
             _settings.NumberOfLightingCommandRepeat = viewModel.NumberOfLightingCommandRepeat;
             _settings.MillisecondRepeatInterval     = viewModel.MinuteRepeatInterval * 60 * 1000;
             _settings.Save();
         }
     });
 }
Exemplo n.º 2
0
 public void Save()
 {
     if (_applicationSettingsService.IsDirty)
     {
         _applicationSettingsService.Save();
     }
 }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private Notification Handle(string[] args)
        {
            if (args.Length == 0)
            {
                _commandHandler.WriteUsage(_systemService.StandardOut);
                return(Notification.Empty);
            }

            var command = _commandHandler.GetMatchingCommand(args);

            if (command == null)
            {
                return(Notification.ErrorFor(DontKnowHowToHandleMessageText, String.Join(" ", args)));
            }
            var executionArguments = new ExecutionArguments
            {
                Args = args.Skip(command.GetCommandWords().Length).ToArray(),
                ApplicationSettings = _applicationSettingsService.Load(),
                Statement           = _storageService.Load()
            };

            var result = _commandHandler.Handle(command, executionArguments);

            if (result.HasErrors)
            {
                return(result);
            }

            if (command.ChangesTheApplicationSettings())
            {
                var saveResult = _applicationSettingsService.Save(executionArguments.ApplicationSettings);
                if (saveResult.HasErrors)
                {
                    return(saveResult);
                }
            }

            if (command.ChangesTheStatement())
            {
                var saveResult = _storageService.Save(executionArguments.Statement);
                if (saveResult.HasErrors)
                {
                    return(saveResult);
                }
            }
            return(result);
        }
 public void SaveInstagramUser(InstagramTokenResponse userResponse)
 {
     InstagramTokenResponse = userResponse;
     _settingsService.Set(Constants.Settings.InstagramUser, InstagramTokenResponse);
     _settingsService.Save();
 }
Exemplo n.º 6
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
        }