//===================================================================== /// <inheritdoc /> public override void Invoke(CancellationToken cancellationToken) { // Remove mnemonics string wordToIgnore = this.Span.GetText(this.Span.TextBuffer.CurrentSnapshot).Replace("&", String.Empty).Replace("_", String.Empty); try { var words = new HashSet <string>(Utility.LoadUserDictionary(ignoredWordsFile, false, false), StringComparer.OrdinalIgnoreCase); if (!words.Contains(wordToIgnore)) { words.Add(wordToIgnore); if (!ignoredWordsFile.CanWriteToUserWordsFile(null)) { MessageBox.Show("Ignored words file is read-only or could not be checked out", PackageResources.PackageTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Utility.SaveCustomDictionary(ignoredWordsFile, false, false, words); } } catch (Exception ex) { // Ignore errors, we just won't save it to the file Debug.WriteLine(ex); } dictionary.IgnoreWord(wordToIgnore); }
/// <summary> /// This method is executed when action is selected in the context menu. /// </summary> public void Invoke() { bool succeeded; switch (action) { case DictionaryAction.IgnoreOnce: dictionary.IgnoreWordOnce(span); succeeded = true; break; case DictionaryAction.IgnoreAll: succeeded = dictionary.IgnoreWord(span.GetText(span.TextBuffer.CurrentSnapshot)); break; default: succeeded = dictionary.AddWordToDictionary(span.GetText(span.TextBuffer.CurrentSnapshot)); break; } Debug.Assert(succeeded, "Call to modify dictionary was unsuccessful"); }
//===================================================================== /// <inheritdoc /> public override void Invoke(CancellationToken cancellationToken) { bool succeeded; switch (action) { case DictionaryAction.IgnoreOnce: dictionary.IgnoreWordOnce(this.Span); succeeded = true; break; case DictionaryAction.IgnoreAll: succeeded = dictionary.IgnoreWord(this.Span.GetText(this.Span.TextBuffer.CurrentSnapshot)); break; default: succeeded = dictionary.AddWordToDictionary(this.Span.GetText( this.Span.TextBuffer.CurrentSnapshot), culture); break; } Debug.Assert(succeeded, "Call to modify dictionary was unsuccessful"); }
/// <summary> /// Ignore the word /// </summary> private void IgnoreWord() { dictionary.IgnoreWord(selectedMisspelling.Word); textBox.RaiseEvent(new TextChangedEventArgs(TextBox.TextChangedEvent, UndoAction.None)); }