private List <Tuple <DocumentPosition, string> > GetPreviousWords(DocumentPosition caretPosition, List <Tuple <DocumentPosition, string> > result = null)
        {
            if (result == null)
            {
                result = new List <Tuple <DocumentPosition, string> >();
            }

            DocumentPosition pos = new DocumentPosition(richTextBox.Document);

            pos.MoveToPosition(caretPosition);
            pos.MoveToPreviousWordStart();
            var text = pos.GetCurrentInlineBox().Text;

            if (text.Contains("_"))
            {
                pos.MoveToPreviousWordStart();
            }
            var previousOfMainCaret = new DocumentPosition(pos);

            if (previousOfMainCaret != caretPosition)
            {
                result.Add(new Tuple <DocumentPosition, string>(previousOfMainCaret, text));

                GetPreviousWords(previousOfMainCaret, result);
            }

            return(result);
            //////var word = GetText(previousOfMainCaret, caretPosition);// pos.Get
            //////return new Tuple<DocumentPosition, string>(previousOfMainCaret, word);
        }
        private Tuple <DocumentPosition, string> GetPreviousWord(RadDocument radDocument, DocumentPosition caretPosition)
        {
            DocumentPosition pos = new DocumentPosition(richTextBox.Document);

            pos.MoveToPosition(caretPosition);
            pos.MoveToPreviousWordStart();
            radDocument.Selection.SetSelectionStart(pos);
            radDocument.Selection.AddSelectionEnd(caretPosition);



            // var text = pos.GetCurrentInlineBox().Text;
            string text = radDocument.Selection.GetSelectedText();; // pos.GetCurrentWord();

            if (text.Contains("_"))
            {
                pos.MoveToPreviousWordStart();
                radDocument.Selection.SetSelectionStart(pos);
                radDocument.Selection.AddSelectionEnd(caretPosition);
                text = radDocument.Selection.GetSelectedText();
            }
            if (text != null && text != "" && text != ".")
            {
                if (text.EndsWith("."))
                {
                    text = text.Substring(0, text.Length - 1);
                }
            }
            var previousOfMainCaret = new DocumentPosition(pos);

            radDocument.Selection.Clear();
            return(new Tuple <DocumentPosition, string>(previousOfMainCaret, text));
            //////var word = GetText(previousOfMainCaret, caretPosition);// pos.Get
            //////return new Tuple<DocumentPosition, string>(previousOfMainCaret, word);
        }