Knowledgebase Home Page  >  RapidSpell Desktop .NET  >  Troubleshooting
Search the Knowledge Base
With very large texts (eg. 1000 pages equivalent) the dialog spell checker takes tens of seconds to start. (C#)
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=154&catId=64

Options

Print this page
Email this to a friend

With very large documents, the startup time can be non-instant (5 seconds or more).  If you are working with very large documents, you can implement the following to quicken the GUI startup time.


1. Add the following class to the project - note the commented lines which can be switched for 3rd party component use (eg TX TextControl).

class TextBoxWindow : Keyoti.RapidSpell.ISpellCheckableTextComponent
{

//pointers to the start and end of the window - these are relative to the END of the text, doing this simplifies
//tracking the window's position as the text is changed during spell checking.

int _from, _to;


//UNCOMMENT FOR 3rd PARTY COMPONENT USE. Keyoti.RapidSpell.ISpellCheckableTextComponent _windowedTextBox;

TextBoxBase _windowedTextBox; //COMMENT FOR 3rd PARTY COMPONENT USE.

/// <summary>
/// New
/// </summary>
/// <param name="from">Where the text window starts, relative to the original text.</param>
/// <param name="to">Where the text window ends, relative to the original text.</param>
/// <param name="length">Length of text</param>
/// <param name="windowedTextBox">The textbox being 'windowed'</param>

public TextBoxWindow(int from, int to,

TextBoxBase windowedTextBox)//COMMENT FOR 3rd PARTY COMPONENT USE.

//UNCOMMENT FOR 3rd PARTY COMPONENT USE. Keyoti.RapidSpell.ISpellCheckableTextComponent windowedTextBox)
{
int length = windowedTextBox.Text.Length;
_from = length - from;
_to = length - to;
_windowedTextBox = windowedTextBox;
}
int PositionWindowInWindowedTextBox
{
get{ return _windowedTextBox.Text.Length - _from;}
}

public static Keyoti.RapidSpell.ISpellCheckableTextComponent[]
CreateTextBoxWindows(

TextBoxBase tb, int windowSize)//COMMENT FOR 3rd PARTY COMPONENT USE.
//UNCOMMENT FOR 3rd PARTY COMPONENT USE.
Keyoti.RapidSpell.ISpellCheckableTextComponent tb, int windowSize)
{

ArrayList windows = new ArrayList();
int windowStart=0;
if(tb.Text.Length == 0)
windows.Add(new TextBoxWindow(windowStart, 0, tb));
for(int i=0; i<tb.Text.Length; i=i+windowSize)
{

 if(tb.Text[i]!=' ')//ensure we end on a space (dont cut a word in half)

 i = tb.Text.IndexOf(' ', i);

 if(i<0)//couldnt find a space, so go to end

 i = tb.Text.Length;


 windows.Add(new TextBoxWindow(windowStart, i, tb));

 windowStart = i;

}

return windows.ToArray( typeof
(Keyoti.RapidSpell.ISpellCheckableTextComponent) ) as
Keyoti.RapidSpell.ISpellCheckableTextComponent[];


}

 

#region ISpellCheckableTextComponent Members

public int SelectionStart

{

get

{

return _windowedTextBox.SelectionStart - PositionWindowInWindowedTextBox;

}

set

{

_windowedTextBox.SelectionStart = value + PositionWindowInWindowedTextBox;

}

}

public event System.EventHandler GotFocus;

public int SelectionLength

{

get

{


return _windowedTextBox.SelectionLength;

}

set

{

_windowedTextBox.SelectionLength=value;

}

}

public string SelectedText

{

get

{

 

return _windowedTextBox.SelectedText;

}

set

{

//adjust from pointer

_from += value.Length - _windowedTextBox.SelectedText.Length;

_windowedTextBox.SelectedText=value;

}

}

public void ScrollToCaret()

{

_windowedTextBox.ScrollToCaret();

}

public string Text

{

get

{


return _windowedTextBox.Text.Substring(PositionWindowInWindowedTextBox,
_from - _to);

}

set

{

throw new NotImplementedException("This should never be used by the spell
checker.");

}

}

public bool HideSelection

{

get

{


return _windowedTextBox.HideSelection;

}

set

{

_windowedTextBox.HideSelection = value;

}

}

#endregion

}

 

2. Modify the spell check startup code to

private void spellCheckingMenuItem_Click(object sender, System.EventArgs e)

{

rapidSpellDialog1.ThirdPartyTextComponentsToCheck =
TextBoxWindow.CreateTextBoxWindows(richTextBox1, 100000);

richTextBox1.SelectionStart=0;

rapidSpellDialog1.Check();

}

 

This will cause the creation of 'text windows' which breakup the spell
checker's initial checking into a few smaller blocks - thereby spreading the
load time.


Related Questions:

Attachments:

No attachments were found.