Skip to main content

SpellChecker

Namespace: PPJ.Runtime.Windows.Spell

Assembly: PPJ.Runtime.50 (5.0.0.0)

Attaches background spell checking and correction suggestions to a WinForms text control.

public class SpellChecker : IDisposable

Dictionaries are shared by language. Unloaded languages are resolved from language.aff and language.dic in the current directory, with a hyphen-to-underscore filename fallback.

Example:

void CheckText(System.Windows.Forms.Control editor)
{
using (var checker = new PPJ.Runtime.Windows.Spell.SpellChecker(editor, "en-US"))
{
// Keep the checker alive for the required editing lifetime.
}
}

Constructors​

Instance member SpellChecker(control, culture)​

Attaches spell checking using a culture name.

NameTypeDescription
controlControlThe non-null text control to monitor.
cultureCultureInfoThe dictionary culture, or null to use the default language.

Instance member SpellChecker(control, language)​

Attaches spell checking using a dictionary language.

NameTypeDescription
controlControlThe non-null text control to monitor.
languageStringThe dictionary language; null or empty selects Sys.CultureInfo.Name.

Instance member SpellChecker(control)​

Attaches spell checking using the control culture or the SAL application culture.

NameTypeDescription
controlControlThe non-null text control to monitor.

Properties​

Instance member Language​

String: Gets or sets the dictionary language used by this checker.

Null or empty assignments select Sys.CultureInfo.Name. A changed language resolves or loads the shared dictionary.

Static member LineStyle​

SpellCheckerLineStyle: Gets or sets the shared spelling-error underline style.

Methods​

Static member AddWords(culture, words)​

Adds words to the shared language dictionary.

ParameterTypeDescription
cultureCultureInfoThe non-null dictionary culture.
wordsICollectionA non-null collection of strings to add.

The dictionary is loaded if necessary. Native results for individual additions are not returned.

Static member AddWords(language, words)​

Adds words to the shared language dictionary.

ParameterTypeDescription
languageStringThe language name; null or empty uses Sys.CultureInfo.Name.
wordsICollectionA non-null collection of strings to add.

The dictionary is loaded if necessary. Native results for individual additions are not returned.

Instance member Dispose()​

Detaches control events, releases the native subclass, and invalidates the control.

Disposal is not idempotent; call it once. The checker also disposes itself when the monitored control is disposed. Shared dictionaries remain cached.

Static member GetDictionary(language)​

Gets a wrapper for a shared dictionary, loading it if necessary.

ParameterTypeDescription
languageStringThe language name; null or empty uses Sys.CultureInfo.Name.

Returns: Dictionary. A Dictionary wrapper around the cached language dictionary.

Static member GetDictionary(culture)​

Gets a wrapper for a shared dictionary, loading it if necessary.

ParameterTypeDescription
cultureCultureInfoThe non-null culture whose name identifies the dictionary.

Returns: Dictionary. A Dictionary wrapper around the cached language dictionary.

Static member LoadDictionary(culture, affFile, dictFile)​

Loads a shared dictionary if its language has not already been registered.

ParameterTypeDescription
cultureCultureInfoThe non-null culture whose name identifies the dictionary.
affFileStringThe affix file path.
dictFileStringThe dictionary file path.

An already registered language is unchanged.

Static member LoadDictionary(culture, affFile, dictFile)​

Loads a shared dictionary if its language has not already been registered.

ParameterTypeDescription
cultureCultureInfoThe non-null culture whose name identifies the dictionary.
affFileStreamThe readable affix stream with an accessible Length.
dictFileStreamThe readable dictionary stream with an accessible Length.

An already registered language is unchanged. When loading occurs, both input streams are disposed by the dictionary reader.

Static member LoadDictionary(language, affFile, dictFile)​

Loads a shared dictionary if its language has not already been registered.

ParameterTypeDescription
languageStringThe language key; null or empty uses en-US.
affFileStringThe affix file path.
dictFileStringThe dictionary file path.

An already registered language is unchanged.

Static member LoadDictionary(language, affFile, dictFile)​

Loads a shared dictionary if its language has not already been registered.

ParameterTypeDescription
languageStringThe language key; null or empty uses en-US.
affFileStreamThe readable affix stream with an accessible Length.
dictFileStreamThe readable dictionary stream with an accessible Length.

An already registered language is unchanged. When loading occurs, both input streams are disposed by the dictionary reader.

Events​

Static member ShowSuggestionsMenu​

SpellCheckerEventHandler Occurs before the default spelling-suggestion menu is displayed.

The sender is the edited control. Set Handled to suppress the default menu; a nonempty NewWord then replaces the misspelled word.