Exemplo n.º 1
0
        private void AddWordBeforeQueryStatus(object sender, EventArgs e)
        {
            string currentWord = GetCurrentEditorWord();

            _toggleWordCommand.Enabled =
                HighlightWordsSettingsManager.CanToggleWord(currentWord);
        }
        static internal bool ToggleWord(string word)
        {
            if (!IsValidWord(word))
            {
                throw new ArgumentOutOfRangeException(
                          "column", "The string must contain only one nonempty word.");
            }
            var words = HighlightWordsSettingsManager.GetWords();

            if (words.Contains(word))
            {
                // Remove the word.
                words.Remove(word);
            }
            else
            {
                if (words.Count() >= _maxWords)
                {
                    return(false);
                }
                words.Add(word);
            }
            WriteSettings(words);
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item
        /// is clicked. See the Initialize method to see how the menu item is associated
        /// to this function using the OleMenuCommandService service and the MenuCommand
        /// class.
        /// </summary>
        private void AddWordExecuted(object sender, EventArgs e)
        {
            string word = GetApplicableWord(e);

            if (!string.IsNullOrEmpty(word))
            {
                HighlightWordsSettingsManager.ToggleWord(word);
            }
        }
        void UpdateWordsAdornments()
        {
            SnapshotPoint currentRequest = RequestedPoint;
            List <NormalizedSnapshotSpanCollection> wordSpansList = new List <NormalizedSnapshotSpanCollection>();
            var words = HighlightWordsSettingsManager.GetWords();

            foreach (string word in words)
            {
                //Find the new spans
                FindData findData = new FindData(word, SourceBuffer.CurrentSnapshot)
                {
                    FindOptions = FindOptions.WholeWord | FindOptions.MatchCase
                };

                wordSpansList.Add(new NormalizedSnapshotSpanCollection(TextSearchService.FindAll(findData)));
            }

            //If another change hasn't happened, do a real update
            if (currentRequest == RequestedPoint)
            {
                SynchronousUpdate(currentRequest, wordSpansList);
            }
        }
Exemplo n.º 5
0
 private void RemoveAllWordsExecuted(object sender, EventArgs e)
 {
     HighlightWordsSettingsManager.RemoveAllWords();
 }