Knowledgebase Home Page  >  RapidSpell Desktop .NET  >  Behavior Customization
Search the Knowledge Base
How to load .dict file dictionaries when RapidSpell is running in a 'download' environment (IE hosting, ClickOnce, etc).
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=220&catId=62

Options

Print this page
Email this to a friend
Most commonly 'RapidSpell Desktop .NET' runs in a desktop environment, so any external dictionary files (.dict files) are located in your app's setup folder, and the RapidSpell controls are pointed to the dict file path.
 
In a 'download' environment, such as IE hosting (eg. TX Text Control Browser, or other Browser based text controls) or with ClickOnce, there is no setup folder.  All DLLs are actually downloaded by the .NET runtime automatically to the client machine and run in a sandbox.  This works fine by default with the standard DLL based dictionary (which is stored in the Keyoti.RapidSpellMDict.DLL).
 
To use a .dict file based dictionary, in a 'download' environment, we need to download the file to the client somehow.  This could be performed manually, placing the file on the client machine if there is enough 'trust' to do so.  Or, one very simple way is to house the .dict file in a DLL and let the runtime download that for us.
 
1. In the solution which holds the project where RapidSpell is used, create a new 'Class Library' project, in the screenshot it's called "Dictionaries".
 
 
 
 
2. Add any .dict files to the project as an 'Embedded resource' (in the above screenshot it's "DICT-DE-DE-German.dict")
 
3. Add a simple class that reads the resource, to the new project.
 

using System;

using System.Collections.Generic;

using System.Text;

using System.Reflection;

namespace Dictionaries

{

public class DictionaryReader

{

public static System.IO.Stream ReadDictionary(string filename)

{

return Assembly.GetExecutingAssembly().GetManifestResourceStream("Dictionaries." + filename);

}

}

}

 
Notice that the filename is preprended with "Dictionaries." because the .dict file resource is added to the "Dictionaries" namespace by default by VS.
 
4. In the Form (or Control) where RapidSpell is used;
 
i) Reference the Dictionaries project.
 
ii) Set the dict file stream (important to do this before the text controls are assigned to the spell checker).
 

public BrowserAppControl()

{

InitializeComponent();

browserTextControl1.ButtonBar = browserButtonBar1;

browserTextControl1.RulerBar = browserRulerBar1;

browserTextControl1.VerticalRulerBar = browserRulerBar2;

browserTextControl1.StatusBar = browserStatusBar1;

browserTextControl1.CreateControl();

rapidSpellDialog1.CheckerEngine.SetDictFileStream(Dictionaries.DictionaryReader.ReadDictionary("DICT-DE-DE-German.dict"));

rapidSpellAsYouType1.RapidSpellChecker.SetDictFileStream(Dictionaries.DictionaryReader.ReadDictionary("DICT-DE-DE-German.dict"));

}

 
That is all that is required, provided the ReadDictionary method locates the .dict file correctly (ie correct namespace and filename), everything else should work as-is.  The project can be extended to include other .dict files of course, and the required dictionary is specified in the ReadDictionary call.
 
If you have trouble with the ReadDictionary method returning the resource, use ILDASM (in the .NET SDK) to check the name of the .dict file when it is embedded - here it is "Dictionaries.DICT-DE-DE-German.dict", and change the GetManifestResourceStream call accordingly.
 
 
 
 
 
 
 
 

Related Questions:

Attachments:

No attachments were found.