示例#1
0
文件: lib.cs 项目: PavelPZ/libs
        static List <int> doRun(Langs lang, IEnumerable <SelectedWord> wordIdx)
        {
            if (wordIdx == null)
            {
                return(null);
            }
            List <int>       wrongIdxs = null;
            TextBox          tb        = null;
            HashSet <string> freq      = NoFrequency ? null : (Frequency.forLangs.Contains(lang) ? Frequency.isWord[lang] : null);

            foreach (var wi in wordIdx)
            {
                var isError = false;
                if (wi.ftxWord.Length > maxWordLen)                 //too long word => error
                {
                    isError = true;
                }
                else                   //else check TextBox
                {
                    if (freq != null && freq.Contains(wi.word.ToLower()))
                    {
                        continue;                                                                      //vyuziti frekvencniho slovniku
                    }
                    if (!Metas.SpellCheckLangs.Contains(lang))
                    {
                        continue;
                    }
                    if (tb == null && !textBoxes.TryGetValue(lang, out tb))
                    {
                        tb = new TextBox(); tb.SpellCheck.IsEnabled = true; tb.Language = XmlLanguage.GetLanguage(Metas.lang2string(lang));
                        textBoxes.Add(lang, tb);
                    }
                    tb.Text = wi.word;
                    if (tb.GetNextSpellingErrorCharacterIndex(0, LogicalDirection.Forward) != -1)
                    {
                        isError = true;
                    }
                }
                if (isError)
                {
                    if (wrongIdxs == null)
                    {
                        wrongIdxs = new List <int>();
                    }
                    wrongIdxs.Add(wi.idx);
                }
            }
            //if (wrongIdxs==null)
            //return wrongIdxs;
            return(wrongIdxs);
        }