Knowledgebase Home Page  >  RapidSpell Desktop .NET  >  3rd Party Ctrls
Search the Knowledge Base
How can I use RapidSpellDialog with SubSystem's TE Edit control? (C#)
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=165&catId=61

Options

Print this page
Email this to a friend

To do this, as with most 3rd party text controls, we create a class that either sits between the RapidSpellDialog and the text editor control, or subclasses the text editor control - this class then implements ISpellCheckableTextComponent.
 
 
In this example we inherit from the SubSystems.TE.Tern class, and use that instead of the regular control's class.  Note if you have used the VS designer to create your form, you can easily do a find/replace in the designer code to replace SubSystems.TE.Tern with "TernX", this will simply switch the type of the text editor control to our new subclass.
 
 
Adapter usage (place in the form with the RapidSpellDialog control)
 
editor = new TernX();

...

this.rapidSpellDialog1.ThirdPartyTextComponentToCheck = editor;

this.rapidSpellDialog1.Check();

 
 

The adapter class

using System.Text;

using System;

using SubSystems.TE;

namespace TextEditorKeyoti

{

public class TernX : SubSystems.TE.Tern, Keyoti.RapidSpell.ISpellCheckableTextComponent

{

public override string Text

{

get

{

this.TerCommand(tc.ID_SELECT_ALL);

string text = this.TerGetTextSel();

this.DeselectTerText(true);

text = (text == null) ? string.Empty : text;

return text;

}

set

{

base.Text = value;

}

}

#region ISpellCheckableTextComponent Members

private bool bHideSelection;

public bool HideSelection

{

get { return bHideSelection; } //isn't used in TE. It's either painted when an action is performed or not.

set { bHideSelection = value; this.DeselectTerText(true); }

}

public void ScrollToCaret()

{

this.TerEngageCaret(false);

}

public string SelectedText

{

get

{

return this.TerGetTextSel();

}

set

{

this.TerDeleteBlock(false);

this.InsertTerText(value,true);

}

 
If you prefer to add an 'adapter' class, rather than subclassing the control you can do that too.  
To do this, you would pass an instance of the editor to the adapter class (which would implement ISpellCheckableTextComponent) and 
map the Text, SelectionStart, SelectionLength and SelectedText properties to the appropriate calls in the editor control instance.  
Then, the adapter class can be passed to the spell checker's ThirdPartyTextComponentToCheck property.
 

Related Questions:

Attachments:

No attachments were found.