ContextNodeBase.Reparent 方法
從目前的父代移除這個 ContextNodeBase 物件,並且將它加入另一個父代。
命名空間: System.Windows.Ink.AnalysisCore
組件: IACore (在 IACore.dll 中)
語法
'宣告
Public Sub Reparent ( _
newParentNode As ContextNodeBase _
)
'用途
Dim instance As ContextNodeBase
Dim newParentNode As ContextNodeBase
instance.Reparent(newParentNode)
public void Reparent(
ContextNodeBase newParentNode
)
public:
void Reparent(
ContextNodeBase^ newParentNode
)
public void Reparent(
ContextNodeBase newParentNode
)
public function Reparent(
newParentNode : ContextNodeBase
)
參數
- newParentNode
型別:System.Windows.Ink.AnalysisCore.ContextNodeBase
這個 ContextNodeBase 物件的新父代。
範例
這個範例會取得 TypeLine 的所有 ContextNodeBase 物件,並將它們放入本身所屬的 ContextNodeBase 物件中,這些物件為 Paragraph 型別。範例中會使用來自 InkAnalyzerBase (名為 theInkAnalyzerBase;) 的行,為每一行建立新的段落子節點、將這些行的父代重設為這些新段落,並且刪除原始段落。
' 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