private void InitializeSpritz() { try { _isSpritzReady = false; ActiveIndex = 0; _spritzState = SpritzState.Ready; _spritzWords = new List <SpritzWord>(); DisplayWord(new SpritzWord() { After = "ding", Before = "Lo", Middle = 'a', Lenght = 1000 }); _platformCodeService.CheckBeginInvokeOnUi(() => { _goLeftCommand.RaiseCanExecuteChanged(); _goRightCommand.RaiseCanExecuteChanged(); _goToStartCommand.RaiseCanExecuteChanged(); _startCommand.RaiseCanExecuteChanged(); RaisePropertyChanged(() => TotalWords); }); //inititialize Wordlists if (Article.Content != null && Article.Content.Any()) { _spritzWords = SpritzHelper.GenerateList(Article.Content); //prepare User Interface if (_spritzWords != null && _spritzWords.Count > 0) { _platformCodeService.CheckBeginInvokeOnUi(() => { _goLeftCommand.RaiseCanExecuteChanged(); _goRightCommand.RaiseCanExecuteChanged(); RaisePropertyChanged(() => TotalWords); }); DisplayWord(_spritzWords[0]); _isSpritzReady = true; _platformCodeService.CheckBeginInvokeOnUi(() => { _startCommand.RaiseCanExecuteChanged(); }); } } } catch (Exception ex) { LogHelper.Instance.Log(LogLevel.FatalError, "Spritz failed", this, ex); } }
private async void DisplayNextWord() { if (_spritzWords == null) { _spritzWords = SpritzHelper.GenerateList(Article.Content); } int delay = (60 * 1000) / ReadingSpeed; if (SpritzState == SpritzState.Running && ActiveIndex < _spritzWords.Count) { if (++ActiveIndex < _spritzWords.Count) { DisplayWord(_spritzWords[ActiveIndex]); await Task.Delay(delay); DisplayNextWord(); } else { SpritzState = SpritzState.Finished; } } }