ContextNodeBase.CreateSubNode 方法
建立新的子 ContextNodeBase 物件。
命名空間: System.Windows.Ink.AnalysisCore
組件: IACore (在 IACore.dll 中)
語法
'宣告
Public Function CreateSubNode ( _
type As Guid _
) As ContextNodeBase
'用途
Dim instance As ContextNodeBase
Dim type As Guid
Dim returnValue As ContextNodeBase
returnValue = instance.CreateSubNode(type)
public ContextNodeBase CreateSubNode(
Guid type
)
public:
ContextNodeBase^ CreateSubNode(
Guid type
)
public ContextNodeBase CreateSubNode(
Guid type
)
public function CreateSubNode(
type : Guid
) : ContextNodeBase
參數
- type
型別:System.Guid
要建立的內容節點類型。使用 ContextNodeTypeBase 類別中定義的其中一個 GUID,即可指定要建立的型別。
傳回值
型別:System.Windows.Ink.AnalysisCore.ContextNodeBase
新建立的 ContextNodeBase 物件,其父代 (Parent) 是這個 ContextNodeBase。
備註
當現有的子節點已經存在時,會加入新建立的 ContextNodeBase 做為 SubNodes 集合中的最後一個子節點。
範例
這個範例會取得所有行,並且將它們放入本身所屬的段落中。範例中會使用來自 InkAnalyzerBasetheInkAnalyzerBase; 的行,為每一行建立新的段落子節點,並且將這些行的父代重設為這些新段落。
' Take each line and make it its own paragraph
Dim originalParagraphs As ContextNodeBaseCollection = _
theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph)
Dim lines As ContextNodeBaseCollection = _
theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line)
Dim lineNode As ContextNodeBase
For Each lineNode In lines
' Create a new alignment level and paragraph
Dim lineParagraph As ContextNodeBase = lineNode.ParentNode
Dim writingRegion As ContextNodeBase = lineParagraph.ParentNode
Dim newParagraph As ContextNodeBase = _
writingRegion.CreateSubNode(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph)
' Reparent the line
lineNode.Reparent(newParagraph)
Next lineNode
' Remove original paragraphs and alignment nodes
Dim originalParagraph As ContextNodeBase
For Each originalParagraph In originalParagraphs
Dim originalAlignmentLevel As ContextNodeBase = originalParagraph.ParentNode
originalAlignmentLevel.DeleteSubNode(originalParagraph)
originalAlignmentLevel.ParentNode.DeleteSubNode(originalAlignmentLevel)
Next originalParagraph
// Take each line and make it its own paragraph
ContextNodeBaseCollection originalParagraphs =
theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph);
ContextNodeBaseCollection lines =
theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line);
foreach (ContextNodeBase lineNode in lines)
{
// Create a new paragraph
ContextNodeBase paragraph = lineNode.ParentNode;
ContextNodeBase writingRegion = paragraph.ParentNode;
ContextNodeBase newParagraph =
writingRegion.CreateSubNode(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph);
// Reparent the line
lineNode.Reparent(newParagraph);
}
// Remove original paragraphs
foreach (ContextNodeBase originalParagraph in originalParagraphs)
{
ContextNodeBase originalWritingRegion = originalParagraph.ParentNode;
originalWritingRegion.DeleteSubNode(originalParagraph);
}
平台
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0