Product Architecture
Knowing how the parts of TX Spell .NET for Windows Forms fit together makes it easier to add it to a project and to deploy the result. The sections below describe the assemblies and classes, the language data they read, how TX Text Control and other controls use the spell checker, and what each NuGet package brings.
How the Parts Fit
Windows Forms application
┌──────────────────────────────────────────────────────────────────┐
│ TextControl ── SpellChecker ──►┐ │
│ RichTextBox / TextBox ─ Check ─► TXSpellChecker │
│ (dialogs, menu items, events) │
│ TXSpell.Windows.Forms.dll │
│ │ │
│ Console, service, server ─────────► TXSpell │
│ (checking, suggestions, │
│ hyphenation, synonyms, │
│ language detection) │
│ TXSpell.dll │
└─────────────────────────────────────────┬────────────────────────┘
│ reads
Dictionaries HyphenationLists SynonymLists LanguageRecognition
TX Spell .NET has one engine, TXSpell.dll, shared by all its products, and one assembly with the user interface for each platform, here TXSpell.Windows.Forms.dll. Both read the language data from four folders next to the application.
The Two Classes
| TXSpellChecker | TXSpell | |
|---|---|---|
| Assembly | TXSpell.Windows.Forms.dll | TXSpell.dll |
| Namespace | TXTextControl.Proofing | TXTextControl.Proofing |
| What it is | A component, derived from System.ComponentModel.Component, on a form | A class for code |
| User interface | Spell check dialog, options dialog, context menu items | None |
| Events | For corrections, the dialog and the dictionaries | None |
| Connects to TX Text Control | To the TextControl of Windows Forms | Only to ServerTextControl |
| Initialization | Automatic when connected to a TextControl, otherwise Create | Create before first use |
| Package | TXTextControl.TXSpell.WinForms.SDK | TXTextControl.TXSpell.Core.SDK, and the Windows Forms package |
Both classes check text, create suggestions, hyphenate, find synonyms and detect languages with the same members, such as Check, CreateSuggestions and GetHyphenationPoints. The classes of the language data, such as OpenOfficeDictionary, UserDictionary and HyphenationList, are shared by both. Components describes each part.
The texts of the dialogs are resources: English is built in, German comes as the satellite assembly de\TXSpell.resources.dll, and Localization and Resource Kit adds other languages.
The Language Data
The spell checker reads its language data from four folders next to the application: Dictionaries for spell checking and suggestions, HyphenationLists for hyphenation, SynonymLists for synonyms and LanguageRecognition for language detection. The NuGet packages copy them with the US English data into the output directory when you build; Installing Dictionaries and Language Data describes the folders, where the spell checker looks for them and how to keep them elsewhere.
How TX Text Control Uses the Spell Checker
A TextControl gets its spell checker through its SpellChecker property. From then on, the editor drives the checking, and the spell checker answers:
- The user types a word. When the word is complete, the
TextControlasks the spell checker whether it is spelled correctly. - The
TextControlunderlines the misspelled words and keeps them in its MisspelledWords collection, which holds the misspelled words of the part of the document with the input focus, such as the main text, a header or a text frame. - A right-click on an underlined word opens the spell check menu; the menu and the dialogs correct the word in the document.
IsSpellCheckingEnabled, IsHyphenationEnabled and IsLanguageDetectionEnabled of the TextControl switch the three services on. As-You-Type Checking describes the connection in detail.
How Other Controls Use It
A RichTextBox or a TextBox doesn't know the spell checker. Your application does the work the TextControl does by itself:
- It passes the text to Check, which fills IncorrectWords with the misspelled words and their positions.
- It marks the words, or opens the spell check dialog for them.
- It applies each correction the user makes in the IncorrectWordChanging event.
Checking on Demand shows these steps with a RichTextBox.
The NuGet Packages
Two NuGet packages bring the assemblies into a .NET project: TXTextControl.TXSpell.WinForms.SDK with TXSpell.dll and TXSpell.Windows.Forms.dll, and TXTextControl.TXSpell.Core.SDK with TXSpell.dll only. Both also bring the US English language data, the German texts and the license file, and neither depends on TX Text Control; Package Overview lists what each contains.
One Spell Checker for Many Controls
One TXSpellChecker serves every TextControl and every other control of a form, and of other forms. The dictionaries are loaded once, and a word the user adds to a user dictionary is accepted in all editors at once. Checking Multiple Controls shows how to share it and how one dialog checks several controls.
Next Steps
- Components: what each part does.
- Supported Platforms: the .NET versions and tools.
- Loading and Managing Dictionaries: the dictionaries in code.
- Getting Started: a first application.