Esempio n. 1
0
        private void GetCaretPosition(out int ColumnNumber, out int LineNumber)
        {
            TextPointer current = rtbConsole.CaretPosition;
            var         start   = current.GetEdgeTextPointer(LogicalDirection.Backward); // Word position before caret
            var         end     = current.GetEdgeTextPointer(LogicalDirection.Forward);  // Word position after caret

            current.GetCharacterRect(LogicalDirection.Forward);
            current.GetLineStartPosition(-int.MaxValue, out LineNumber);
            if (LineNumber < 0)
            {
                LineNumber *= -1;
            }
            LineNumber++;

            //var p = rtbConsole.Document.Blocks.ElementAt(lineNumber - 1) as Paragraph;
            ColumnNumber = start.GetLineStartPosition(0).GetOffsetToPosition(current) - 3;
        }