Ejemplo n.º 1
0
 private void ExecuteDeleteReplaceCommand(int index)
 {
     if (index < 0 || index >= ReplaceList.Count)
     {
         return;
     }
     ReplaceList.RemoveAt(index);
 }
Ejemplo n.º 2
0
        private void _openReplace(string file)
        {
            var content = Open.Read(file);
            var matches = Regex.Matches(content, @"(.*)替换为(.*)");

            foreach (Match item in matches)
            {
                ReplaceList.Add(new ReplaceItem(item.Groups[1].Value, item.Groups[2].Value));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Spell checks a range of words in the <see cref="Text"/> property starting
        ///     at the <see cref="WordIndex"/> position and ending at endWordIndex.
        /// </summary>
        /// <param name="startWordIndex" type="int">
        ///     <para>
        ///         The index of the word to start checking from.
        ///     </para>
        /// </param>
        /// <param name="endWordIndex" type="int">
        ///     <para>
        ///         The index of the word to end checking with.
        ///     </para>
        /// </param>
        /// <returns>
        ///     Returns true if there is a word found in the text
        ///     that is not in the dictionaries
        /// </returns>
        /// <seealso cref="CurrentWord"/>
        /// <seealso cref="WordIndex"/>
        public bool SpellCheck(int startWordIndex, int endWordIndex)
        {
            if (startWordIndex > endWordIndex || _words == null || _words.Count == 0)
            {
                // make sure end index is not greater then word count
                OnEndOfText(System.EventArgs.Empty);    // raise event
                return(false);
            }

            Initialize();

            string currentWord    = "";
            bool   misspelledWord = false;

            for (int i = startWordIndex; i <= endWordIndex; i++)
            {
                WordIndex   = i; // saving the current word index
                currentWord = CurrentWord;

                if (CheckString(currentWord))
                {
                    if (!TestWord())
                    {
                        if (ReplaceList.ContainsKey(currentWord))
                        {
                            ReplacementWord = ReplaceList[currentWord];
                            ReplaceWord();
                        }
                        else if (!IgnoreList.Contains(currentWord))
                        {
                            misspelledWord = true;
                            OnMisspelledWord(new SpellingEventArgs(currentWord, i, _words[i].Index));       // raise event

                            // break;
                        }
                    }
                    else if (i > 0 && _words[i - 1].Value == currentWord &&
                             (_words[i - 1].Index + _words[i - 1].Length + 1) == _words[i].Index)
                    {
                        misspelledWord = true;
                        OnDoubledWord(new SpellingEventArgs(currentWord, i, _words[i].Index));      // raise event

                        // break;
                    }
                }
            } // for

            if (_wordIndex >= _words.Count - 1 && !misspelledWord)
            {
                OnEndOfText(System.EventArgs.Empty);    // raise event
            }

            return(misspelledWord);
        } // SpellCheck
Ejemplo n.º 4
0
        public void UpdateEnvironmentList()
        {
            string filename = PathManager.Init.GetResourcePath("EnvIntellisense.txt");

            if (File.Exists(filename))
            {
                var tempVal = File.ReadLines(filename).ToArray();
                SearchList.AddRange(tempVal);
                ReplaceList.AddRange(tempVal);
            }
        }
Ejemplo n.º 5
0
 private void _addReplace()
 {
     if (string.IsNullOrEmpty(Pattern) && string.IsNullOrEmpty(Replace))
     {
         _showMessage("替换规则添加失败!不能都为空!");
         return;
     }
     ReplaceList.Add(new ReplaceItem(Pattern, Replace));
     Pattern = Replace = string.Empty;
     _showMessage("替换规则添加成功!");
 }
Ejemplo n.º 6
0
        /// <summary>
        ///     Replaces all instances of the CurrentWord in the Text Property
        /// </summary>
        public void ReplaceAllWord()
        {
            if (CurrentWord.Length == 0)
            {
                TraceWriter.TraceWarning("No current word");
                return;
            }

            // if not in list and replacement word has length
            if (!ReplaceList.ContainsKey(CurrentWord) && _replacementWord.Length > 0)
            {
                ReplaceList.Add(CurrentWord, _replacementWord);
            }

            ReplaceWord();
        }
Ejemplo n.º 7
0
 private void ExecuteClearReplaceCommand()
 {
     ReplaceList.Clear();
 }