Ejemplo n.º 1
0
        private void contextRecommendSpelling_Opening(object sender, CancelEventArgs e)
        {
            MousedWordIndex = richTextBox1.SelectionStart;
            this.toolstripRecommendSpelling.DropDownItems.Clear();
            EventHandler SpellingEventHandler = new EventHandler(SpellingRecommendationEventHandler);

            List <SpellCheckRange> ranges = SpellChecker.ProofRead(richTextBox1.Text);

            for (int count = 0; count < ranges.Count; count++)
            {
                if (ranges[count].IsWithinRange(MousedWordIndex))
                {
                    foreach (string s in SpellChecker.Recommended(ranges, count))
                    {
                        this.toolstripRecommendSpelling.DropDownItems.Add(new ToolStripMenuItem(s, null, SpellingEventHandler));
                    }
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private List <SpellCheckRange> HilightEditorText(Stellarmap.FlickerFreeRichEditTextBox control, TypingSpellChecker checker)
        {
            List <SpellCheckRange> ranges;

            //Hack Alert, this isn't entirely thread safe because I could dispose of the SpellChecker
            // but not yet make the referece invalid
            lock (control)
            {
                if (SpellChecker == null || SpellChecker.DataDisposed)
                {
                    return(null);
                }
                if (Control.MouseButtons == MouseButtons.Left || Control.MouseButtons == MouseButtons.Right)
                {
                    return(null);
                }

                bool hadFocus = control.Focused;
                int  selStart = control.SelectionStart;
                int  selLen   = control.SelectionLength;

                richTextBox1.EnablePainting = false;
                ranges = checker.ProofRead(control.Text);
                control.Select(0, control.Text.Length);
                control.SelectionFont  = new Font(control.Font, FontStyle.Regular);
                control.SelectionColor = System.Drawing.SystemColors.ControlText;


                foreach (SpellCheckRange r in ranges)
                {
                    control.Select(r.Start, r.End - r.Start);
                    control.SelectionFont  = new Font(control.Font, FontStyle.Underline);
                    control.SelectionColor = System.Drawing.Color.Red;
                }


                //richTextBox1.Enabled = true;
                if (hadFocus)
                {
                    control.Focus();
                    control.Select(selStart, selLen);
                }
                control.EnablePainting = true;
            }                    //end crit section

            return(ranges);
        }