ContextNode.SetStrokes 方法
在 ContextNode 物件上設定指定的筆劃。
命名空間: System.Windows.Ink
組件: IAWinFX (在 IAWinFX.dll 中)
語法
'宣告
Public Sub SetStrokes ( _
strokes As StrokeCollection _
)
'用途
Dim instance As ContextNode
Dim strokes As StrokeCollection
instance.SetStrokes(strokes)
public void SetStrokes(
StrokeCollection strokes
)
public:
void SetStrokes(
StrokeCollection^ strokes
)
public void SetStrokes(
StrokeCollection strokes
)
public function SetStrokes(
strokes : StrokeCollection
)
參數
- strokes
型別:System.Windows.Ink.StrokeCollection
ContextNode 物件取得的 StrokeCollection。
備註
這個方法不會更新 DirtyRegion。
如果筆劃集合中任何指定的筆劃已設定於 InkAnalyzer,則會擲回 ArgumentException。
範例
下列範例是名為 PopulateNode 的方法,它會使用 TreeView 做為文件模型,以顯示如何使用資料 Proxy 儲存和載入 InkAnalyzer 的內容節點樹狀目錄。DocumentNodeData 類別會在每個 TreeViewItem 物件的 Tag 屬性都設定為 DocumentNodeData 物件時,將 ContextNode 資料儲存在文件模型中。
PopulateNode 方法會透過從 InkAnalyzer 物件加入筆劃、屬性資料、註釋型別、子節點和連結,完整地填入 ContextNode 物件。方法會使用 SetStrokes 加入筆劃。資料來自 DocumentNodeData 物件,而該物件是從對應的 TreeViewItem 取得。
this[analyzerNode.Id] 是文件模型類別上的索引子 (Indexer),會將 Guid 對應至 TreeViewItem (在 VB.NET 中為 Me(analyzerNode.Id))。
AddLinksToAnalyer 是文件模型類別上的方法,會將連結加入至 ContextNode。
完整填入節點之後,PartiallyPopulated 屬性會設定為 false。如需資料 Proxy 的詳細資訊,請參閱Data Proxy with Ink Analysis。
Sub PopulateNode(ByVal analyzerNode As ContextNode, ByVal theInkAnalyzer As InkAnalyzer) Implements IDocumentModel.PopulateNode
System.Diagnostics.Debug.WriteLine(String.Format("IDocumentModel.PopulateNode: populate {0} {1}.", analyzerNode.ToString(), GetRecognizedString(analyzerNode)))
System.Diagnostics.Debug.Indent()
' Get the document node associated with the analyzer node.
Dim documentNode As TreeViewItem = Me(analyzerNode.Id)
If documentNode Is Nothing Then
Throw New ApplicationException("The requested node does not exist in the document model.")
End If
' Get the data associated with the node.
Dim nodeData As DocumentNodeData = documentNode.Tag '
' Copy any application specific data associated with the node to the
' partially populated ContextNode.
For Each identifier As Guid In nodeData.GetPropertyDataIds()
analyzerNode.AddPropertyData(identifier, nodeData.GetPropertyData(identifier))
Next identifier
' Check if the partially populated ContextNode is an ink leaf node.
If nodeData.IsInkLeafNode Then
' Add the strokes to the context node.
analyzerNode.SetStrokes(nodeData.Strokes)
Else
' Add each child subnode as a partially populated ContextNode.
Dim documentSubNode As TreeViewItem
For Each documentSubNode In documentNode.Items
' Get the DocumentNode data for the
Dim subNodeData As DocumentNodeData = documentSubNode.Tag '
If analyzerNode.SubNodes.IndexOf(nodeData.Id) <> -1 Then
analyzerNode.CreatePartiallyPopulatedSubNode( _
subNodeData.Type, subNodeData.Id, subNodeData.Location)
End If
Next documentSubNode
End If
' Add links to the ContextNode.
Me.AddLinksToAnalyzer(documentNode, analyzerNode, theInkAnalyzer)
' Update the partially populated flag.
analyzerNode.PartiallyPopulated = False
System.Diagnostics.Debug.Unindent()
End Sub 'IDocumentModel.PopulateNode
void IDocumentModel.PopulateNode(
ContextNode analyzerNode,
InkAnalyzer theInkAnalyzer)
{
System.Diagnostics.Debug.WriteLine(string.Format(
"IDocumentModel.PopulateNode: populate {0} {1}.",
analyzerNode.ToString(), GetRecognizedString(analyzerNode)));
System.Diagnostics.Debug.Indent();
// Get the document node associated with the analyzer node.
TreeViewItem documentNode = this[analyzerNode.Id];
if (null == documentNode)
{
throw new ApplicationException(
"The requested node does not exist in the document model.");
}
// Get the data associated with the node.
DocumentNodeData nodeData = documentNode.Tag as DocumentNodeData;
// Copy any application specific data associated with the node to the
// partially populated ContextNode.
foreach (Guid identifier in nodeData.GetPropertyDataIds())
{
analyzerNode.AddPropertyData(
identifier, nodeData.GetPropertyData(identifier));
}
// Check if the partially populated ContextNode is an ink leaf node.
if (nodeData.IsInkLeafNode)
{
// Add the strokes to the context node.
analyzerNode.SetStrokes(nodeData.Strokes);
}
else
{
// Add each child subnode as a partially populated ContextNode.
foreach (TreeViewItem documentSubNode in documentNode.Items)
{
// Get the DocumentNode data for the
DocumentNodeData subNodeData = documentSubNode.Tag as DocumentNodeData;
if (analyzerNode.SubNodes.IndexOf(nodeData.Id) != -1)
{
analyzerNode.CreatePartiallyPopulatedSubNode(
subNodeData.Type, subNodeData.Id, subNodeData.Location);
}
}
}
// Add links to the ContextNode.
this.AddLinksToAnalyzer(documentNode, analyzerNode, theInkAnalyzer);
// Update the partially populated flag.
analyzerNode.PartiallyPopulated = false;
System.Diagnostics.Debug.Unindent();
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0