private void SpellCheck() { if (!IsLoaded()) { return; } if (!SpellCheckEnable) { return; } if (Text == string.Empty) { WordCache = new Dictionary <string, bool>(); LastSpellCheck = null; } if (LastSpellCheck == Text) { return; } else { LastSpellCheck = Text; } //Backup and Reset values ErrorCount = 0; SuggestionLoaded = false; TextSuggestions = new Suggestion[0]; string[] Words = Text.Split(WordSeparators); this.ClearAllFormatting(Font); //SpellCheck for (int i = 0, WIndex = 0; i < Words.Length; WIndex += Words[i].Length, i++) { if (!WordCache.ContainsKey(Words[i].ToLower())) { WordCache.Add(Words[i].ToLower(), SpellChecker.Spell(Words[i])); } if (WordTL.ContainsKey(Words[i])) { if (WordTL[Words[i]].Length > 0 && WordTL[Words[i]][0] == IGNORE) { continue; } ErrorCount++; WaveWord(WIndex + i, Words[i].Length); } else if (!WordCache[Words[i].ToLower()]) { ErrorCount++; WaveWord(WIndex + i, Words[i].Length); } } foreach (string Phrase in PhraseCache.Keys) { if (Text.ToLower().Contains(Phrase)) { string lt = Text.ToLower(); for (int i = 0; i < Text.Length; i++) { if (i + Phrase.Length > Text.Length) { break; } string sub = lt.Substring(i, Phrase.Length); if (sub == Phrase) { ErrorCount++; WaveWord(i, Phrase.Length); if (PaintTerms) { Select(i, Phrase.Length); SelectionColor = Color.Green; } } } } } if (!Program.OfflineMode) { new System.Threading.Thread((Str) => { try { string Text = (string)Str; VNXTLP.Result Result; if (QueryCache.ContainsKey(Text)) { Result = QueryCache[Text]; } else { Result = LanguageTool.Check(Text, TargetLang, ProxyHelper.Proxy); QueryCache[Text] = Result; } HintCount = Result.matches.Length; List <Suggestion> Suggetions = new List <Suggestion>(); foreach (Match match in Result.matches) { int Pos = match.offset; while (Text[Pos] == ' ') { Pos++; } int Len = match.length - (Pos - match.offset); if (Len != match.length) { continue; } string Word = Text.Substring(Pos, Len); if (WordCache.ContainsKey(Word) && WordCache[Word]) { continue; } WaveWord(Pos, Len); Suggetions.Add(new Suggestion() { Word = Word, Suggestions = (from x in match.replacements select x.value).ToList(), Info = match.message, Pos = Pos, Len = Len }); } TextSuggestions = Suggetions.ToArray(); } catch { } }).Start(Text); } }