ContextNode.ToString 方法
以字串的形式傳回 ContextNode 物件的型別,這個型別是人們可讀取的 (Human-Readable) 型別。
命名空間: Microsoft.Ink
組件: Microsoft.Ink.Analysis (在 Microsoft.Ink.Analysis.dll 中)
語法
'宣告
Public Overrides Function ToString As String
'用途
Dim instance As ContextNode
Dim returnValue As String
returnValue = instance.ToString()
public override string ToString()
public:
virtual String^ ToString() override
public String ToString()
public override function ToString() : String
傳回值
型別:System.String
ContextNode 物件的型別,這個型別是人們可讀取的字串形式。
備註
例如,如果 Type 為 InkWord,則這個方法傳回的值會是 "InkWordNode"。
範例
這個範例是一個方法,會遞迴地周遊 ContextNode 物件的樹狀目錄。它會使用 SubNodes 屬性,並且透過加入 TreeNode (英文) 物件填入 System.Windows.Forms.TreeView (英文),然後將物件的 TreeNode.Text (英文) 屬性設定為 ToString,並加入 InkWordNode.GetRecognizedString 或 InkDrawingNode.GetShapeName (如果適用)。
Private Sub WalkTree(ByVal parentContextNode As Microsoft.Ink.ContextNode, _
ByVal parentTreeNode As TreeNode)
Dim cNode As ContextNode
For Each cNode In parentContextNode.SubNodes
Dim newTNode As New TreeNode(cNode.ToString())
If TypeOf cNode Is Microsoft.Ink.InkWordNode Then
newTNode.Text = newTNode.Text + _
": " + CType(cNode, InkWordNode).GetRecognizedString()
ElseIf TypeOf cNode Is Microsoft.Ink.InkDrawingNode Then
Dim shapeName As String = CType(cNode, InkDrawingNode).GetShapeName()
If shapeName <> "" Then
newTNode.Text = newTNode.Text + ": " + shapeName
End If
End If
WalkTree(cNode, newTNode)
parentTreeNode.Nodes.Add(newTNode)
' Add the context node as a tag of the tree node
newTNode.Tag = cNode
Next cNode
End Sub 'WalkTree
private void WalkTree(ContextNode parentContextNode, TreeNode parentTreeNode)
{
foreach (ContextNode cNode in parentContextNode.SubNodes)
{
TreeNode newTNode = new TreeNode(cNode.ToString());
if (cNode is Microsoft.Ink.InkWordNode)
{
newTNode.Text +=
": " + ((InkWordNode)cNode).GetRecognizedString();
}
else if (cNode is Microsoft.Ink.InkDrawingNode)
{
String shapeName = ((InkDrawingNode)cNode).GetShapeName();
if (shapeName != "")
newTNode.Text += ": " + shapeName;
}
WalkTree(cNode, newTNode);
parentTreeNode.Nodes.Add(newTNode);
// Add the context node as a tag of the tree node
newTNode.Tag = cNode;
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0