private void resetReadText(int pos) { GetContentResponse.Document doc = mContentResponse.documents[0]; mIndex = pos; var sub = doc.text.GetRange(0, mIndex); mReadText = String.Join(" ", sub); if (mplayer.CurrentState != MediaElementState.Playing) { if (mIndex < doc.offset.Count) { string word = doc.text[mIndex]; mTextItem.ReadText = mReadText; int start = mIndex + 1; sub = doc.text.GetRange(start, doc.offset.Count - start); string leftOver = String.Join(" ", sub); mReadText += " " + word; mTextItem.Word = word; mTextItem.UnreadText = leftOver; mIndex++; } } }
private async void DelayTimer_Tick(object sender, object e) { if (mContentResponse != null && mContentResponse.documents != null) { GetContentResponse.Document doc = mContentResponse.documents[0]; await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var pos = mplayer.Position.TotalMilliseconds; if (mIndex < doc.offset.Count) { var check = doc.offset[mIndex]; if (pos > check) { string word = doc.text[mIndex]; mTextItem.ReadText = mReadText; int start = mIndex + 1; var sub = doc.text.GetRange(start, doc.offset.Count - start); string leftOver = String.Join(" ", sub); mTextItem.Word = word; mTextItem.UnreadText = leftOver; mReadText += " " + word; mIndex++; } } }); } }
private void nextwordbtn_Click(object sender, RoutedEventArgs e) { GetContentResponse.Document doc = mContentResponse.documents[0]; mSearchIndex++; if (mSearchIndex >= mWordsIndex.Count) { mSearchIndex = 0; } int i = mWordsIndex[mSearchIndex]; mplayer.Position = TimeSpan.FromMilliseconds(doc.offset[i]); resetReadText(i); int c = mSearchIndex + 1; searchwordcount.Text = String.Format("{0} / {1}", c, mWordsIndex.Count); }
private void instantSearchText() { var searchTerms = instantsearch.Text.ToLower(); searchTerms = searchTerms.Trim(); if (searchTerms.Length > 0) { GetContentResponse.Document doc = mContentResponse.documents[0]; var words = doc.text.FindAll(item => item.ToLower().Contains(searchTerms)); mWordsIndex.Clear(); if (words.Count >= 1) { var r = 0; foreach (var word in words) { int m = doc.text.FindIndex(r, item => item.Equals(word)); r = m + 1; if (m >= 0) { mWordsIndex.Add(m); } } } if (mWordsIndex.Count > 0) { if (mWordsIndex.Count > 1) { nextwordbtn.IsEnabled = true; searchwordcount.Text = "1/" + mWordsIndex.Count.ToString(); } else { nextwordbtn.IsEnabled = false; searchwordcount.Text = ""; } mSearchIndex = 0; int c = mWordsIndex[mSearchIndex]; mplayer.Position = TimeSpan.FromMilliseconds(doc.offset[c]); resetReadText(c); instantsearch.SelectAll(); } } }
private void mplayer_SeekCompleted(object sender, RoutedEventArgs e) { GetContentResponse.Document doc = mContentResponse.documents[0]; if (doc == null) { return; } var pos = mplayer.Position.TotalMilliseconds; int max = doc.offset.Count - 1; for (int i = 0; i < max; i++) { var low = doc.offset[i]; var high = doc.offset[i + 1]; if (pos > low && pos < high) { resetReadText(i); break; } } }