ContextNode.PartiallyPopulated 属性

获取或设置一个值,该值指示 ContextNode 对象是部分填充还是完全填充。

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public Property PartiallyPopulated As Boolean
用法
Dim instance As ContextNode
Dim value As Boolean

value = instance.PartiallyPopulated

instance.PartiallyPopulated = value
public bool PartiallyPopulated { get; set; }
public:
property bool PartiallyPopulated {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_PartiallyPopulated()
/** @property */
public  void set_PartiallyPopulated(boolean value)
public function get PartiallyPopulated () : boolean
public function set PartiallyPopulated (value : boolean)

属性值

类型:System.Boolean
如果 ContextNode 在数据代理过程中包含部分数据,则为 true;如果已添加所有数据,则为 false。

备注

如果在上下文节点树中创建 ContextNode 对象时关于该对象的所有信息还不可用,则可将此属性用于数据代理。此属性指示是否已经发生完全数据填充。

示例

下面的示例是一段示例代码中一个名为 PopulateNode 的方法,该方法使用 [System.Windows.Controls.TreeView] 作为一个文档模型来演示如何使用数据代理存储和加载 InkAnalyzer 的上下文节点树。当每个 TreeViewItem 对象的 [System.Windows.FrameworkElement.Tag] 属性都设置为 DocumentNodeData 对象时,DocumentNodeData 类将 ContextNode 数据存储在该文档模型中。

PopulateNode 方法使用 ContextNode 对象和 InkAnalyzer 对象,通过添加笔画、属性数据、批注类型、子节点和链接来完全填充上下文节点。数据来自从对应的 TreeViewItem 获取的 DocumentNodeData 对象。

  • this[analyzerNode.Id] 是文档模型类上的一个索引器,该索引器将 Guid 映射到 TreeViewItem

  • AddLinksToAnalyer 是文档模型类的方法,用于将链接添加到 ContextNode

在节点完全填充之后,PartiallyPopulated 属性将设置为 false。

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

另请参见

参考

ContextNode 类

ContextNode 成员

System.Windows.Ink 命名空间