ContextNode.Type, propriété
Mise à jour : November 2007
Obtient le type de nœud de contexte de cet objet ContextNode.
Espace de noms : System.Windows.Ink
Assembly : IAWinFX (dans IAWinFX.dll)
Syntaxe
'Déclaration
Public ReadOnly Property Type As Guid
'Utilisation
Dim instance As ContextNode
Dim value As Guid
value = instance.Type
public Guid Type { get; }
public:
property Guid Type {
Guid get ();
}
/** @property */
public Guid get_Type()
public function get Type () : Guid
Valeur de propriété
Type : System.Guid
Nœud de contexte de cet objet ContextNode.
Exemples
L'exemple suivant montre comment utiliser la propriété Type d'un objet ContextNode nommé selectedNode. Le texte d'un TextBox, selectedResultsTextBox, est rempli différemment selon le type de nœud. La chaîne reconnue est utilisée dans la plupart des cas, mais pour InkWord, la chaîne reconnue de la ligne est utilisée et le mot est sélectionné dans le TextBox.
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 = "";
}
Plateformes
Windows Vista
Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Informations de version
.NET Framework
Pris en charge dans : 3.0
Voir aussi
Référence
System.Windows.Ink, espace de noms
System.Windows.Ink.ContextNodeType
InkAnalyzerFindNodesOfType(Guid, array<Int32[])