Exemplo n.º 1
0
        static UITextPosition GetSelectionEnd(UITextView textView, IEditor editor, UITextPosition start, int startOffset)
        {
            int selectionLength = editor.SelectionLength;
            int textFieldLength = textView.Text == null ? 0 : textView.Text.Length;
            // Get the desired range in respect to the actual length of the text we are working with
            UITextPosition end       = textView.GetPosition(start, Math.Min(textFieldLength - editor.CursorPosition, selectionLength)) ?? start;
            int            endOffset = Math.Max(startOffset, (int)textView.GetOffsetFromPosition(textView.BeginningOfDocument, end));

            int newSelectionLength = Math.Max(0, endOffset - startOffset);

            if (newSelectionLength != selectionLength)
            {
                editor.SelectionLength = newSelectionLength;
            }

            return(end);
        }