This is a migrated thread and some comments may be shown as answers.

How to add a custom dictionary to RadSpellChecker

6 Answers 329 Views
SpellChecker
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 31 Mar 2011, 09:50 PM
Hello,
I am using your RadSpellChecker class to perform the spell checking on a standard silverlight textbox but I wasn't able to figure out how to load a custom dictionary (a .tdf file) like I am doing with your RadRichTextBox class.

It seems that the spellchecker in your RadRichTextBox implements the interface ISpellCheker while your RadSpellChecker is a static class deriving from the Object class.
Because of that I don't see any AddDictionary method in the RadSpellChecker class that allows me to import my dictionary.

Any help would be really appreciated.

Thanks,
Frank

6 Answers, 1 is accepted

Sort by
0
Frank
Top achievements
Rank 1
answered on 05 Apr 2011, 05:15 PM
Hello,
Do you have any update on this open question?

Thanks,
Frank
0
Accepted
Andrew
Telerik team
answered on 05 Apr 2011, 05:38 PM
Hi Frank,

Thank you for your question. The problem you are referring to, has a solution, although it might not be so intuitive. Actually RadSpellChecker is using a dictionary that matches a Type to a corresponding manager of type IControlSpellChecker. We have a public static class called ControlSpellCheckersManager which has a static method GetControlSpellChecker(Type type). Using this method you can access the corresponding IControlSpellChecker and get it's SpellChecker property which is of type ISpellChecker. Then if you want you can cast it to DocumentSpellChecker and use all it's methods. Here is the code to do this:

IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(TextBox));
ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
Then you can call documentSpellChecker.AddDictionary().
We will consider simplifying this functionality in the next version.

Kind regards,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Frank
Top achievements
Rank 1
answered on 05 Apr 2011, 09:28 PM
Hi Andrew,
Thank you very much.
This was what I was looking for.

I agree with you that it would be great if you could make the process more intuitive or, at least, documented somewhere because I wasn't able to find the RadSpellCheck class (or your ControlSpellCheckersManager class) between your online documentation.

Fortunately you offer such great customer support!! ;)

Thanks again,
Frank
0
Iva Toteva
Telerik team
answered on 08 Apr 2011, 09:27 AM
Hi Frank,

Thank you for the positive feedback.
We agree that this information should be included in the documentation and will do our best to do so shortly.

Regards,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kotte
Top achievements
Rank 1
answered on 12 Oct 2011, 05:52 PM
Hi ,
I am trying to add a custom dictionary ..

I created Test.txt file with few words and added to the project and loading to IsolatedStorage

IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();          
isoStore.CreateDirectory("SpellCheck");
IsolatedStorageFileStream isoStream1 =  new IsolatedStorageFileStream("Test.txt", FileMode.Create, isoStore);
isoStream1.Close();

Creating the Custom Dictionary..
RadIsolatedStorageCustomDictionary dictionary = new RadIsolatedStorageCustomDictionary(IsolatedStorageScope.Application, "Test.txt");
DocumentSpellChecker spellchecker = new DocumentSpellChecker(dictionary);
this._richTextBox.SpellChecker = spellchecker;


Adding Dictionary
 Stream tdfFileStream = Application.GetResourceStream(new Uri("/MC.Client.Controls;component/Resources/en-US.tdf", UriKind.RelativeOrAbsolute)).Stream;
 RadDictionary dictionary1 = new RadDictionary();
 dictionary1.Load(tdfFileStream);
 ((DocumentSpellChecker)this._richTextBox.SpellChecker).AddDictionary(dictionary, CultureInfo.CurrentCulture);

its still showing the default dictionary and I did not find the words from Test.txt file.
Am I missing any thing.
Can you please post a sample working project which loads custom dictionary file like (ex: CustomDictionary.txt )

Thanks,
Kotte
0
Kotte
Top achievements
Rank 1
answered on 13 Oct 2011, 04:11 PM
Hi,


I am able to fix the issue.Its working fine now.


Thanks,
Kotte
Tags
SpellChecker
Asked by
Frank
Top achievements
Rank 1
Answers by
Frank
Top achievements
Rank 1
Andrew
Telerik team
Iva Toteva
Telerik team
Kotte
Top achievements
Rank 1
Share this question
or