Esempio n. 1
0
        IndexedRange GetTextRange(UITextPosition fromPosition, UITextPosition toPosition)
        {
            // Generate IndexedPosition instances that wrap the to and from ranges
            IndexedPosition @from = (IndexedPosition)fromPosition;
            IndexedPosition @to   = (IndexedPosition)toPosition;
            NSRange         range = new NSRange(Math.Min(@from.Index, @to.Index), Math.Abs(to.Index - @from.Index));

            return(IndexedRange.GetRange(range));
        }
Esempio n. 2
0
        RectangleF FirstRect(UITextRange range)
        {
            // FIXME: the Objective-C code doesn't get a null range
            // This is the reason why we don't get the autocorrection suggestions
            // (it'll just autocorrect without showing any suggestions).
            // Possibly due to http://bugzilla.xamarin.com/show_bug.cgi?id=265
            IndexedRange r = (IndexedRange)(range ?? IndexedRange.GetRange(new NSRange(0, 1)));
            // Use underlying SimpleCoreTextView to get rect for range
            RectangleF rect = textView.FirstRect(r.Range);

            // Convert rect to our view coordinates
            return(ConvertRectFromView(rect, textView));
        }
Esempio n. 3
0
        IndexedRange GetCharacterRange(UITextPosition position, UITextLayoutDirection direction)
        {
            // Note that this sample assumes LTR text direction
            IndexedPosition pos    = (IndexedPosition)position;
            NSRange         result = new NSRange(pos.Index, 1);

            switch (direction)
            {
            case UITextLayoutDirection.Up:
            case UITextLayoutDirection.Left:
                result = new NSRange(pos.Index - 1, 1);
                break;

            case UITextLayoutDirection.Right:
            case UITextLayoutDirection.Down:
                result = new NSRange(pos.Index, 1);
                break;
            }

            // Return range using our UITextRange implementation
            // Note that range is not currently checked against document range.
            return(IndexedRange.GetRange(result));
        }