Esempio n. 1
0
        protected override void WireMessages()
        {
            Messenger.Default.Register <NotificationMessage>(this, m =>
            {
                if (m.Notification.Equals(Constants.Messages.ReaderViewLeftMsg))
                {
                    ShowFinishedScreen = false;
                    if (_readerTimer != null && _readerTimer.IsEnabled)
                    {
                        _readerTimer.Stop();
                    }

                    var wordsRead          = SelectedIndex * _settingsService.WordsAtATime;
                    var articleNotFinished = wordsRead < SelectedItem.WordCount;
                    if (articleNotFinished)
                    {
                        _roamingSettings.Set(SelectedItem.InternalId, wordsRead);
                    }
                    else
                    {
                        _roamingSettings.Remove(SelectedItem.InternalId);
                    }

                    SaveInProgressItems(wordsRead, !articleNotFinished);
                }
            });

            Messenger.Default.Register <ShareMessage>(this, async m =>
            {
                _shareOperation = (ShareOperation)m.Sender;
                if (_shareOperation.Data.Contains(StandardDataFormats.WebLink))
                {
                    var url     = await _shareOperation.Data.GetWebLinkAsync();
                    var message = new UriSchemeMessage(url.ToString(), true, SchemeType.Read);

                    await SaveItemFromExternal(message, async() =>
                    {
                        var title = _loader.GetString("ShareErrorTitle");
                        await _messageBox.ShowAsync(_loader.GetString("ShareErrorText"), title, new List <string> {
                            _loader.GetString("MessageBoxOk")
                        });
                        _shareOperation.ReportError(title);
                    });
                }
                else
                {
                    _shareOperation.ReportCompleted();
                }
            });

            Messenger.Default.Register <UriSchemeMessage>(this, async m =>
            {
                if (m.SchemeType != SchemeType.Read)
                {
                    return;
                }

                await SaveItemFromExternal(m);
            });
        }
Esempio n. 2
0
        public TrialHelper()
        {
            _settings = new ApplicationSettingsService().Legacy;
#if TRIAL
            IsTrial = true;
#else
            IsTrial = new LicenseInformation().IsTrial();
            _settings.Set(Constants.Settings.AppIsBought, !IsTrial);
#endif
        }
Esempio n. 3
0
        public TrialHelper()
        {
            _settings = new ApplicationSettingsService().Legacy;
#if TRIAL
            IsTrial = true;
#else
            IsTrial = new LicenseInformation().IsTrial();
            _settings.Set(Constants.Settings.AppIsBought, !IsTrial);
#endif
        }
        private async void OnRunUnderLockChanged()
        {
            if (_ignoreRunUnderLockChanged)
            {
                return;
            }

            var result = await _messageBox.ShowAsync(AppResources.ErrorPlayUnderLock, AppResources.ErrorPleaseRestart, new List <string> {
                AppResources.LabelRestartNow, AppResources.LabelLater
            });

            App.SpecificSettings.PlayVideosUnderLock = RunUnderLock;

            if (result == 0)
            {
                _applicationSettings.Set(Constants.Settings.SpecificSettings, App.SpecificSettings);

                Application.Current.Terminate();
            }
        }
        public async Task Login(string selectedUserName, string pinCode)
        {
            try
            {
                _logger.Info("Authenticating user [{0}]", selectedUserName);

                var result = await _connectionManager.CurrentApiClient.AuthenticateUserAsync(selectedUserName, pinCode);

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

                AuthenticationResult = result;
                _settingsService.Set(Constants.Settings.AuthUserSetting, AuthenticationResult);

                SetUser(result.User);
                _logger.Info("User [{0}] has been saved", selectedUserName);
            }
            catch (HttpException ex)
            {
                _logger.ErrorException("Login()", ex);
            }
        }
Esempio n. 6
0
        private async Task ConnectToServer()
        {
            RetryButtonIsVisible = false;
            ConnectionResult result = null;

            SetProgressBar(AppResources.SysTrayGettingServerDetails);

            if (_connectionDetails != null && !string.IsNullOrEmpty(_connectionDetails.ServerId))
            {
                result = await ConnectionManager.Connect(_connectionDetails.ServerAddress);

                var server = result.Servers.FirstOrDefault(x =>
                                                           string.Equals(x.Id, _connectionDetails.ServerId, StringComparison.CurrentCultureIgnoreCase));

                if (server != null)
                {
                    _serverInfo.SetServerInfo(server);
                    _applicationSettings.Set(Constants.Settings.DefaultServerConnection, server);

                    _savedServer = server;

                    _applicationSettings.Remove(Constants.Settings.ConnectionSettings);
                    _connectionDetails = null;
                }
            }

            if (_savedServer != null)
            {
                result = await ConnectionManager.Connect(_savedServer);
            }

            if (result != null && result.State == ConnectionState.Unavailable && _savedServer != null)
            {
                RetryButtonIsVisible = true;
                return;
            }

            // See if we can find and communicate with the server

            if (result == null || result.State == ConnectionState.Unavailable)
            {
                result = await ConnectionManager.Connect();
            }

            Deployment.Current.Dispatcher.BeginInvoke(async() =>
            {
                await Utils.HandleConnectedState(result, ApiClient, NavigationService, Log);

                SetProgressBar();
            });
        }
Esempio n. 7
0
        private async Task AddRemoveBackgroundTask()
        {
            if (IsInDesignMode || _ignoreChange)
            {
                return;
            }

            if (IsPhotoUploadsEnabled)
            {
                BackgroundTaskService.Current.CreateTask();

                _appSettingsService.Set(Constants.Settings.PhotoUploadSettings, App.UploadSettings);

                LaunchBackgroundTask();
            }
            else
            {
                BackgroundTaskService.Current.RemoveTask();
            }
        }
Esempio n. 8
0
        public void Save()
        {
            var json = JsonConvert.SerializeObject(this);

            _roamingSettings.Set(Constants.StorageSettings.SettingsFile, json);
        }
Esempio n. 9
0
        public static void SetS <T>(this IApplicationSettingsServiceHandler handler, string key, T value)
        {
            var json = JsonConvert.SerializeObject(value);

            handler.Set(key, json);
        }
Esempio n. 10
0
 private void WriteAllTextAsync(string filename, string content)
 {
     _roamingSettings.Set(filename, content);
 }