// .... NOTE: this function is separated from SetDocument because UI needs to be updated first before we fire any selection events public void Init() { if (DocumentState != null) { SelectWordPlease?.Invoke(DocumentState.Word); } }
public void SetSearchString(string searchText) { searching.IsSearchInProgress = true; var index = ttsDocument.Text.IndexOf(searchText, searching.LastSearchIndex, StringComparison.InvariantCultureIgnoreCase); if (index == -1) { SelectWordPlease?.Invoke(null); } else { //searching.LastSearchIndex = index + searchText.Length; searching.SearchHighlight = new WordHighlight(index, searchText.Length); SelectWordPlease?.Invoke(searching.SearchHighlight); } }
private void ttsService_Word(string text, int offset, int start, int length) { if (DocumentState == null) { return; } if (!ttsService.IsPlaying) { return; } DocumentState.Word.StartIndex = offset + start; // + startedReadingFromHere; DocumentState.Word.Length = length; if (!searching.IsSearchInProgress) { SelectWordPlease?.Invoke(DocumentState.Word); } }
public void Goto(int position) { if (DocumentState == null) { return; } // search up in the string to find correct start of the double-clicked word int wStart, wLength; Utils.FindWord( text: ttsDocument.Text, position: position, paraStart: out wStart, paraLength: out wLength); var subword = ttsDocument.Text.Substring(wStart, wLength); DocumentState.Word.StartIndex = wStart; DocumentState.Word.Length = wLength; SelectWordPlease?.Invoke(DocumentState.Word); }
public void ClearSearch() { searching.IsSearchInProgress = false; SelectWordPlease?.Invoke(null); }