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 and thesaurus 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 12 & 13 Professional (Pro is required for headers/footers/text-frames) - however it can easily be adapted for 10, 11 and non Professional versions. Support for TX 13 was added in RapidSpell Desktop 3.7 and Thesaurus Desktop 1.1.0.
Downloads:
These projects show complete integration with both RapidSpell Desktop .NET and Thesaurus Desktop .NET, and therefore require both to be installed in order to run properly.
TX v13 C# Demo Project
TX v13 VB.NET Demo Project
a) Add references to Keyoti.RapidSpell.TXSupportv13.dll 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.TXSupportv13.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.TXSupportv13.dll to your tool box (right click toolbox, add/remove items, browse for Keyoti.RapidSpell.TXSupportv13.dll). Note, you must not have a reference to Keyoti.RapidSpell.dll in your project.
Note if you added items to your toolbox from the Keyoti.RapidSpell.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. Adding RapidSpellAsYouType to TX Text Control
To begin with, as-you-type support will be added without concern for headers/footers/text-frames or context menus. In the "TX Text Control Words" demo project the TXTextControl.TextControl Control is located in the frmMDIChild Form.
a) Drag the RapidSpellAsYouType control from the toolbox on to the frmMDIChild Form.
b) Drag the TXTextControlAdapter control from the toolbox on to the form.
c) The simplest way to configure RapidSpellAsYouType in the designer's property editor is to first set TXTextControlAdapter.TextControl to the instance of TextControl, and then set RapidSpellAsYouType.TextComponent to the instance of TXTextControlAdapter. However, see the ContextMenu section for important points.
1. RapidSpellAsYouType will display it's own context menu when an error is underlined - to display other static menus when the click is not on an error, set the TXTextControlAdapter.ContextMenuDefault property to the desired ContextMenu.
2. If you create context menus dynamically then you will need to approach this differently, please see the context menu section for Thesaurus integration (section 5.2).
If your document can have headers, footers or text frames then you need to follow these instructions to implement correct spell checking.
1. Add this class to your project, which will handle the common tasks associated with headers, footers and text frames.
C#
using System;
using System.Collections;
using TXTextControl;
using Keyoti.RapidSpell;
namespace TX_Text_Control_Words
{
/// <summary>
/// Summary description for TXHelper.
/// </summary>
public class TXHelper
{
RapidSpellAsYouType ayt;
RapidSpellDialog dia;
TXTextControl.TextControl txc;
TXTextControlAdapter dialogAdapter;
TXTextControlAdapter[] adapters;
bool isTextFrameActive = false;
public bool IsTextFrameActive{ get{ return isTextFrameActive; }}
/// <summary>
/// Configures the spell checkers to work with the text control, pass a null
/// spell checker object if not being used.
/// </summary>
public TXHelper(RapidSpellAsYouType ayt, RapidSpellDialog dia, TXTextControl.TextControl txc)
{
this.ayt = ayt;
this.dia = dia;
this.txc = txc;
if(dia!=null)
{
dialogAdapter = new TXTextControlAdapter(txc);
dialogAdapter.WorkWithCurrentlyActiveElementOnly = true;
this.dia.ThirdPartyTextComponentToCheck = dialogAdapter;
dia.SpellCheckStarted +=new Keyoti.RapidSpell.RapidSpellDialog.SpellCheckEventHandler(dia_SpellCheckStarted);
dia.SpellCheckFinished += new Keyoti.RapidSpell.RapidSpellDialog.SpellCheckEventHandler(dia_SpellCheckFinished);
}
if(ayt!=null)
{
this.txc.TextFrameCreated +=new TextFrameEventHandler(txc_TextFrameCreated);
adapters = (TXTextControlAdapter[]) getBasisAdapters().ToArray(typeof (TXTextControlAdapter));
this.ayt.UpdateAllTextBoxes = false;
this.ayt.TextComponents = adapters;
}
this.txc.TextFrameActivated+= new TextFrameEventHandler(txc_TextFrameActivated);
this.txc.TextFrameDeactivated+=new TextFrameEventHandler(txc_TextFrameDeactivated);
}
ArrayList getBasisAdapters()
{
ArrayList adaps = new ArrayList();
TXTextControlAdapter adap;
//add main adapter
adap = new TXTextControlAdapter(this.txc);
adaps.Add(adap);
//add adapters for headers/footers
foreach (HeaderFooter hf in this.txc.HeadersAndFooters)
{
adap = new TXTextControlAdapter(this.txc);
adap.HeaderFooter = hf;
adaps.Add(adap);
}
return adaps;
}
private void dia_SpellCheckStarted(object sender, Keyoti.RapidSpell.Event.SpellCheckEventArgs e)
{
dialogAdapter.IgnoreHeaderFooterDeactivationEvents = true;
}
private void dia_SpellCheckFinished(object sender, Keyoti.RapidSpell.Event.SpellCheckEventArgs e)
{
dialogAdapter.IgnoreHeaderFooterDeactivationEvents = false;
}
//used for AYT only, this is only called when text frames come from the CLIPBOARD
private void txc_TextFrameCreated(object sender, TextFrameEventArgs e)
{
OnTextFrameCreated(e.TextFrame);
}
//used for AYT only
/// <summary>
/// Call when adding a TextFrame
/// </summary>
/// <param name="tf"></param>
public void OnTextFrameCreated(TextFrame tf)
{
ArrayList basis = new ArrayList();
TXTextControlAdapter adap;
//refresh old adapters, note we must create new adapters as old ones are retired below
foreach(TXTextControlAdapter a in adapters)
{
adap = new TXTextControlAdapter(this.txc);
adap.SetWith(a);
basis.Add(adap);
}
//text frame adapter
adap = new TXTextControlAdapter(this.txc);
adap.TextFrame = tf;
basis.Add(adap);
adapters = (TXTextControlAdapter[]) basis.ToArray(typeof (TXTextControlAdapter));
//retire the old ones
ayt.TextComponents = null;
//add the new ones
ayt.TextComponents = adapters;
}
private void txc_TextFrameActivated(object sender, TextFrameEventArgs e)
{
isTextFrameActive = true;
}
private void txc_TextFrameDeactivated(object sender, TextFrameEventArgs e)
{
isTextFrameActive = false;
}
}
}
VB.NET
Imports System
Imports System.Collections
Imports TXTextControl
Imports Keyoti.RapidSpell
Public Class TXHelper
Private ayt As RapidSpellAsYouType
Private dia As RapidSpellDialog
Private WithEvents txc As TXTextControl.TextControl
Private dialogAdapter As TXTextControlAdapter
Private adapters() As TXTextControlAdapter
Private _isTextFrameActive = False
Public ReadOnly Property IsTextFrameActive() As Boolean
Get
Return _isTextFrameActive
End Get
End Property
' Configures the spell checkers to work with the text control, pass a null
' spell checker object if not being used.
Public Sub New(ByVal ayt As RapidSpellAsYouType, ByVal dia As RapidSpellDialog, ByVal txc As TXTextControl.TextControl)
Me.ayt = ayt
Me.dia = dia
Me.txc = txc
If Not (dia Is Nothing) Then
dialogAdapter = New TXTextControlAdapter(txc)
dialogAdapter.WorkWithCurrentlyActiveElementOnly = True
Me.dia.ThirdPartyTextComponentToCheck = dialogAdapter
AddHandler dia.SpellCheckStarted, AddressOf dia_SpellCheckStarted
AddHandler dia.SpellCheckFinished, AddressOf dia_SpellCheckFinished
End If
If Not (ayt Is Nothing) Then
AddHandler Me.txc.TextFrameCreated, AddressOf txc_TextFrameCreated
adapters = CType(getBasisAdapters().ToArray(GetType(TXTextControlAdapter)), TXTextControlAdapter())
Me.ayt.UpdateAllTextBoxes = False
Me.ayt.TextComponents = adapters
End If
End Sub 'New
Function getBasisAdapters() As ArrayList
Dim adaps As New ArrayList
Dim adap As TXTextControlAdapter
'add main adapter
adap = New TXTextControlAdapter(Me.txc)
adaps.Add(adap)
'add adapters for headers/footers
Dim hf As HeaderFooter
For Each hf In Me.txc.HeadersAndFooters
adap = New TXTextControlAdapter(Me.txc)
adap.HeaderFooter = hf
adaps.Add(adap)
Next hf
Return adaps
End Function 'getBasisAdapters
Private Sub dia_SpellCheckStarted(ByVal sender As Object, ByVal e As Keyoti.RapidSpell.Event.SpellCheckEventArgs)
dialogAdapter.IgnoreHeaderFooterDeactivationEvents = True
End Sub 'dia_SpellCheckStarted
Private Sub dia_SpellCheckFinished(ByVal sender As Object, ByVal e As Keyoti.RapidSpell.Event.SpellCheckEventArgs)
dialogAdapter.IgnoreHeaderFooterDeactivationEvents = False
End Sub 'dia_SpellCheckFinished
'used for AYT only, this is only called when text frames come from the CLIPBOARD
Private Sub txc_TextFrameCreated(ByVal sender As Object, ByVal e As TextFrameEventArgs)
OnTextFrameCreated(e.TextFrame)
End Sub 'txc_TextFrameCreated
'used for AYT only
' Call when adding a TextFrame
Public Sub OnTextFrameCreated(ByVal tf As TextFrame)
Dim basis As New ArrayList
Dim adap As TXTextControlAdapter
'refresh old adapters, note we must create new adapters as old ones are retired below
Dim a As TXTextControlAdapter
For Each a In adapters
adap = New TXTextControlAdapter(Me.txc)
adap.SetWith(a)
basis.Add(adap)
Next a
'text frame adapter
adap = New TXTextControlAdapter(Me.txc)
adap.TextFrame = tf
basis.Add(adap)
adapters = CType(basis.ToArray(GetType(TXTextControlAdapter)), TXTextControlAdapter())
'retire the old ones
ayt.TextComponents = Nothing
'add the new ones
ayt.TextComponents = adapters
End Sub 'OnTextFrameCreated
Private Sub txc_TextFrameActivated(ByVal sender As Object, ByVal e As TXTextControl.TextFrameEventArgs) Handles txc.TextFrameActivated
Me._isTextFrameActive = True
End Sub
Private Sub txc_TextFrameDeactivated(ByVal sender As Object, ByVal e As TXTextControl.TextFrameEventArgs) Handles txc.TextFrameDeactivated
Me._isTextFrameActive = False
End Sub
End Class 'TXHelper
2. For the purposes of this article we will create a header in the load event of the form, and then add the TXHelper object. Note also, that the .TextControl and .TextComponent assignments from before have been commented, this is because the TXHelper will handle assignments for us.
C#//Declared in class
TXHelper helper;
....
#region " Form Events "
private void frmMDIChild_Load(object sender, System.EventArgs e)
{
//this.txTextControlAdapter1.TextControl = this.TextControl1;
//this.rapidSpellAsYouType1.TextComponent = this.txTextControlAdapter1;
TextControl1.RulerBar = TxRulerBar1;
TextControl1.ButtonBar = m_MainFormButtonBar;
TextControl1.StatusBar = m_MainFormStatusBar;
FileHandler1.TextControl = TextControl1;
FileHandler1.DocumentDirty = false;
TXTextControl.HeaderFooterCollection hfc = this.TextControl1.HeadersAndFooters;
hfc.Styles = TXTextControl.HeaderFooterStyles.ActivateClick | TXTextControl.HeaderFooterStyles.SingleFrame;
hfc.Add(TXTextControl.HeaderFooterType.Header);
hfc.Add(TXTextControl.HeaderFooterType.Footer);
//the second argument should be RapidSpellDialog if it is being used aswell
helper = new TXHelper(rapidSpellAsYouType1, null, this.TextControl1);
if (m_LoadFileOnCreate)
{
if(!FileHandler1.FileOpen())
return;
if(FileHandler1.DocumentFileName != "")
this.Text = FileHandler1.DocumentFileName;
}
}
VB.NET
'Declared in class
Dim helper As TXHelper
....
#Region " Form Events "
Private Sub frmMDIChild_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'TxTextControlAdapter1.TextControl = TextControl1
'RapidSpellAsYouType1.TextComponent = TxTextControlAdapter1
TextControl1.RulerBar = TxRulerBar1
TextControl1.ButtonBar = m_MainFormButtonBar
TextControl1.StatusBar = m_MainFormStatusBar
FileHandler1.TextControl = TextControl1
FileHandler1.DocumentDirty = False
Dim hfc As TXTextControl.HeaderFooterCollection
hfc = Me.TextControl1.HeadersAndFooters
hfc.Styles = TXTextControl.HeaderFooterStyles.ActivateClick Or TXTextControl.HeaderFooterStyles.SingleFrame
hfc.Add(TXTextControl.HeaderFooterType.Header)
hfc.Add(TXTextControl.HeaderFooterType.Footer)
'the second argument should be RapidSpellDialog if it is being used aswell
helper = New TXHelper(RapidSpellAsYouType1, Nothing, Me.TextControl1)
If m_LoadFileOnCreate Then
FileHandler1.FileOpen()
End If
If FileHandler1.DocumentFileName <> "" Then
Me.Text = FileHandler1.DocumentFileName
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
At runtime, switch to page view and click near the top of the page to enter the header, you'll see if you type that spell checking is performed in the header/footer aswell.
3. The TXHelper class also takes care of TextFrame objects, however when adding text frames to the document, be sure to register the frame with TXHelper (call OnTextFrameCreated) - in this code we create the text frame in a menu item handler.
C# [Attach this handler to the menu item click event]
private void textFrame_menuItem5_Click(object sender, System.EventArgs e)
{
TXTextControl.TextFrame NewFrame = new TXTextControl.TextFrame(new Size(1800,1000));
TextControl1.TextFrames.Add (NewFrame,TXTextControl.HorizontalAlignment.Left,
-1, TXTextControl.TextFrameInsertionMode.DisplaceText);
//Must inform helper of this
helper.OnTextFrameCreated(NewFrame);
}
VB.NET
Private Sub textFrame_MenuItem18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textFrame_MenuItem18.Click
Dim NewFrame As New TXTextControl.TextFrame(New Size(1800, 1000))
TextControl1.TextFrames.Add(NewFrame, TXTextControl.HorizontalAlignment.Left, -1, TXTextControl.TextFrameInsertionMode.DisplaceText)
'Must inform helper of this
helper.OnTextFrameCreated(NewFrame)
End Sub
Two things to do when loading and saving documents.
1. When loading, call TXHelper.OnDocumentOpen or (if not using TXHelper) TXTextControlAdapter.DocumentLoaded. This ensures RapidSpell knows that the document has changed.
2. When saving, remove underlines and stop spell checking by calling rapidSpellAsYouType1.CheckAsYouType = false. This removes underlines from the document, which are actually part of the document, and prevents them being saved with the document. After saving it is OK to call rapidSpellAsYouType1.CheckAsYouType = true
3. Adding RapidSpellDialog to TX Text Control
There are two ways to do this, the first way below is if you are not working with headers/footers or text-frames, the second way continues on from the as-you-type integration instructions above.
2. Drag a TXTextControlAdapter control onto the form.
3. In the property editor set TXTextControlAdapter.TextControl to the instance of TextControl, and then to set RapidSpellDialog.ThirdPartyTextComponentToCheck to the instance of TXTextControlAdapter. Note if you do not see any options in the property editor drop down, please close the designer and reopen it - sometimes Visual Studio fails to correctly identify possible objects.
4. Add a menu item and an event handler to start the dialog spell check.
C# [Attach this event handler to the menu item click event]
private void SpellCheck_menuItem7_Click(object sender, System.EventArgs e)
{
this.rapidSpellDialog1.Check();
}
VB.NET
Private Sub SpellCheck_MenuItem19_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SpellCheck_MenuItem19.Click
Me.RapidSpellDialog1.Check()
End Sub
3.2 Full, integration with headers/footers and text frames
2. Drag a TXTextControlAdapter control onto the form.
3. Referring to section 2.2, the TXHelper is now constructed with the RapidSpellDialog instance.
C#
#region " Form Events "
private void frmMDIChild_Load(object sender, System.EventArgs e)
{
//this.txTextControlAdapter1.TextControl = this.TextControl1;
//this.rapidSpellAsYouType1.TextComponent = this.txTextControlAdapter1;
TextControl1.RulerBar = TxRulerBar1;
TextControl1.ButtonBar = m_MainFormButtonBar;
TextControl1.StatusBar = m_MainFormStatusBar;
FileHandler1.TextControl = TextControl1;
FileHandler1.DocumentDirty = false;
TXTextControl.HeaderFooterCollection hfc = this.TextControl1.HeadersAndFooters;
hfc.Styles = TXTextControl.HeaderFooterStyles.ActivateClick | TXTextControl.HeaderFooterStyles.SingleFrame;
hfc.Add(TXTextControl.HeaderFooterType.Header);
hfc.Add(TXTextControl.HeaderFooterType.Footer);
helper = new TXHelper(rapidSpellAsYouType1, rapidSpellDialog1, this.TextControl1);
if (m_LoadFileOnCreate)
{
if(!FileHandler1.FileOpen())
return;
if(FileHandler1.DocumentFileName != "")
this.Text = FileHandler1.DocumentFileName;
}
}
VB.NET
#Region " Form Events "
Private Sub frmMDIChild_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'TxTextControlAdapter1.TextControl = TextControl1
'RapidSpellAsYouType1.TextComponent = TxTextControlAdapter1
TextControl1.RulerBar = TxRulerBar1
TextControl1.ButtonBar = m_MainFormButtonBar
TextControl1.StatusBar = m_MainFormStatusBar
FileHandler1.TextControl = TextControl1
FileHandler1.DocumentDirty = False
Dim hfc As TXTextControl.HeaderFooterCollection
hfc = Me.TextControl1.HeadersAndFooters
hfc.Styles = TXTextControl.HeaderFooterStyles.ActivateClick Or TXTextControl.HeaderFooterStyles.SingleFrame
hfc.Add(TXTextControl.HeaderFooterType.Header)
hfc.Add(TXTextControl.HeaderFooterType.Footer)
helper = New TXHelper(RapidSpellAsYouType1, RapidSpellDialog1, Me.TextControl1)
If m_LoadFileOnCreate Then
FileHandler1.FileOpen()
End If
If FileHandler1.DocumentFileName <> "" Then
Me.Text = FileHandler1.DocumentFileName
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
4. Add a menu item and an event handler to start the dialog spell check.
C# [Attach this event handler to the menu item click event]
private void SpellCheck_menuItem7_Click(object sender, System.EventArgs e)
{
this.rapidSpellDialog1.Check();
}
VB.NET
Private Sub SpellCheck_MenuItem19_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SpellCheck_MenuItem19.Click
Me.RapidSpellDialog1.Check()
End Sub
5. This is enough to get both spell checkers working independently however it's usually desirable to have dialog and as-you-type working in unison, so that words which are "ignore all'ed" in one, are ignored in the other. To do this, drag the RapidSpellAYTDialogCoupler control onto the form and set it's RapidSpellAsYouType and RapidSpellDialog properties to the existing controls of the same name on the form (note if you do not see them as options in the property editor, please close and reopen the designer window - as Visual Studio sometimes fails to pick up objects as options).
a) Add references to Keyoti.Thesaurus.TXTextControlAdapter.v13.dll and Keyoti.Thesaurus.Windows.DLL (found in 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 two controls in the list, one from Keyoti.Thesaurus.TXTextControlAdapter.v12.dll and one from Keyoti.Thesaurus.TXTextControlAdapter.v13.dll - if you pick v12 you will get references added to your project which are dependent on TX v12.
2. Drag the ThesaurusTXAdapter control onto the form.
3. Set ThesaurusTXAdapter.Control to the instance of TextControl, and set Thesaurus.ThirdPartyTextComponent to the instance of ThesaurusTXAdapter.
4. Add a menu item for the Thesaurus in the main menu and an event handler to start the Thesaurus dialog.
C# [Attach this event handler to the menu item click event]
private void thesaurus_menuItem1_Click(object sender, System.EventArgs e)
{
if(this.TextControl1.Text.Length==0)
MessageBox.Show("You must select a word to use the thesaurus.");
else
{
this.thesaurus1.DialogForm.TopMost = true;
this.thesaurus1.Show();
}
}
VB.NET
Private Sub Thesaurus_MenuItem19_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Thesaurus_MenuItem19.Click
If Me.TextControl1.Text.Length = 0 Then
MessageBox.Show("You must select a word to use the thesaurus.")
Else
Thesaurus1.DialogForm.TopMost = True
Me.Thesaurus1.Show()
End If
End Sub
Continuing on from section 3.2, we will now modify the as-you-type context menu and integrate with a new dynamic menu.
1. Follow all steps in 5.1 to add the dialog thesaurus.
2. The nature of the thesaurus is such that it's context menu is suited to being a sub-menu, so it is necessary to build the ContextMenu items at run-time. Add a context menu to the form if one doesn't already exist and assign it to the TextControl instance.
3. In RapidSpellAsYouType set the ShowSuggestionsContextMenu property to false (this allows us to override the default behaviour).
4. Handle the context menu PopUp event, and create the menu items there
C# [Attach this event handler to the menu PopUp event]
private void contextMenu1_Popup(object sender, System.EventArgs e)
{
contextMenu1.MenuItems.Clear();
//see if any spelling suggestions
MenuItem[] spellingSuggestions = this.rapidSpellAsYouType1.GetSuggestions();
if(spellingSuggestions!=null)
{
contextMenu1.MenuItems.AddRange(spellingSuggestions);
contextMenu1.MenuItems.Add("-");
}
//add non spell check and thesaurus menu items
if (this.TextControl1.CanCopy)
{
contextMenu1.MenuItems.Add("Copy", new EventHandler(cm_copy_Click));
contextMenu1.MenuItems.Add("Cut", new EventHandler(cm_cut_Click));
}
contextMenu1.MenuItems.Add("Paste", new EventHandler(cm_cut_Paste));
//add synonymns (thesaurus submenu), if not in header/footer
if(this.m_ActiveHeaderFooter==null && !helper.IsTextFrameActive)
{
MenuItem synonymsMenuItem = new MenuItem("Synonyms");
contextMenu1.MenuItems.Add(synonymsMenuItem);
MenuItem[] thSuggestions = this.thesaurus1.GetSuggestionMenuItems();
MenuItem noSuggestionsMenuItem = new MenuItem("(No suggestions)");
MenuItem thesaurusMenuItem = new MenuItem("&Thesaurus...", new EventHandler(this.thesaurus_menuItem1_Click));
noSuggestionsMenuItem.Enabled=false;
synonymsMenuItem.MenuItems.Clear();
if(thSuggestions!=null)
synonymsMenuItem.MenuItems.AddRange(thSuggestions);
else
synonymsMenuItem.MenuItems.Add(noSuggestionsMenuItem);
synonymsMenuItem.MenuItems.Add("-");
synonymsMenuItem.MenuItems.Add(thesaurusMenuItem);
}
}
void cm_cut_Click(object sender, System.EventArgs e)
{
this.Cut();
}
void cm_copy_Click(object sender, System.EventArgs e)
{
this.Copy();
}
void cm_cut_Paste(object sender, System.EventArgs e)
{
this.Paste();
}
VB.NET
Private Sub ContextMenu1_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup
ContextMenu1.MenuItems.Clear()
'see if any spelling suggestions
Dim spellingSuggestions As MenuItem() = Me.RapidSpellAsYouType1.GetSuggestions()
If Not (spellingSuggestions Is Nothing) Then
ContextMenu1.MenuItems.AddRange(spellingSuggestions)
ContextMenu1.MenuItems.Add("-")
End If
'add non spell check and thesaurus menu items
If Me.TextControl1.CanCopy Then
ContextMenu1.MenuItems.Add("Copy", AddressOf cm_copy_Click)
ContextMenu1.MenuItems.Add("Cut", AddressOf cm_cut_Click)
End If
ContextMenu1.MenuItems.Add("Paste", AddressOf cm_cut_Paste)
'add synonymns (thesaurus submenu), if not in header/footer
If Me.m_ActiveHeaderFooter Is Nothing And Not helper.IsTextFrameActive Then
Dim synonymsMenuItem As New MenuItem("Synonyms")
ContextMenu1.MenuItems.Add(synonymsMenuItem)
Dim thSuggestions As MenuItem() = Me.Thesaurus1.GetSuggestionMenuItems()
Dim noSuggestionsMenuItem As New MenuItem("(No suggestions)")
Dim thesaurusMenuItem As New MenuItem("&Thesaurus...", AddressOf Thesaurus_MenuItem19_Click)
noSuggestionsMenuItem.Enabled = False
synonymsMenuItem.MenuItems.Clear()
If Not (thSuggestions Is Nothing) Then
synonymsMenuItem.MenuItems.AddRange(thSuggestions)
Else
synonymsMenuItem.MenuItems.Add(noSuggestionsMenuItem)
End If
synonymsMenuItem.MenuItems.Add("-")
synonymsMenuItem.MenuItems.Add(thesaurusMenuItem)
End If
End Sub 'contextMenu1_Popup
Sub cm_cut_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Cut()
End Sub 'cm_cut_Click
Sub cm_copy_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Copy()
End Sub 'cm_copy_Click
Sub cm_cut_Paste(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Paste()
End Sub 'cm_cut_Paste
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.
Downloads:
These projects show complete integration with both RapidSpell Desktop .NET and Thesaurus Desktop .NET, and therefore require both to be installed in order to run properly.
TX v13 C# Demo Project
TX v13 VB.NET Demo Project