TextPatternRange.MoveEndpointByRange Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Metin aralığının bir uç noktasını ikinci bir metin aralığının belirtilen uç noktasına taşır.
public:
void MoveEndpointByRange(System::Windows::Automation::Text::TextPatternRangeEndpoint endpoint, System::Windows::Automation::Text::TextPatternRange ^ targetRange, System::Windows::Automation::Text::TextPatternRangeEndpoint targetEndpoint);
public void MoveEndpointByRange (System.Windows.Automation.Text.TextPatternRangeEndpoint endpoint, System.Windows.Automation.Text.TextPatternRange targetRange, System.Windows.Automation.Text.TextPatternRangeEndpoint targetEndpoint);
member this.MoveEndpointByRange : System.Windows.Automation.Text.TextPatternRangeEndpoint * System.Windows.Automation.Text.TextPatternRange * System.Windows.Automation.Text.TextPatternRangeEndpoint -> unit
Public Sub MoveEndpointByRange (endpoint As TextPatternRangeEndpoint, targetRange As TextPatternRange, targetEndpoint As TextPatternRangeEndpoint)
Parametreler
- endpoint
- TextPatternRangeEndpoint
Taşınacak uç nokta.
- targetRange
- TextPatternRange
Aynı metin sağlayıcısından başka bir aralık.
- targetEndpoint
- TextPatternRangeEndpoint
Diğer aralıktaki bir uç nokta.
Örnekler
private void MoveEndpointByRangeFromSelection(AutomationElement target)
{
// Specify the control type we're looking for, in this case 'Document'
PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);
// target --> The root AutomationElement.
AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);
TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
if (textpatternPattern == null)
{
Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
return;
}
TextPatternRange[] currentSelection = textpatternPattern.GetSelection();
TextPatternRange[] currentVisibleRanges = textpatternPattern.GetVisibleRanges();
currentSelection[0].MoveEndpointByRange(
TextPatternRangeEndpoint.Start,
currentVisibleRanges[0],
TextPatternRangeEndpoint.Start);
}
Private Sub MoveEndpointByRangeFromSelection(ByVal target As AutomationElement)
' Specify the control type we're looking for, in this case 'Document'
Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)
' target --> The root AutomationElement.
Dim textProvider As AutomationElement = target.FindFirst(TreeScope.Descendants, cond)
Dim textpatternPattern As TextPattern = CType(textProvider.GetCurrentPattern(TextPattern.Pattern), TextPattern)
If (textpatternPattern Is Nothing) Then
Console.WriteLine("Root element does not contain a descendant that supports TextPattern.")
Return
End If
Dim currentSelection As TextPatternRange() = textpatternPattern.GetSelection()
Dim currentVisibleRanges As TextPatternRange() = textpatternPattern.GetVisibleRanges()
currentSelection(0).MoveEndpointByRange(TextPatternRangeEndpoint.Start, _
currentVisibleRanges(0), _
TextPatternRangeEndpoint.Start)
End Sub
Açıklamalar
Taşınan uç nokta aynı metin aralığının diğer uç noktasını geçerse, diğer uç nokta da taşınır ve bu da bozuk bir aralıkla sonuçlanır ve uç noktaların doğru sıralanmasını sağlar (yani, Start her zaman küçük veya eşittir End).