HaimK
January 21, 2003, 13:59:15
I have found a very good .net spell checking component which works flawlessly with the textcontrol with very little additional programming effort. It is the rapidspell spell checker available at www.keyoti.com (http://www.keyoti.com).
All one needs to do is to wrap the text control in a class which implements their spell checking interface. This class can then be used transparently with the spell checker with no other special programming.
You might need to ask them specifically for the textcontrol compatible version as I don't know if the necessary interface is included in their public evaluation version.
Here is what the wrapper class looks like in C#. I also have a vb version if anyone is interested.
Haim
using System;
using Com.Keyoti.RapidSpell;
namespace Simple
{
/// <summary>
/// Summary description for RSTextControl.
/// </summary>
public class RSTextControl : TXTextControl.TextControl, ISpellCheckableTextComponent {
public RSTextControl() : base() {
}
public String SelectedText{
get{
return Selection.Text;
}
set{
if (Selection!=null) Selection.Text = value;
}
}
public int SelectionStart{
get{
//Adjust the selection start, because TextControl doesn't count newlines in selection indices.
int s = Selection.Start, numberOfNewlines=0, last=-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= s)
numberOfNewlines++;
return s + numberOfNewlines;
}
set{
//Adjust the selection start, because TextControl doesn't count newlines in selection indices.
int v = value, numberOfNewlines=0, last=-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= v)
numberOfNewlines++;
v -= numberOfNewlines;
if(Selection!=null)Selection.Start = v;
}
}
public int SelectionLength{
get{
//Adjust the selection length because TextControl doesn't count newlines in selection indices.
int l = Selection.Length, numberOfNewlines=0, last=Selection.Start-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= l)
numberOfNewlines++;
return Selection.Length + numberOfNewlines;
}
set{
if(Selection!=null){
//Adjust the selection start, because TextControl doesn't count newlines in selection indices.
int v = value, numberOfNewlines=0, last=Selection.Start-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= v)
numberOfNewlines++;
v -= numberOfNewlines;
Selection.Length = v;
}
}
}
}
}
All one needs to do is to wrap the text control in a class which implements their spell checking interface. This class can then be used transparently with the spell checker with no other special programming.
You might need to ask them specifically for the textcontrol compatible version as I don't know if the necessary interface is included in their public evaluation version.
Here is what the wrapper class looks like in C#. I also have a vb version if anyone is interested.
Haim
using System;
using Com.Keyoti.RapidSpell;
namespace Simple
{
/// <summary>
/// Summary description for RSTextControl.
/// </summary>
public class RSTextControl : TXTextControl.TextControl, ISpellCheckableTextComponent {
public RSTextControl() : base() {
}
public String SelectedText{
get{
return Selection.Text;
}
set{
if (Selection!=null) Selection.Text = value;
}
}
public int SelectionStart{
get{
//Adjust the selection start, because TextControl doesn't count newlines in selection indices.
int s = Selection.Start, numberOfNewlines=0, last=-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= s)
numberOfNewlines++;
return s + numberOfNewlines;
}
set{
//Adjust the selection start, because TextControl doesn't count newlines in selection indices.
int v = value, numberOfNewlines=0, last=-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= v)
numberOfNewlines++;
v -= numberOfNewlines;
if(Selection!=null)Selection.Start = v;
}
}
public int SelectionLength{
get{
//Adjust the selection length because TextControl doesn't count newlines in selection indices.
int l = Selection.Length, numberOfNewlines=0, last=Selection.Start-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= l)
numberOfNewlines++;
return Selection.Length + numberOfNewlines;
}
set{
if(Selection!=null){
//Adjust the selection start, because TextControl doesn't count newlines in selection indices.
int v = value, numberOfNewlines=0, last=Selection.Start-1;
while( (last=Text.IndexOf("\n",last+1))>-1 && last <= v)
numberOfNewlines++;
v -= numberOfNewlines;
Selection.Length = v;
}
}
}
}
}