Esempio n. 1
0
        /// <summary>
        /// This is used to replace all occurrences of the specified word
        /// </summary>
        /// <param name="word">The word to be replaced</param>
        /// <param name="replacement">The suggestion to use as the replacement</param>
        public void ReplaceAllOccurrences(string word, ISpellingSuggestion replacement)
        {
            var handler = ReplaceAll;

            if (handler != null)
            {
                handler(this, new SpellingEventArgs(word, replacement));
            }
        }
Esempio n. 2
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="span">The word span to replace</param>
        /// <param name="replaceWith">The suggestion to replace the misspelled word</param>
        /// <param name="dictionary">The dictionary used to perform the Replace All action</param>
        public SpellSuggestedAction(ITrackingSpan span, ISpellingSuggestion replaceWith,
                                    SpellingDictionary dictionary) : base(replaceWith.Suggestion.Replace("_", "__"), span)
        {
            this.replaceWith = replaceWith;
            this.dictionary  = dictionary;

            // The preview is used to remind users that they can hold Ctrl when selecting this suggestion to
            // replace all instances of the word.
            this.Preview = new TextBlock(new Run {
                Text = "Hold Ctrl to replace all"
            })
            {
                Padding = new Thickness(5)
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="word">The word related to the event</param>
        /// <param name="replacement">The replacement to use.  If null, an empty string is used.</param>
        public SpellingEventArgs(string word, ISpellingSuggestion replacement)
        {
            if(String.IsNullOrWhiteSpace(word))
                throw new ArgumentException("The word cannot be null or empty", "word");

            this.Word = word;

            if(replacement == null)
                this.ReplacementWord = String.Empty;
            else
            {
                this.Culture = replacement.Culture;
                this.ReplacementWord = String.IsNullOrWhiteSpace(replacement.Suggestion) ? String.Empty :
                    replacement.Suggestion;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="word">The word related to the event</param>
        /// <param name="replacement">The replacement to use.  If null, an empty string is used.</param>
        public SpellingEventArgs(string word, ISpellingSuggestion replacement)
        {
            if (String.IsNullOrWhiteSpace(word))
            {
                throw new ArgumentException("The word cannot be null or empty", "word");
            }

            this.Word = word;

            if (replacement == null)
            {
                this.ReplacementWord = String.Empty;
            }
            else
            {
                this.Culture         = replacement.Culture;
                this.ReplacementWord = String.IsNullOrWhiteSpace(replacement.Suggestion) ? String.Empty :
                                       replacement.Suggestion;
            }
        }
        //=====================================================================

        /// <summary>
        /// Constructor for spelling suggestions smart tag actions
        /// </summary>
        /// <param name="span">The word span to replace</param>
        /// <param name="replaceWith">The suggestion to replace misspelled word with</param>
        /// <param name="dictionary">The dictionary used to perform the Replace All action</param>
        public SpellSmartTagAction(ITrackingSpan span, ISpellingSuggestion replaceWith, SpellingDictionary dictionary)
        {
            this.span = span;
            this.replaceWith = replaceWith;
            this.dictionary = dictionary;
        }
        //=====================================================================

        /// <summary>
        /// Constructor for spelling suggestions smart tag actions
        /// </summary>
        /// <param name="span">The word span to replace</param>
        /// <param name="replaceWith">The suggestion to replace misspelled word with</param>
        /// <param name="dictionary">The dictionary used to perform the Replace All action</param>
        public SpellSmartTagAction(ITrackingSpan span, ISpellingSuggestion replaceWith, SpellingDictionary dictionary)
        {
            this.span        = span;
            this.replaceWith = replaceWith;
            this.dictionary  = dictionary;
        }
Esempio n. 7
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="trackingSpan">The tracking span</param>
        /// <param name="replaceWith">The suggestion to replace the misspelled word</param>
        /// <param name="escapeApostrophes">True to escape apostrophes in the suggestion, false if not</param>
        /// <param name="cultures">The cultures from which the suggested word was chosen</param>
        /// <param name="dictionary">The dictionary used to perform the Replace All action</param>
        public MultiLanguageSpellSuggestedAction(ITrackingSpan trackingSpan, ISpellingSuggestion replaceWith,
                                                 bool escapeApostrophes, IEnumerable <CultureInfo> cultures, SpellingDictionary dictionary) :
            base(trackingSpan, replaceWith, escapeApostrophes, dictionary)
        {
            this.DisplayTextSuffix = String.Join(" | ", cultures.Select(c => c.Name));
        }
Esempio n. 8
0
 /// <summary>
 /// This is used to replace all occurrences of the specified word
 /// </summary>
 /// <param name="word">The word to be replaced</param>
 /// <param name="replacement">The suggestion to use as the replacement</param>
 public void ReplaceAllOccurrences(string word, ISpellingSuggestion replacement)
 {
     ReplaceAll?.Invoke(this, new SpellingEventArgs(word, replacement));
 }
        /// <summary>
        /// This is used to replace all occurrences of the specified word
        /// </summary>
        /// <param name="word">The word to be replaced</param>
        /// <param name="replacement">The suggestion to use as the replacement</param>
        public void ReplaceAllOccurrences(string word, ISpellingSuggestion replacement)
        {
            var handler = ReplaceAll;

            if(handler != null)
                handler(this, new SpellingEventArgs(word, replacement));
        }
 /// <summary>Constructor for multi-language spelling suggestions smart tag actions.</summary>
 /// <param name="trackingSpan">The tracking span.</param>
 /// <param name="replaceWith">The suggestion to replace misspelled word with</param>
 /// <param name="cultures">The cultures from which the suggested word was chosen.</param>
 /// <param name="dictionary">The dictionary used to perform the Replace All action</param>
 public MultiLanguageSpellSmartTagAction(ITrackingSpan trackingSpan, ISpellingSuggestion replaceWith,
     IEnumerable<CultureInfo> cultures, SpellingDictionary dictionary) : base(trackingSpan, replaceWith, dictionary)
 {
     this.cultures = cultures.ToArray();
     this.displayText = null;
 }
Esempio n. 11
0
 /// <summary>Constructor for multi-language spelling suggestions smart tag actions.</summary>
 /// <param name="trackingSpan">The tracking span.</param>
 /// <param name="replaceWith">The suggestion to replace misspelled word with</param>
 /// <param name="cultures">The cultures from which the suggested word was chosen.</param>
 /// <param name="dictionary">The dictionary used to perform the Replace All action</param>
 public MultiLanguageSpellSmartTagAction(ITrackingSpan trackingSpan, ISpellingSuggestion replaceWith,
                                         IEnumerable <CultureInfo> cultures, SpellingDictionary dictionary) : base(trackingSpan, replaceWith, dictionary)
 {
     this.cultures    = cultures.ToArray();
     this.displayText = null;
 }