Knowledgebase Home Page  >  RapidSpell Desktop .NET  >  Behavior Customization
Search the Knowledge Base
How can I setup RapidSpellAsYouType to ignore some footer text (eg. original email)? (VB.NET)
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=167&catId=62

Options

Print this page
Email this to a friend

If you are using version 5 or version 4 please see this article instead, http://keyoti.com/kb/Default.aspx?ToDo=view&questId=114&catId=62

This article is for v3 users;

Assume in this example we have an email program and when replying to a message we don't want the original message to be spell checked (underlined).  Eg. the text looks like this

 

Hi Bob, I'm sorry.
John
 
--ORIGINAL MESSAGE--
John, please do not use contractions in your emails and presentations.
With kind regards
Bob.
 

and we don't want Bob's message to be spell checked.
 
By subclassing RapidSpellAsYouType we can override the IsInIgnorePos method which determines which parts of the text are ignored.  We can simply tell it where the ignore region begins and return true in those cases.
 
As the user types, the ignore region moves, but as an elegant trick, if we measure OriginalMessageStart from the end of the text, instead of from the beginning. The number of chars between the end of the text and your ignore position will be constant. Eg.
 

 Public Class CustomRapidSpellAsYouType
     Inherits Keyoti.RapidSpell.RapidSpellAsYouType
 
     Public OriginalMessageStart As Integer
 
     Public Sub New(ByVal container As System.ComponentModel.IContainer)
  MyBase.New(container)
     End Sub
 
     'Force words after OriginalMessageStart to be ignored (important to allow text from MyBase to be ignored too)
 
     Protected Overrides Function IsInIgnorePos(ByVal pos As Integer) As Boolean
  Return pos >= MyBase.TextComponent.TextLength - OriginalMessageStart Or MyBase.IsInIgnorePos(pos)
     End Function
 
 End Class
 
 
 
So now it will ignore the LAST OriginalMessageStart chars in your text, and this won't need to change as the user types.  To use this subclass you need to change all instances of RapidSpellAsYouType to CustomRapidSpellAsYouType in the code (including the designer regions).
 
The ignore region can then be identified and set in the .ctor.
 
Eg.
 
    Public Sub New()
        MyBase.New()
 
        'This call is required by the Windows Form Designer.
        InitializeComponent()
 
        aytRichTextBox1.Text = "nesessary errars" & Chr(13) & Chr(13) & "--ORIGINAL MESSAGE--" & Chr(13) & "nonewor of dsuhfuis isd to be cheecked."
        Dim x = aytRichTextBox1.Text.IndexOf("--ORIGINAL MESSAGE--")
        CustomRapidSpellAsYouType1.OriginalMessageStart = aytRichTextBox1.TextLength - x
 
    End Sub
 
 
 
Now it will ignore everything from --ORIGINAL MESSAGE-- to the end.

Related Questions:

Attachments:

No attachments were found.