本文整理汇总了C#中System.Windows.Controls.TextBox.GetNextSpellingErrorCharacterIndex方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.GetNextSpellingErrorCharacterIndex方法的具体用法?C# TextBox.GetNextSpellingErrorCharacterIndex怎么用?C# TextBox.GetNextSpellingErrorCharacterIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TextBox
的用法示例。
在下文中一共展示了TextBox.GetNextSpellingErrorCharacterIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkone
private static string checkone(string text)
{
System.Windows.Controls.TextBox wpfTextBox = new System.Windows.Controls.TextBox();
wpfTextBox.AcceptsReturn = true;
wpfTextBox.AcceptsTab = true;
wpfTextBox.SpellCheck.IsEnabled = true;
List<string> suggestions = new List<string>();
wpfTextBox.Text = text;
int index = 0;
Dictionary<int, string> spellingErrors = new Dictionary<int, string>();
while ((index = wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) != -1)
{
string currentError = wpfTextBox.Text.Substring(index,
wpfTextBox.GetSpellingErrorLength(index));
spellingErrors.Add(index, currentError);
index += currentError.Length;
}
int caretIndex = wpfTextBox.CaretIndex;
SpellingError spellingError;
spellingError = wpfTextBox.GetSpellingError(caretIndex);
if (spellingError == null)
{
return text;
}
else
{
return null;
}
}
示例2: getSuggestions
private static List<string> getSuggestions(List<string> alltext)
{
System.Windows.Controls.TextBox wpfTextBox = new System.Windows.Controls.TextBox();
wpfTextBox.AcceptsReturn = true;
wpfTextBox.AcceptsTab = true;
wpfTextBox.SpellCheck.IsEnabled = true;
List<string> suggestions = new List<string>();
foreach (var ttt in alltext)
{
int index = 0;
wpfTextBox.Text = ttt;
Dictionary<int,string> spellingErrors = new Dictionary<int, string>();
while ((index = wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) != -1)
{
string currentError = wpfTextBox.Text.Substring(index,
wpfTextBox.GetSpellingErrorLength(index));
spellingErrors.Add(index, currentError);
index += currentError.Length;
}
int caretIndex = wpfTextBox.CaretIndex;
SpellingError spellingError;
spellingError = wpfTextBox.GetSpellingError(caretIndex);
if (spellingError == null)
{
suggestions.Add(ttt);
}
}
//while ((index =wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) !=-1)
//{
// string currentError = wpfTextBox.Text.Substring(index, wpfTextBox.GetSpellingErrorLength(index));
// suggestions.Add(currentError);
// foreach (string suggestion in wpfTextBox.GetSpellingError(index).Suggestions)
// {
// suggestions.Add(suggestion);
// }
//})
return suggestions;
}