TX Spell .NET for WPF

UserDictionary Class

Class
Namespace
TXTextControl.Proofing
Package
TXTextControl.TXSpell.WPF.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXSpell.dll
Install
dotnet add package TXTextControl.TXSpell.WPF.SDK .NET 8 and later. For .NET Framework, reference TXSpell.dll from the setup.
Also in
TXTextControl.TXSpell.Core.SDK as TXSpell.dll
Inherits
  1. Dictionary
  2. UserDictionary

Description

The UserDictionary class represents a dictionary that allows to use, create and edit user dictionaries. The first constructor creates an empty UserDictionary object with no reference to a file. The second constructor initializes a new UserDictionary object that is filled with the content of a specified word list file. As with all dictionaries of type Dictionary, the content of the dictionary is only accessed when the dictionary was added to the TXSpell.Dictionaries collection. The third constructor loads a dictionary from string arrays that represent the content of an user dictionary. It is recommended to create that array by using the encoding that was used to create the source of that dictionary. Using that implementation, it is required to define the language of the dictionary through the System.Globalization.CultureInfo language parameter that sets the user dictionary's Language property automatically. To declare a specific encoding for the dictionary, use the Dictionary.DictionaryEncoding property. If the encoding is not declared through the property or inside the word list file, the encoding of operation system's current ANSI code page is used. The UserDictionary class is inherited from the abstract class Dictionary.

Syntax

public sealed class UserDictionary : Dictionary

Examples

The following example creates an User Dictionary instance and configures its is editable setting for a document workflow.

TXTextControl.Proofing.UserDictionary userDictionary = new();
userDictionary.IsEditable = true;

Members

Constructors

ConstructorDescription
UserDictionaryInitializes a new instance of the UserDictionary class.

Properties

PropertyDescription
DictionaryEncodingGets or sets the dictionary's encoding. (Inherited from Dictionary.)
DisplayNameGets or sets the text that is displayed for the dictionary inside the options dialog or the SpellCheckDialog's SuggestionDictionaryComboBox. The default value is the name of the dictionary. (Inherited from Dictionary.)
FilePathGets the name and path of the file that has been used to load this user dictionary or where it has been saved to. If the user dictionary was neither loaded from nor saved as a file, the property returns null.
IsEditableGets or sets a value indicating whether the user dictionary is editable or not. The default value is true.
IsGetSuggestionsEnabledGets or sets a value that indicates whether suggestions are created using this dictionary or not. The default value is true. (Inherited from Dictionary.)
IsSelectedAsDefaultGets a value indicating whether the dictionary is selected as the default dictionary by the Language property. The default value is false. (Inherited from Dictionary.)
IsSpellCheckingEnabledGets or sets a value indicating whether spell checking of this dictionary is enabled or not. The default value is true. (Inherited from Dictionary.)
LanguageGets or sets the dictionary's language. (Inherited from Dictionary.)
NameGets or sets the dictionary's name. (Inherited from Dictionary.)
ShowInOptionsDialogGets or sets a value indicating whether the dictionary is shown in the options dialog. The default value is true. (Inherited from Dictionary.)

Methods

MethodDescription
AddWordAdds a word to the user dictionary. The method has no effect, if the UserDictionary.IsEditable property is false or the user dictionary is not added to the TXSpell.Dictionaries or TXSpellChecker.Dictionaries DictionaryCollection.
RemoveAllWordsRemoves all words from the user dictionary. The method has no effect, if the UserDictionary.IsEditable property is false or the user dictionary is not added to the TXSpell.Dictionaries or TXSpellChecker.Dictionaries DictionaryCollection.
RemoveWordRemoves a word the user dictionary. The method has no effect if the UserDictionary.IsEditable property is false or the user dictionary is not added to the TXSpell.Dictionaries or TXSpellChecker.Dictionaries DictionaryCollection.
SaveSaves the complete content of the user dictionary in a file at the specified path or as a string array. If using a file name without any file path, the user dictionary is saved in the default dictionary folder. The method has no effect, if the specified path does not end with ".txd" or the user dictionary is not added to the TXSpell.Dictionaries or TXSpellChecker.Dictionaries DictionaryCollection.
ToArrayConverts all user dictionary entries to a string array.