private void MnuSpellCheck_Click(object sender, EventArgs e) { //scintilla.ContextMenuStrip = cmsTest; // comment this in case not needed for testing.. DateTime dt = DateTime.Now; spellCheck = new ScintillaSpellCheck(scintilla, @"C:\Files\GitHub\dictionaries\en\en_US.dic", @"C:\Files\GitHub\dictionaries\en\en_US.aff"); spellCheck.WordAddDictionaryRequested += SpellCheck_WordAddDictionaryRequested; spellCheck.ShowDictionaryTopMenuItem = true; spellCheck.ToExistingMenu = false; spellCheck.ShowIgnoreMenu = true; spellCheck.ShowAddToDictionaryMenu = true; spellCheck.SpellCheckScintillaFast(); MessageBox.Show((DateTime.Now - dt).TotalMilliseconds.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="TabbedDocumentSpellCheck"/> class. /// </summary> /// <param name="document">The <see cref="ScintillaTabbedDocument"/> to attach the spell checker.</param> /// <param name="loadDictionaryFiles">Specifies whether the dictionary files should be loaded to the instance.</param> public TabbedDocumentSpellCheck(ScintillaTabbedDocument document, bool loadDictionaryFiles) { // verify the settings and the fact that the document doesn't already have this instance.. if (FormSettings.Settings.EditorUseSpellChecking && File.Exists(FormSettings.Settings.EditorHunspellDictionaryFile) && File.Exists(FormSettings.Settings.EditorHunspellAffixFile) && document.Tag0 == null) { try { SpellCheck = new ScintillaSpellCheck(document.Scintilla, FormSettings.Settings.EditorHunspellDictionaryFile, FormSettings.Settings.EditorHunspellAffixFile, UserDictionaryFile, UserIgnoreWordFile) { MenuIgnoreText = DBLangEngine.GetStatMessage("msgSpellCheckIgnoreWordMenuText", "Ignore word \"{0}\".|A context menu item for spell checking to ignore a word"), MenuAddToDictionaryText = DBLangEngine.GetStatMessage( "msgSpellCheckAddWordToDictionaryText", "Add word \"{0}\" to the dictionary.|A context menu item for spell checking to add a word to the dictionary"), MenuDictionaryTopItemText = DBLangEngine.GetStatMessage("msgSpellChecking", "Spell checking|A message displayed in a spelling correct menu's top item."), ShowDictionaryTopMenuItem = true, AddBottomSeparator = true, ShowIgnoreMenu = true, ShowAddToDictionaryMenu = true, ScintillaIndicatorColor = FormSettings.Settings.EditorSpellCheckColor, }; if (!loadDictionaryFiles) { SpellCheck.Dictionary = null; } // add this instance to the document's Tag0 property.. document.Tag0 = this; // subscribe to the event where a user wishes to correct a // misspelled word via the context menu.. SpellCheck.UserWordReplace += SpellCheck_UserWordReplace; // subscribe to the Scintilla text changed event.. document.Scintilla.TextChanged += Scintilla_TextChanged; // subscribe the event when a user is requesting a word to be added to the personal dictionary.. SpellCheck.WordAddDictionaryRequested += SpellCheck_WordAddDictionaryOrIgnoreRequested; // subscribe to the event when a user is requesting to add a word to personal ignore list.. SpellCheck.WordIgnoreRequested += SpellCheck_WordAddDictionaryOrIgnoreRequested; // save the Scintilla instance to unsubscribe the events.. Scintilla = document.Scintilla; // spell check the document for the first time.. SpellCheck?.SpellCheckScintillaFast(); // save the time of the latest spell check.. LastSpellCheck = DateTime.Now; } catch (Exception ex) { // log the exception.. ExceptionLogAction?.Invoke(ex); try { ExceptionLogger.LogMessage($"Spell check state: '{FormSettings.Settings.EditorUseSpellChecking}'."); ExceptionLogger.LogMessage( $"File exists ({File.Exists(FormSettings.Settings.EditorHunspellDictionaryFile)}): '{FormSettings.Settings.EditorHunspellDictionaryFile}'."); ExceptionLogger.LogMessage( $"File exists ({File.Exists(FormSettings.Settings.EditorHunspellAffixFile)}): '{FormSettings.Settings.EditorHunspellAffixFile}'."); ExceptionLogger.LogMessage($"Document Tag0: '{document.Tag0}'."); } catch (Exception ex2) { ExceptionLogger.LogError(ex2); } } } else { try { ExceptionLogger.LogMessage($"Spell check state: '{FormSettings.Settings.EditorUseSpellChecking}'."); ExceptionLogger.LogMessage( $"File exists ({File.Exists(FormSettings.Settings.EditorHunspellDictionaryFile)}): '{FormSettings.Settings.EditorHunspellDictionaryFile}'."); ExceptionLogger.LogMessage( $"File exists ({File.Exists(FormSettings.Settings.EditorHunspellAffixFile)}): '{FormSettings.Settings.EditorHunspellAffixFile}'."); ExceptionLogger.LogMessage($"Document Tag0: '{document.Tag0}'."); } catch (Exception ex) { ExceptionLogger.LogError(ex); } } }