Interface ITextRangeProvider
Exposes methods and properties to support UI automation client access to a span of continuous text in a text container that implements ITextProvider.
Namespace: System.Windows.Automation.Provider
Assembly: OpenSilver.dll
Syntax
public interface ITextRangeProvider
Methods
| Improve this Doc View SourceAddToSelection()
Adds to the collection of highlighted text in a text container that supports multiple disjoint selections.
Declaration
void AddToSelection()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The text provider does not support multiple disjoint selections. |
Clone()
Returns a new ITextRangeProvider that is identical to the original ITextRangeProvider and that inherits all the properties of the original.
Declaration
ITextRangeProvider Clone()
Returns
Type | Description |
---|---|
ITextRangeProvider | The new text range. This method never returns null. |
Compare(ITextRangeProvider)
Returns a value that indicates whether the span (the Start endpoint through the End endpoint) of a text range is the same as another text range.
Declaration
bool Compare(ITextRangeProvider range)
Parameters
Type | Name | Description |
---|---|---|
ITextRangeProvider | range | A text range to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if the span of both text ranges is identical; otherwise, false. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The range to compare does not come from the same text provider. |
CompareEndpoints(TextPatternRangeEndpoint, ITextRangeProvider, TextPatternRangeEndpoint)
Returns a value that specifies whether two text ranges have identical endpoints.
Declaration
int CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint)
Parameters
Type | Name | Description |
---|---|---|
TextPatternRangeEndpoint | endpoint | |
ITextRangeProvider | targetRange | The target range for comparison. |
TextPatternRangeEndpoint | targetEndpoint |
Returns
Type | Description |
---|---|
System.Int32 | Returns a negative value if the caller's endpoint occurs earlier in the text than the target endpoint. Returns zero if the caller's endpoint is at the same location as the target endpoint. Returns a positive value if the caller's endpoint occurs later in the text than the target endpoint. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The |
ExpandToEnclosingUnit(TextUnit)
Expands the text range to the specified text unit.
Declaration
void ExpandToEnclosingUnit(TextUnit unit)
Parameters
Type | Name | Description |
---|---|---|
TextUnit | unit | The textual unit. |
FindAttribute(Int32, Object, Boolean)
Returns a text range subset that has the specified attribute ID and attribute value.
Declaration
ITextRangeProvider FindAttribute(int attributeId, object value, bool backward)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | attributeId | The attribute ID to search for. |
System.Object | value | The attribute value to search for. This value must match the specified attribute type. |
System.Boolean | backward | true if the last occurring text range should be returned instead of the first; otherwise, false. |
Returns
Type | Description |
---|---|
ITextRangeProvider | A text range that has a matching attribute ID and attribute value; otherwise, null. |
FindText(String, Boolean, Boolean)
Returns a text range subset that contains the specified text.
Declaration
ITextRangeProvider FindText(string text, bool backward, bool ignoreCase)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text string to search for. |
System.Boolean | backward | true to return the last occurring text range instead of the first; otherwise, false. |
System.Boolean | ignoreCase | true to ignore case; otherwise, false. |
Returns
Type | Description |
---|---|
ITextRangeProvider | A text range that matches the specified text; otherwise, null. |
GetAttributeValue(Int32)
Retrieves the value of the specified attribute ID across the text range.
Declaration
object GetAttributeValue(int attributeId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | attributeId | The text attribute ID. |
Returns
Type | Description |
---|---|
System.Object | Retrieves an object that represents the value of the specified attribute. See Remarks. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The specified attribute ID is not valid. |
GetBoundingRectangles()
Retrieves a collection of bounding rectangles for each fully or partially visible line of text in a text range.
Declaration
double[] GetBoundingRectangles()
Returns
Type | Description |
---|---|
System.Double[] | An array of bounding rectangles for each full or partial line of text in a text range. See Remarks. |
Remarks
This method returns an empty array for a degenerate range. This method returns an empty array for a text range that has screen coordinates that place it completely off-screen, are scrolled out of view, or are obscured by an overlapping window.
GetChildren()
Retrieves a collection of all the embedded objects that exist within the text range.
Declaration
IRawElementProviderSimple[] GetChildren()
Returns
Type | Description |
---|---|
IRawElementProviderSimple[] | A collection of child objects that exist within the range. Child objects that overlap with the text range but are not completely enclosed by it are also included in the collection. Returns an empty collection if no child objects exist. |
GetEnclosingElement()
Returns the innermost element that encloses the text range.
Declaration
IRawElementProviderSimple GetEnclosingElement()
Returns
Type | Description |
---|---|
IRawElementProviderSimple | The enclosing control, typically the text provider that provides the text range. However, if the text provider supports child text elements such as tables or hyperlinks, the enclosing element can be a descendant of the text provider. |
GetText(Int32)
Retrieves the plain text of the range.
Declaration
string GetText(int maxLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxLength | The maximum length of the string to return. Use -1 to specify an unlimited length. |
Returns
Type | Description |
---|---|
System.String | The plain text of the text range, which might represent a portion of the full string
truncated at the specified |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
Move(TextUnit, Int32)
Moves the text range the specified number of text units.
Declaration
int Move(TextUnit unit, int count)
Parameters
Type | Name | Description |
---|---|---|
TextUnit | unit | The text unit boundary. |
System.Int32 | count | The number of text units to move.A positive value moves the text range forward; a negative value moves the text range backward; and a value of 0 has no effect. |
Returns
Type | Description |
---|---|
System.Int32 | The number of units actually moved. This value can be less than the
|
MoveEndpointByRange(TextPatternRangeEndpoint, ITextRangeProvider, TextPatternRangeEndpoint)
Moves one endpoint of a text range to the specified endpoint of a second text range.
Declaration
void MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint)
Parameters
Type | Name | Description |
---|---|---|
TextPatternRangeEndpoint | endpoint | The endpoint to move. |
ITextRangeProvider | targetRange | Another range from the same text provider. |
TextPatternRangeEndpoint | targetEndpoint | An endpoint on the other range. |
MoveEndpointByUnit(TextPatternRangeEndpoint, TextUnit, Int32)
Moves one endpoint of the text range the specified number of text units within the document range.
Declaration
int MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count)
Parameters
Type | Name | Description |
---|---|---|
TextPatternRangeEndpoint | endpoint | The endpoint to move. |
TextUnit | unit | The textual unit for moving. |
System.Int32 | count | The number of units to move. A positive value moves the endpoint forward; a negative value moves the endpoint backward; and a value of 0 has no effect. |
Returns
Type | Description |
---|---|
System.Int32 | The number of units actually moved. This value can be less than the |
RemoveFromSelection()
From the collection of highlighted text in a text container that supports multiple disjoint selections, removes a highlighted section of text that corresponds to the caller's Start and End endpoints.
Declaration
void RemoveFromSelection()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The text provider does not support multiple disjoint. |
ScrollIntoView(Boolean)
Causes the text control to scroll vertically until the text range is visible in the viewport.
Declaration
void ScrollIntoView(bool alignToTop)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | alignToTop | true if the text control should be scrolled so that the text range is flush with the top of the viewport; false if the text range is flush with the bottom of the viewport. |
Select()
Highlights text in the text control that corresponds to the Start and End endpoints of the text range.
Declaration
void Select()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Text selection is not supported by the text control. |