ContextNodeType 类

定义用于指定 ContextNode 对象类型的值。

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public NotInheritable Class ContextNodeType
用法
Dim instance As ContextNodeType
public sealed class ContextNodeType
public ref class ContextNodeType sealed
public final class ContextNodeType
public final class ContextNodeType

备注

ContextNode.Type 属性和 InkAnalyzer.FindNodesOfType 方法经常引用 System.Windows.Ink.ContextNodeType 中的字段。

示例

此示例设置名为 selectedResultsTextBox 的 TextBoxText 属性,以显示与所选择的名为 selectedNode 的 ContextNode 相关联的字符串值。此示例使用 Type 属性根据 ContextNode 的类型值来指定文本显示。

If selectedNode.Type = ContextNodeType.WritingRegion Then
    Dim writingRegion As WritingRegionNode = CType(selectedNode, WritingRegionNode)
    selectedResultsTextBox.Text = writingRegion.GetRecognizedString()
ElseIf selectedNode.Type = ContextNodeType.Paragraph Then
    Dim paragraph As ParagraphNode = CType(selectedNode, ParagraphNode)
    selectedResultsTextBox.Text = paragraph.GetRecognizedString()
ElseIf selectedNode.Type = ContextNodeType.Line Then
    Dim line As LineNode = CType(selectedNode, LineNode)
    selectedResultsTextBox.Text = line.GetRecognizedString()
ElseIf selectedNode.Type = ContextNodeType.InkWord Then
    Dim inkWord As InkWordNode = CType(selectedNode, InkWordNode)
    Dim parentNode As ContextNode = inkWord.ParentNode
    If TypeOf parentNode Is LineNode Then
        Dim parentLine As LineNode = CType(parentNode, LineNode)
        ' Put parent line's recognized string into the text box
        selectedResultsTextBox.Text = parentLine.GetRecognizedString()

        ' Select the text that corresponds to the ink word
        Dim subNodes As New ContextNodeCollection(theInkAnalyzer)
        subNodes.Add(inkWord)
        Dim start As Integer
        Dim length As Integer
        parentLine.GetTextRangeFromNodes(subNodes, start, length)
        If start >= 0 AndAlso length > 0 Then
            selectedResultsTextBox.Select(start, length)
        End If
    End If
ElseIf selectedNode.Type = ContextNodeType.InkDrawing Then
    Dim drawingNode As InkDrawingNode = CType(selectedNode, InkDrawingNode)
    selectedResultsTextBox.Text = drawingNode.GetShapeName()
ElseIf selectedNode.Type = ContextNodeType.InkBullet Then
    Dim bulletNode As InkBulletNode = CType(selectedNode, InkBulletNode)
    selectedResultsTextBox.Text = bulletNode.GetRecognizedString()
ElseIf selectedNode.Type = ContextNodeType.CustomRecognizer Then
    Dim customRecognizer As CustomRecognizerNode = CType(selectedNode, CustomRecognizerNode)
    selectedResultsTextBox.Text = customRecognizer.GetRecognizedString()
ElseIf selectedNode.Type = ContextNodeType.Object Then
    Dim selectedObject As ObjectNode = CType(selectedNode, ObjectNode)
    selectedResultsTextBox.Text = selectedObject.GetRecognizedString()
Else
    selectedResultsTextBox.Text = ""
End If
if (selectedNode.Type == ContextNodeType.WritingRegion)
{
    WritingRegionNode writingRegion = (WritingRegionNode)selectedNode;
    selectedResultsTextBox.Text = writingRegion.GetRecognizedString();
}
else if (selectedNode.Type == ContextNodeType.Paragraph)
{
    ParagraphNode paragraph = (ParagraphNode)selectedNode;
    selectedResultsTextBox.Text = paragraph.GetRecognizedString();
}
else if (selectedNode.Type == ContextNodeType.Line)
{
    LineNode line = (LineNode)selectedNode;
    selectedResultsTextBox.Text = line.GetRecognizedString();
}
else if (selectedNode.Type == ContextNodeType.InkWord)
{
    InkWordNode inkWord = (InkWordNode)selectedNode;
    ContextNode parentNode = inkWord.ParentNode;
    if (parentNode is LineNode)
    {
        LineNode parentLine = (LineNode)parentNode;
        // Put parent line's recognized string into the text box
        selectedResultsTextBox.Text = parentLine.GetRecognizedString();

        // Select the text that corresponds to the ink word
        ContextNodeCollection subNodes = new ContextNodeCollection(theInkAnalyzer);
        subNodes.Add(inkWord);
        int start;
        int length;
        parentLine.GetTextRangeFromNodes(subNodes, out start, out length);
        if (start >= 0 && length > 0)
        {
            selectedResultsTextBox.Select(start, length);
        }
    }
}
else if (selectedNode.Type == ContextNodeType.InkDrawing)
{
    InkDrawingNode drawingNode = (InkDrawingNode)selectedNode;
    selectedResultsTextBox.Text = drawingNode.GetShapeName();
}
else if (selectedNode.Type == ContextNodeType.InkBullet)
{
    InkBulletNode bulletNode = (InkBulletNode)selectedNode;
    selectedResultsTextBox.Text = bulletNode.GetRecognizedString();
}
else if (selectedNode.Type == ContextNodeType.CustomRecognizer)
{
    CustomRecognizerNode customRecognizer = (CustomRecognizerNode)selectedNode;
    selectedResultsTextBox.Text = customRecognizer.GetRecognizedString();
}
else if (selectedNode.Type == ContextNodeType.Object)
{
    ObjectNode selectedObject = (ObjectNode)selectedNode;
    selectedResultsTextBox.Text = selectedObject.GetRecognizedString();
}
else
{
    selectedResultsTextBox.Text = "";
}

继承层次结构

System.Object
  System.Windows.Ink.ContextNodeType

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ContextNodeType 成员

System.Windows.Ink 命名空间

ContextNode.Type

InkAnalyzer.FindNodesOfType