Exemple #1
0
        /// <summary>
        /// Moves the range the specified number of units in the text.  Note that the text is not altered.  Instead the
        /// range spans a different part of the text.
        /// If the range is degenerate, this method tries to move the insertion point count units.  If the range is nondegenerate
        /// and count is greater than zero, this method collapses the range at its end point, moves the resulting range forward
        /// to a unit boundary (if it is not already at one), and then tries to move count - 1 units forward. If the range is
        /// nondegenerate and count is less than zero, this method collapses the range at the starting point, moves the resulting
        /// range backward to a unit boundary (if it isn't already at one), and then tries to move |count| - 1 units backward.
        /// Thus, in both cases, collapsing a nondegenerate range, whether or not moving to the start or end of the unit following
        /// the collapse, counts as a unit.
        /// </summary>
        /// <param name="unit">The textual unit for moving.</param>
        /// <param name="count">The number of units to move.  A positive count moves the range forward.
        /// A negative count moves backward. A count of 0 has no effect.</param>
        /// <returns>The number of units actually moved, which can be less than the number requested if
        /// moving the range runs into the beginning or end of the document.</returns>
        public int Move(TextUnit unit, int count)
        {
            ValidateUnitArgument(unit, "unit");
            // note: we could optimize the case of count==0 and just return 0.

            return(UiaCoreApi.TextRange_Move(_hTextRange, unit, count));
        }