当前位置: 首页>>代码示例>>C#>>正文


C# TextPatternRange.GetChildren方法代码示例

本文整理汇总了C#中System.Windows.Automation.Text.TextPatternRange.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# TextPatternRange.GetChildren方法的具体用法?C# TextPatternRange.GetChildren怎么用?C# TextPatternRange.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。


在下文中一共展示了TextPatternRange.GetChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartTarget

/// -------------------------------------------------------------------
/// <summary>
/// Starts the target application and returns the AutomationElement 
/// obtained from the targets window handle.
/// </summary>
/// <param name="exe">
/// The target application.
/// </param>
/// <param name="filename">
/// The text file to be opened in the target application
/// </param>
/// <returns>
/// An AutomationElement representing the target application.
/// </returns>
/// -------------------------------------------------------------------
private AutomationElement StartTarget(string exe, string filename)
{
    // Start text editor and load with a text file.
    Process p = Process.Start(exe, filename);

    // targetApp --> the root AutomationElement.
    AutomationElement targetApp =
        AutomationElement.FromHandle(p.MainWindowHandle);

    return targetApp;
}
开发者ID:.NET开发者,项目名称:System.Windows.Automation.Text,代码行数:26,代码来源:TextPatternRange.GetChildren

示例2: GetTextElement

/// -------------------------------------------------------------------
/// <summary>
/// Obtain the text control of interest from the target application.
/// </summary>
/// <param name="targetApp">
/// The target application.
/// </param>
/// <returns>
/// An AutomationElement that represents a text provider..
/// </returns>
/// -------------------------------------------------------------------
private AutomationElement GetTextElement(AutomationElement targetApp)
{
    // The control type we're looking for; in this case 'Document'
    PropertyCondition cond1 =
        new PropertyCondition(
        AutomationElement.ControlTypeProperty,
        ControlType.Document);

    // The control pattern of interest; in this case 'TextPattern'.
    PropertyCondition cond2 = 
        new PropertyCondition(
        AutomationElement.IsTextPatternAvailableProperty, 
        true);

    AndCondition textCondition = new AndCondition(cond1, cond2);

    AutomationElement targetTextElement =
        targetApp.FindFirst(TreeScope.Descendants, textCondition);

    // If targetText is null then a suitable text control was not found.
    return targetTextElement;
}
开发者ID:.NET开发者,项目名称:System.Windows.Automation.Text,代码行数:33,代码来源:TextPatternRange.GetChildren

示例3: GetEmbeddedObjects

/// -------------------------------------------------------------------
/// <summary>
/// Retrieves the embedded children of a document control.
/// </summary>
/// <param name="targetTextElement">
/// The AutomationElment that represents a text control.
/// </param>
/// -------------------------------------------------------------------
private void GetEmbeddedObjects(AutomationElement targetTextElement)
{
    TextPattern textPattern = 
        targetTextElement.GetCurrentPattern(TextPattern.Pattern) 
        as TextPattern;

    if (textPattern == null)
    {
        // Target control doesn't support TextPattern.
        return;
    }

    // Obtain a text range spanning the entire document.
    TextPatternRange textRange = textPattern.DocumentRange;

    // Retrieve the embedded objects within the range.
    AutomationElement[] embeddedObjects = textRange.GetChildren();

    foreach (AutomationElement embeddedObject in embeddedObjects)
    {
        Console.WriteLine(embeddedObject.Current.Name);
    }
}
开发者ID:.NET开发者,项目名称:System.Windows.Automation.Text,代码行数:31,代码来源:TextPatternRange.GetChildren


注:本文中的System.Windows.Automation.Text.TextPatternRange.GetChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。