Esempio n. 1
0
        private void _Check()
        {
            List <Word> lbw;

            if ((!isSCInit) || (_ftb == null) || (string.IsNullOrWhiteSpace(_ftb.Text)))
            {
                return;
            }
            try
            {
                lbw = _spc.CheckTextSpell(_ftb.Text);
                if (lbw.Count == 0)
                {
                    FCBTWordSelector.DataSource = new string[] {
                        Properties.Resources.txtSpellMwnuNoMiss,
                        Properties.Resources.txtSpellMwnuClose
                    };
                    FLSpellWorCount.Text =
                        string.Format(
                            Properties.Resources.fmtSpellCount,
                            0
                            );
                    _SpellReset();
                }
                else if ((lbw[0] != null) && (!string.IsNullOrWhiteSpace(lbw[0].Text)))
                {
                    _bw = lbw[0];
                    int i = 0;
                    SpellSuggestion[] suggest = _spc.SuggestCorrectedWords(_bw.Text, true);
                    List <string>     dtsrc   = suggest.Select(s => s.Text).ToList <string>();

                    dtsrc.Insert(i++, Properties.Resources.txtSpellMwnuReplace);
                    dtsrc.Insert(i++, Properties.Resources.txtSpellMwnuRestore);
                    dtsrc.Insert(i++, Properties.Resources.txtSpellMwnuAddDictionary + _bw.Text + "'");
                    dtsrc.Insert(i++, Properties.Resources.txtSpellMwnuCancel);
                    dtsrc.Insert(i++, Properties.Resources.txtSpellMwnuClose);
                    dtsrc.Insert(i++, Properties.Resources.txtSpellMwnuUnderline);
                    FCBTWordSelector.DataSource = dtsrc.ToArray();
                    FLSpellWorCount.Text        =
                        string.Format(
                            Properties.Resources.fmtSpellCount,
                            lbw.Count
                            );

                    List <TxtPosition> ltp = new List <TxtPosition>();

                    foreach (Word w in lbw)
                    {
                        TxtPosition tp = new TxtPosition(w.StartIndex, w.EndIndex, w.Length);
                        ltp.Add(tp);
                    }
                    _ftb.SpellMark = ltp;
                    _ftb.Select(_bw.StartIndex, _bw.Length);
                    _ftb.Invalidate();
                    _ftb.Focus();
                    _iLog.Line(
                        Properties.Resources.txtStatusBadWord +
                        String.Join(", ", lbw.Select(s => s.Text).ToArray())
                        );
                }
            }
            catch (Exception ex)
            {
                _iLog.LogError(ex.Message);
            }
        }