현재 NHunspell을 사용하여 WPF에서 사용자 지정 맞춤법 검사를 구현하고 있습니다. .NET Framework의 기본 솔루션이 내 필요에 맞지 않기 때문입니다. 하지만 큰 텍스트 (예 : 10 점의 파고 그래프가있는 Lorem Ipsum)에서 단어를 확인할 때 문제가 발생합니다. 각 단어를 확인하고 Hunspell에서 사용하는 사전이 있는지 확인해야합니다. 그렇지 않은 경우 그 단어에 밑줄을 긋십시오.화면을 멈추지 않고 RichTextBox의 큰 텍스트를 확인하는 방법은 무엇입니까?
KeyUp이 백 스페이스 또는 스페이스 키일 때마다 모든 텍스트를 검사하는 현재 방법이 있습니다.
var textRange = new TextRange(SpellCheckRichTextBox.Document.ContentStart,
SpellCheckRichTextBox.Document.ContentEnd);
textRange.ApplyPropertyValue(Inline.TextDecorationsProperty, null);
_viewModel.Text = textRange.Text;
var zzz = _viewModel.Text.Split(' ');
var kfeofe = zzz.Where(x => _viewModel.MisspelledWords.Contains(x));
foreach (var item in kfeofe)
{
TextPointer current = textRange.Start.GetInsertionPosition(LogicalDirection.Forward);
while (current != null)
{
string textInRun = current.GetTextInRun(LogicalDirection.Forward);
if (!string.IsNullOrWhiteSpace(textInRun))
{
int index = textInRun.IndexOf(item.ToString());
if (index != -1)
{
TextPointer selectionStart = current.GetPositionAtOffset(index, LogicalDirection.Forward);
TextPointer selectionEnd = selectionStart.GetPositionAtOffset(item.ToString().Length, LogicalDirection.Forward);
TextRange selection = new TextRange(selectionStart, selectionEnd);
selection.ApplyPropertyValue(Inline.TextDecorationsProperty, TextDecorations.Underline);
}
}
current = current.GetNextContextPosition(LogicalDirection.Forward);
}
}
하지만 비동기 솔루션이 필요하다고 생각합니다. 따라서 메인 스레드와 사용자 입력을 차단하지 않습니다. - 이론적으로 사용자가 입력하지 않고 2 초 이상을 소비 한 다음 체크 된 TextRange를 RichTextBox (SpellCheckRichTextBox)로 반환하는 경우 병렬 스레드를 실행하려고 생각했습니다.
누군가 큰 텍스트로 작업 할 때 인증 속도가 느려질 수 있습니다. 나는 정말 그것에 붙어있어, 어떤 도움을 주시면 감사하겠습니다. 미리 감사드립니다.