Share via


InkAnalyzer.GetTextRangeFromNodes 方法

查找已识别字符串中对应于 ContextNode 对象集合的文本范围。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)

语法

声明
Public Sub GetTextRangeFromNodes ( _
    nodesToSearch As ContextNodeCollection, _
    <OutAttribute> ByRef start As Integer, _
    <OutAttribute> ByRef length As Integer _
)
用法
Dim instance As InkAnalyzer
Dim nodesToSearch As ContextNodeCollection
Dim start As Integer
Dim length As Integer

instance.GetTextRangeFromNodes(nodesToSearch, _
    start, length)
public void GetTextRangeFromNodes(
    ContextNodeCollection nodesToSearch,
    out int start,
    out int length
)
public:
void GetTextRangeFromNodes(
    ContextNodeCollection^ nodesToSearch, 
    [OutAttribute] int% start, 
    [OutAttribute] int% length
)
public void GetTextRangeFromNodes(
    ContextNodeCollection nodesToSearch,
    /** @attribute OutAttribute */ /** @ref */int start,
    /** @attribute OutAttribute */ /** @ref */int length
)
public function GetTextRangeFromNodes(
    nodesToSearch : ContextNodeCollection, 
    start : int, 
    length : int
)

参数

  • start
    类型:System.Int32%
    此方法返回时,start 参数包含指示文本范围起点的 32 位有符号整数。该参数未经初始化即被传递。
  • length
    类型:System.Int32%
    此方法返回时,length 参数包含指示文本范围长度的 32 位有符号整数。该参数未经初始化即被传递。

备注

如果 nodesToSearch 包含的 ContextNode 对象不相邻,则此方法返回涵盖所有 ContextNode 对象的最小文本范围。

如果 nodesToSearch 包含不与 InkAnalyzer 关联的 ContextNode,则此方法引发 System.ArgumentException

示例

此示例定义 SelectTextRangeFromNodes 方法,该方法将 System.Windows.Forms.TextBox (theResultsTextBox) 的文本设置为 InkAnalyzer (theInkAnalyzer) 的已识别字符串。然后将文本框选择范围设置为涵盖参数 theContextNodes 的已识别文本。

''' <summary>
''' Selects the text range in the TextBox, theResultsTextBox, that represents
''' the node ranges in theContextNodes.
''' </summary>
''' <param name="theContextNodes">
''' The nodes for which to select the text range.</param>
''' <remarks>
''' If <paramref name="theContextNodes"/> are not current context nodes
''' of the InkAnalyzer, theInkAnalyzer, then GetTextRangeFromNodes throws
''' an ArgumentException.
''' </remarks>
Private Sub SelectTextRangeFromNodes(ByVal theContextNodes As Microsoft.Ink.ContextNodeCollection)
    ' Set the text of theResultsTextBox.
    Me.theResultsTextBox.Text = Me.theInkAnalyzer.GetRecognizedString()

    ' Get the text range for theContextNodes.
    Dim theStart As Integer
    Dim theLength As Integer
    Try
        Me.theInkAnalyzer.GetTextRangeFromNodes( _
            theContextNodes, theStart, theLength)
        ' Check for common exceptions.
    Catch ex As ArgumentException
        Throw New ArgumentException( _
            "Invalid ContextNodeCollection", "theContextNodes", ex)
    End Try

    ' Select the text range in the TextBox.
    Me.theResultsTextBox.Select(theStart, theLength)
    Me.theResultsTextBox.Invalidate()

End Sub 'SelectTextRangeFromNodes
/// <summary>
/// Selects the text range in the TextBox, theResultsTextBox, that represents
/// the node ranges in theContextNodes.
/// </summary>
/// <param name="theContextNodes">
/// The nodes for which to select the text range.</param>
/// <remarks>
/// If <paramref name="theContextNodes"/> are not current context nodes
/// of the InkAnalyzer, theInkAnalyzer, then GetTextRangeFromNodes throws
/// an ArgumentException.
/// </remarks>
private void SelectTextRangeFromNodes(
    Microsoft.Ink.ContextNodeCollection theContextNodes)
{
    // Set the text of theResultsTextBox.
    this.theResultsTextBox.Text = this.theInkAnalyzer.GetRecognizedString();

    // Get the text range for theContextNodes.
    int theStart;
    int theLength;
    try
    {
        this.theInkAnalyzer.GetTextRangeFromNodes(
            theContextNodes, out theStart, out theLength);
    }
    // Check for common exceptions.
    catch (ArgumentException ex)
    {
        throw new ArgumentException("Invalid ContextNodeCollection",
            "theContextNodes", ex);
    }

    // Select the text range in the TextBox.
    this.theResultsTextBox.Select(theStart, theLength);
    this.theResultsTextBox.Invalidate();
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

InkAnalyzer 类

InkAnalyzer 成员

Microsoft.Ink 命名空间