Show language: C# VB.NET Both

RapidSpell Desktop and Thesaurus Desktop Integration With TX Text Control

This article is for the integration of RapidSpell Desktop .NET v4.5 and higher with TX Text Control v15 and older. For use with older versions of RapidSpell, please see this article. For use with newer versions of TX Text Control please see "Using RapidSpell With 3rd Party Controls" in the product Help.

Integration of RapidSpell and Thesaurus with TX Text Control can be as simple as dragging controls on to the Form and setting two properties in the property editor - however, TX Text Control is a powerful word processor component, and full integration of spell checking can be a little more complex with some subtle points to consider. This article intends to show how to achieve full integration, and will address commonly asked questions about this subject.

To show fullest usage of spell checking with TX Text Control we have started from the "TX Text Control Words" demo project distributed with TX Text Control. The following demonstrates nearly all requirements customers have faced. This article is aimed at TX Text Control 15 Professional (Pro is required for headers/footers/text-frames) - however it can easily be adapted for non Professional versions. Support for TX 15 was added in RapidSpell Desktop 4.5.

Demo Projects

Please find complete, running projects under the main product "Examples" folder (3rd Party Integration).

1. RapidSpell Setup

a) Add references to Keyoti.RapidSpell.NET2.TXSupportvXX.dll (where XX is the version of TX TextControl) and Keyoti.RapidSpellMDict.dll Starting from the "TX TextControl Words" the only things that need to be done are adding references in the project to Keyoti.RapidSpell.NET2.TXSupportv15.dll and Keyoti.RapidSpellMDict.dll (found in C:\Program Files\Keyoti Inc\RapidSpell Desktop .NET\3rd Party DLLs)

b) You may want to add controls from Keyoti.RapidSpell.NET2.TXSupportvXX.dll to your tool box if not there already (right click toolbox, choose items, browse for Keyoti.RapidSpell.NET2.TXSupportvXX.dll). Note, you must not have a reference to Keyoti.RapidSpell.dll or Keyoti.RapidSpell.NET2.dll in your project.

Note if you added items to your toolbox from the Keyoti.RapidSpell.NET2.dll, you will find that when dragging controls from the toolbox, that a reference is added to the Keyoti.RapidSpell.dll, this is OK, but remember to remove the reference from your project references

2. Simple Dialog & As-you-type Checking

It may help to refer to the demo projects which are included with the product. Here are the very simple steps to integrate the spell checkers. Note that it is not mandatory to use both RapidSpellAsYouType and RapidSpellDialog.

Basic Setup

a) Open/create a project which uses TX Text Control

b) Open the form holding TX Text Control, and drag on RapidSpellAsYouType, RapidSpellDialog and RapidSpellAYTDialogCoupler.

c) Configure RapidSpellAsYouType and RapidSpellDialog properties in RapidSpellAYTDialogCoupler.

d)
For WinForms:- Drag on a txTextControlAdapter to be used for RapidSpellAsYouType, drag on another txTextControlAdapter to be used for RapidSpellDialog . Set the TextControl property of the txTextControlAdapters to the instance of the Text Control to be spell checked.

For Browser:- Same as above but instead of using txTextControlAdapter use txTextControlBrowserAdapter.

e) Connecting the Adapters;

RapidSpellAsYouType - in the main form Load event set the TextComponent property of rapidSpellAsYouType to the instance of the txTextControlAdapter to be used for rapidSpellAsYouType.


C#
this.rapidSpellAsYouType1.TextComponent = this.ayt_txTextControlAdapter;
ayt_txTextControlAdapter.DocumentLoaded();


VB.NET
        RapidSpellAsYouType1.TextComponent = ayt_TxTextControlAdapter
        ayt_TxTextControlAdapter.DocumentLoaded()

RapidSpellDialog - Set the ThirdPartyTextComponentToCheck property of RapidSpellDialog to the instance of the txTextControlAdapter to be used for RapidSpellDialog.

f) Add a button or menu item and start RapidSpellDialog in it's click handler, calling rapidSpellDialog.Check()

g) Set the UnderlineStyle property of RapidSpellAsYouType to Dashed or Single.

At this stage the spell check should work, however a few changes are needed for optimal integration.

2.1 ContextMenuStrip

+ Expand

2.2 Document Loading/Creation

+ Expand

2.3 TextFields

+ Expand

2.4 Browser Usage

+ Expand

3. As You Type ContextMenuStrip Customization

To use the spell checker's suggestion items in an externally provided ContextMenu(Strip);

a) Set RapidSpellAsYouType.ShowSuggestionsContextMenu = false
b) Add a ContextMenuStrip to the form and assign it to the text editor and handle it's Opening event
c) In the event handler, use GetSuggestionsToolStripItems to obtain spelling suggestions and construct the menu.


C#
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            //clear any old suggestions, leaving the first two menu items which we don't want to clear
            if (contextMenuStrip1.Items.Count > 2)
                while (contextMenuStrip1.Items.Count > 2)
                    contextMenuStrip1.Items.RemoveAt(2);

            //grab the suggestions from the spell checker
            ToolStripItem[] suggestions = rapidSpellAsYouType1.GetSuggestionsToolStripItems();

            //if there are suggestions (ie if the click was on an error), show them
            if (suggestions != null)
            {
                contextMenuStrip1.Items.Add(new ToolStripSeparator());
                contextMenuStrip1.Items.AddRange(suggestions);
            }
        }


VB.NET
Private Sub contextMenuStrip1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles contextMenuStrip1.Opening
        'clear any old suggestions, leaving the first two menu items which we don't want to clear
        If (contextMenuStrip1.Items.Count > 2) Then

            While (contextMenuStrip1.Items.Count > 2)
                contextMenuStrip1.Items.RemoveAt(2)

            End While
        End If
        Dim suggestions() As ToolStripItem = RapidSpellAsYouType1.GetSuggestionsToolStripItems
        'if there are suggestions (ie if the click was on an error), show them
        If (Not (suggestions) Is Nothing) Then
            contextMenuStrip1.Items.Add(New ToolStripSeparator)
            contextMenuStrip1.Items.AddRange(suggestions)
        End If
    End Sub

4. Thesaurus Setup

Thesaurus Desktop .NET is a separate download to RapidSpell.

a) Add references to Keyoti.Thesaurus.TXTextControlAdapter.vXX.dll and Keyoti.Thesaurus.Windows.NET2.DLL (found under C:\Program Files\Keyoti Inc\Thesaurus Desktop .NET)

b) You may want to add controls from both DLLs to your tool box (right click toolbox, add/remove items, find controls named Thesaurus, Thesaurus Control and ThesaurusTXAdapter). Note, be sure to select the TX adapter control for the correct version; You will see multiple controls in the list, for different TX versions, ensure you pick the correct version, otherwise you will get references added to your project which are dependent on a different TX version.

5. Adding Thesaurus to TX Text Control

5.1 Simple, dialog based thesaurus

+ Expand

5.2 Full, context menu and dialog based thesaurus

+ Expand

Conclusion

We hope that this article has shed light on how to achieve more advanced integration requirements. If you have questions or problems please feel free to email support@keyoti.com for assistance.













© Copyright 2005-2009 Keyoti Inc.