Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

User Options for RapidSpell Desktop .NET

RapidSpell Desktop .NET

v6.0

The options form (in RapidSpellDialog or invoked programmatically) allows the user to store their own spell check preferences and also edit their user dictionary.

User Options Form

By default, user options are enabled and stored under .NET's IsolatedStorage. It's important to remember that user options (if enabled) will override the properties set in the spell checker controls (eg. RapidSpellAsYouType.CheckAsYouType = true will have no effect if the user has disabled check as you type).

Disabling User Options

Set OptionsEnabled in the RapidSpellDialog and/or RapidSpellAsYouType control.

Programmatically Setting User Options

Call SetUserOptions on the options object and pass the values that should be used. Then call Save to write the changes. In this example we use the existing values (so no changes are made).

Dim o As Options.UserOptions = rapidSpellDialog1.Options
rapidSpellDialog1.Options.SetUserOptions(o.CheckAsYouType, o.IncludeUserDictionaryInSuggestions, _
	o.IgnoreWordsWithDigits, o.IgnoreURLsAndEmailAddresses, o.IgnoreCapitalizedWords, _
	o.AllowMixedCase, o.AllowAnyCase, o.FindSuggestions, False)
rapidSpellDialog1.Options.Save()	}
						

Eg. To change the "Check as you type" option, replace o.CheckAsYouType with either true or false.

Changing Storage Location

Set OptionsStorageLocation to either IsolatedStorage (default), FileSystem or Stream see below.

Maintaining Separate Options Profiles

Set OptionsFileName in the RapidSpellDialog and/or RapidSpellAsYouType control to a unique name for each separate set of options to use.

Resetting / Deleting Options

Call UserOptions.Delete() to empty the file and allow the default options to be recreated. Eg. RapidSpellDialog.Options.Delete()

Launching Options Editor Programmatically

  1. Create an instance of Keyoti.RapidSpell.Options.OptionsPresenter
  2. Call it's Show method with the UserOptions instance (from either the RapidSpellAsYouType or RapidSpellDialog control)
  3. If Show returns true, then save the UserOptions object
  4. If the UserOptions instance hasn't been loaded (eg before the Check method is called in RapidSpellDialog), then set the UserDictionary property in UserOptions to a new instance of the UserDictionary class, otherwise the edit user dictionary button will not be shown.

Eg.

OptionsPresenter optionsPresenter = new OptionsPresenter();
if (optionsPresenter.Show(this, rapidSpellAsYouType1.Options))
{
	rapidSpellAsYouType1.Options.Save();
}
						

How To Use A Custom Stream For Storage

Events are available which can be used to determine when to prepare a stream to read/write to.

For example, to use a custom stream to write to an XML file;

.........
       Public Sub New()
        MyBase.New
        InitializeComponent
        rapidSpellAsYouType1.OptionsStorageLocation = Keyoti.RapidSpell.Options.UserOptions.StorageType.Stream
        rapidSpellDialog1.OptionsStorageLocation = Keyoti.RapidSpell.Options.UserOptions.StorageType.Stream
        Dim options As Keyoti.RapidSpell.Options.UserOptions = New Keyoti.RapidSpell.Options.UserOptions
        options.StorageLocation = Keyoti.RapidSpell.Options.UserOptions.StorageType.Stream
        AddHandler options.NeedCustomStreamForSaving, AddressOf Me.NeedSaveStream
        AddHandler options.NeedCustomStreamForLoading, AddressOf Me.NeedLoadStream
        AddHandler options.OptionsSaved, AddressOf Me.options_OptionsSaved
        options.Load
        rapidSpellAsYouType1.Options = options
        rapidSpellDialog1.Options = options
        rapidSpellAsYouType1.TextBoxBase = Me.aytTextBox1
    End Sub
    
    Private Sub options_OptionsSaved(ByVal sender As Object, ByVal e As Keyoti.RapidSpell.Event.OptionsSavedEventArgs)
        'update the DB?
    End Sub
    
    Private Sub NeedSaveStream(ByVal sender As Object, ByVal e As Keyoti.RapidSpell.Options.NeedStreamEventArgs)
        e.RequiredStream = New System.IO.FileStream("c:\useropt.xml", System.IO.FileMode.Truncate, System.IO.FileAccess.Write)
    End Sub
    
    Private Sub NeedLoadStream(ByVal sender As Object, ByVal e As Keyoti.RapidSpell.Options.NeedStreamEventArgs)
        e.RequiredStream = New System.IO.FileStream("c:\useropt.xml", System.IO.FileMode.OpenOrCreate)
    End Sub
.........
						

Note:

  1. RapidSpellAsYouType.TextComponent or .TextBoxBase must be set AFTER options.Load. This is because otherwise the options are loaded from the default location as soon as the textbox is set.
  2. You can use the OptionsSaved event to write the stream's contents to a DB instead.









About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.