Exemple #1
0
        IndexedPosition GetPosition(UITextRange range, UITextLayoutDirection direction)
        {
            // Note that this sample assumes LTR text direction
            IndexedRange r   = (IndexedRange)range;
            int          pos = r.Range.Location;

            // For this sample, we just return the extent of the given range if the
            // given direction is "forward" in a LTR context (UITextLayoutDirectionRight
            // or UITextLayoutDirectionDown), otherwise we return just the range position
            switch (direction)
            {
            case UITextLayoutDirection.Up:
            case UITextLayoutDirection.Left:
                pos = r.Range.Location;
                break;

            case UITextLayoutDirection.Right:
            case UITextLayoutDirection.Down:
                pos = r.Range.Location + r.Range.Length;
                break;
            }

            // Return text position using our UITextPosition implementation.
            // Note that position is not currently checked against document range.
            return(IndexedPosition.GetPosition(pos));
        }
Exemple #2
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));
        }
Exemple #3
0
        IndexedPosition GetPosition(UITextPosition position, UITextLayoutDirection direction, int offset)
        {
            // Note that this sample assumes LTR text direction
            IndexedPosition pos    = (IndexedPosition)position;
            int             newPos = pos.Index;

            switch (direction)
            {
            case UITextLayoutDirection.Right:
                newPos += offset;
                break;

            case UITextLayoutDirection.Left:
                newPos -= offset;
                break;

            case UITextLayoutDirection.Up:
            case UITextLayoutDirection.Down:
                // This sample does not support vertical text directions
                break;
            }

            // Verify new position valid in document

            if (newPos < 0)
            {
                newPos = 0;
            }

            if (newPos > text.Length)
            {
                newPos = text.Length;
            }

            return(IndexedPosition.GetPosition(newPos));
        }
		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);
		}
		IndexedPosition GetPosition (UITextRange range, UITextLayoutDirection direction)
		{
			// Note that this sample assumes LTR text direction
			IndexedRange r = (IndexedRange) range;
			int pos = r.Range.Location;
			
			// For this sample, we just return the extent of the given range if the
			// given direction is "forward" in a LTR context (UITextLayoutDirectionRight
			// or UITextLayoutDirectionDown), otherwise we return just the range position
			switch (direction) {
			case UITextLayoutDirection.Up:
			case UITextLayoutDirection.Left:
				pos = r.Range.Location;
				break;
			case UITextLayoutDirection.Right:
			case UITextLayoutDirection.Down:
				pos = r.Range.Location + r.Range.Length;
				break;
			}
			
			// Return text position using our UITextPosition implementation.
			// Note that position is not currently checked against document range.
			return IndexedPosition.GetPosition (pos);
		}
		IndexedPosition GetPosition (UITextPosition position, UITextLayoutDirection direction, int offset)
		{
			// Note that this sample assumes LTR text direction
			IndexedPosition pos = (IndexedPosition) position;
			int newPos = pos.Index;
			
			switch (direction) {
			case UITextLayoutDirection.Right:
				newPos += offset;
				break;
			case UITextLayoutDirection.Left:
				newPos -= offset;
				break;
			case UITextLayoutDirection.Up:
			case UITextLayoutDirection.Down:
				// This sample does not support vertical text directions
				break;
			}
			
			// Verify new position valid in document
			
			if (newPos < 0)
				newPos = 0;
			
			if (newPos > text.Length)
				newPos = text.Length;
			
			return IndexedPosition.GetPosition (newPos);
		}
Exemple #7
0
 IndexedRange GetCharacterRange(UITextPosition position, UITextLayoutDirection direction)
 {
     throw new NotImplementedException();
 }
Exemple #8
0
 IndexedPosition GetPosition(UITextRange range, UITextLayoutDirection direction)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 IndexedPosition GetPosition(UITextPosition position, UITextLayoutDirection direction, int offset)
 {
     throw new NotImplementedException();
 }