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.
- C#
- VB.NET
public class SpellChecker : IDisposable
Public Class SpellChecker
Inherits 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
SpellChecker(control, culture)
Attaches spell checking using a culture name.
| Name | Type | Description |
|---|---|---|
| control | Control | The non-null text control to monitor. |
| culture | CultureInfo | The dictionary culture, or null to use the default language. |
SpellChecker(control, language)
Attaches spell checking using a dictionary language.
| Name | Type | Description |
|---|---|---|
| control | Control | The non-null text control to monitor. |
| language | String | The dictionary language; null or empty selects Sys.CultureInfo.Name. |
SpellChecker(control)
Attaches spell checking using the control culture or the SAL application culture.
| Name | Type | Description |
|---|---|---|
| control | Control | The non-null text control to monitor. |
Properties
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.
LineStyle
SpellCheckerLineStyle: Gets or sets the shared spelling-error underline style.
Methods
AddWords(culture, words)
Adds words to the shared language dictionary.
| Parameter | Type | Description |
|---|---|---|
| culture | CultureInfo | The non-null dictionary culture. |
| words | ICollection | A non-null collection of strings to add. |
The dictionary is loaded if necessary. Native results for individual additions are not returned.
AddWords(language, words)
Adds words to the shared language dictionary.
| Parameter | Type | Description |
|---|---|---|
| language | String | The language name; null or empty uses Sys.CultureInfo.Name. |
| words | ICollection | A non-null collection of strings to add. |
The dictionary is loaded if necessary. Native results for individual additions are not returned.
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.
GetDictionary(language)
Gets a wrapper for a shared dictionary, loading it if necessary.
| Parameter | Type | Description |
|---|---|---|
| language | String | The language name; null or empty uses Sys.CultureInfo.Name. |
Returns: Dictionary. A Dictionary wrapper around the cached language dictionary.
GetDictionary(culture)
Gets a wrapper for a shared dictionary, loading it if necessary.
| Parameter | Type | Description |
|---|---|---|
| culture | CultureInfo | The non-null culture whose name identifies the dictionary. |
Returns: Dictionary. A Dictionary wrapper around the cached language dictionary.
LoadDictionary(culture, affFile, dictFile)
Loads a shared dictionary if its language has not already been registered.
| Parameter | Type | Description |
|---|---|---|
| culture | CultureInfo | The non-null culture whose name identifies the dictionary. |
| affFile | String | The affix file path. |
| dictFile | String | The dictionary file path. |
An already registered language is unchanged.
LoadDictionary(culture, affFile, dictFile)
Loads a shared dictionary if its language has not already been registered.
| Parameter | Type | Description |
|---|---|---|
| culture | CultureInfo | The non-null culture whose name identifies the dictionary. |
| affFile | Stream | The readable affix stream with an accessible Length. |
| dictFile | Stream | The 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.
LoadDictionary(language, affFile, dictFile)
Loads a shared dictionary if its language has not already been registered.
| Parameter | Type | Description |
|---|---|---|
| language | String | The language key; null or empty uses en-US. |
| affFile | String | The affix file path. |
| dictFile | String | The dictionary file path. |
An already registered language is unchanged.
LoadDictionary(language, affFile, dictFile)
Loads a shared dictionary if its language has not already been registered.
| Parameter | Type | Description |
|---|---|---|
| language | String | The language key; null or empty uses en-US. |
| affFile | Stream | The readable affix stream with an accessible Length. |
| dictFile | Stream | The 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
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.