To check the module out go these steps:
Alternatively you can check using a non-modal dialog. To do so, cancel background spellchecking first. Then, hit "Start Dialog".
The spellchecker is made as a plug-in. That means, you can remove the assembly from your project if you don't need this. You can even remove all dictionary not in use.
The features at a glance:
object item; _dropdownSpellerDictionary.ItemsSource.GetItem(_dropdownSpellerDictionary.SelectedItem, out item); // assume we keep the default path EditorDocument.SpellChecker.GetSpeller(EditorDocument.HtmlEditor).DictionaryPath = "Dictionary"; // and get the dictionary name from drop down EditorDocument.SpellChecker.GetSpeller(EditorDocument.HtmlEditor).Dictionary = String.Format("{0}.dic", ((GalleryItemPropertySet)item).Label); // stop current checking, remove all segments and restart immediately EditorDocument.HtmlEditor.InvokeCommand(EditorDocument.SpellChecker.Commands.StopBackground); EditorDocument.HtmlEditor.InvokeCommand(EditorDocument.SpellChecker.Commands.RemoveHighLight); EditorDocument.HtmlEditor.InvokeCommand(EditorDocument.SpellChecker.Commands.ClearBuffer); EditorDocument.HtmlEditor.InvokeCommand(EditorDocument.SpellChecker.Commands.StartBackground);The Label returned from ribbon contains a simple culture string, such as "en-US" or "de-DE". After the dictionary has been set, the background spellchecker is activated.
void _comboboxSpellerHighlightUnderlineStyle_ExecuteEvent(object sender, ExecuteEventArgs e) { GuruComponents.Netrix.WebEditing.HighLighting.UnderlineStyle style = (GuruComponents.Netrix.WebEditing.HighLighting.UnderlineStyle)Enum.Parse(typeof(GuruComponents.Netrix.WebEditing.HighLighting.UnderlineStyle), _comboboxSpellerHighlightUnderlineStyle.StringValue); EditorDocument.SpellChecker.GetSpellChecker(EditorDocument.HtmlEditor).HighLightStyle.UnderlineStyle = style; } void _colorpickerSpellerHighlightColor_ExecuteEvent(object sender, ExecuteEventArgs e) { EditorDocument.SpellChecker.GetSpellChecker(EditorDocument.HtmlEditor).HighLightStyle.LineColor.ColorValue = _colorpickerSpellerHighlightColor.Color; }One typical scenario is the usage of a context menu with suggestions. The following event handler creates a context menu with some static items and adds a list of suggestions:
void speller1_WordOnContext(object sender, GuruComponents.Netrix.SpellChecker.WordOnContextEventArgs e) { contextMenuTabPage.Items.Clear(); // Add Spellchecker suggestions if (speller1.GetSpellChecker(htmlEditor1).BackgroundService) { speller1.GetSpellChecker(htmlEditor1).Suggest(e.Word); List<string> suggestions = speller1.GetSpellChecker(htmlEditor1).Suggestions; if (suggestions != null && suggestions.Count > 0) { foreach (string suggestion in suggestions) { contextMenuTabPage.Items.Add(suggestion, null, (o, ea) => speller1.GetSpellChecker(htmlEditor1).ReplaceWord(suggestion)); } } else { ToolStripItem noSuggestion = contextMenuTabPage.Items.Add("No Suggestions"); noSuggestion.Enabled = false; } } // Show add desired position (Plug-in delivers the suggested position) contextMenuTabPage.Show(e.Position); }You have to call the method Suggest first. You can retrieve all suggestions through the Suggestions property, then. The explicit call is necessary to avoid the creation of suggestions all the time, because it is time consuming.
Note: It's necessary to use the speller's context menu call, because the regular context menu event appears to early and the speller has not yet pulled out the current word. This is the reason why the speller has its own context menu event.
// Dialog for word by word checking private Spellchecker SpellCheckerDialog; // Get an instance once required private Spellchecker GetSpellCheckerDialog() { if (SpellCheckerDialog == null) { SpellCheckerDialog = new Spellchecker(); SpellCheckerDialog.TopMost = true; SpellCheckerDialog.FormClosed += new FormClosedEventHandler(SpellCheckerDialog_FormClosed); SpellCheckerDialog.Show(this); } return SpellCheckerDialog; } void SpellCheckerDialog_FormClosed(object sender, FormClosedEventArgs e) { SpellCheckerDialog = null; } void speller1_DoubledWord(object sender, GuruComponents.Netrix.SpellChecker.NetSpell.SpellingEventArgs e) { GetSpellCheckerDialog().WrongWord = e.Word; } void speller1_EndOfText(object sender, GuruComponents.Netrix.SpellChecker.NetSpell.SpellingEventArgs e) { MessageBox.Show("Reached end of text.", "Spellchecker", MessageBoxButtons.OK); } void speller1_MisspelledWord(object sender, GuruComponents.Netrix.SpellChecker.NetSpell.SpellingEventArgs e) { GetSpellCheckerDialog().WrongWord = e.Word; }