InkAnalyzer.ContextNodeCreated 事件

InkAnalyzer 创建 ContextNode 之后发生。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)

语法

声明
Public Event ContextNodeCreated As ContextNodeCreatedEventHandler
用法
Dim instance As InkAnalyzer
Dim handler As ContextNodeCreatedEventHandler

AddHandler instance.ContextNodeCreated, handler
public event ContextNodeCreatedEventHandler ContextNodeCreated
public:
 event ContextNodeCreatedEventHandler^ ContextNodeCreated {
    void add (ContextNodeCreatedEventHandler^ value);
    void remove (ContextNodeCreatedEventHandler^ value);
}
/** @event */
public void add_ContextNodeCreated (ContextNodeCreatedEventHandler value)
/** @event */
public void remove_ContextNodeCreated (ContextNodeCreatedEventHandler value)
JScript 不支持事件。

备注

如果您的应用程序维护其自己的数据结构(该数据结构与 InkAnalyzer 的数据结构同步),请使用此事件。此事件在墨迹分析的协调阶段中发生,或者在响应创建 ContextNodeInkAnalyzer 方法时发生。

InkAnalyzer 创建 ContextNode 时,新创建的 ContextNode 不包含任何笔画,不包含任何指向其他 ContextNode 对象的链接,而且不能设置它的所有属性。而且,新的 ContextNode 会添加到其父级的 SubNodes 集合的末尾。在此事件之后,InkAnalyzer 可引发以下事件。

有关将应用程序数据与 InkAnalyzer 同步的更多信息,请参见Data Proxy with Ink Analysis

示例

此示例定义 AttachDataProxyEventHandlers 方法,该方法将数据代理事件处理程序附加到一个 InkAnalyzer (theInkAnalyzer)。

Private Sub AttachDataProxyEventHandlers() 
    ' If the document model supports on demand data proxy, then add an
    ' event handler for the PopulateContextNode event. This event is raised
    ' when the InkAnalyzer accesses a partially populated ContextNode created
    ' by the document model.
    If Me.theDocumentModel.SupportsOnDemandDataProxy Then
        AddHandler Me.theInkAnalyzer.PopulateContextNode, AddressOf Me.PopulateContextNode
    End If

    ' Add the other data proxy related event handlers. These events are raised
    ' by the InkAnalyzer to communicate ink analysis results to the document model.
    AddHandler Me.theInkAnalyzer.ContextNodeCreated, AddressOf Me.AddContextNode
    AddHandler Me.theInkAnalyzer.ContextNodeDeleting, AddressOf Me.RemoveContextNode
    AddHandler Me.theInkAnalyzer.ContextNodeLinkAdding, AddressOf Me.AddContextNodeLink
    AddHandler Me.theInkAnalyzer.ContextNodeLinkDeleting, AddressOf Me.RemoveContextNodeLink
    AddHandler Me.theInkAnalyzer.ContextNodeMovingToPosition, AddressOf Me.MoveContextNodeToPosition
    AddHandler Me.theInkAnalyzer.ContextNodePropertiesUpdated, AddressOf Me.UpdateContextNodeProperties
    AddHandler Me.theInkAnalyzer.ContextNodeReparenting, AddressOf Me.ReparentContextNode
    AddHandler Me.theInkAnalyzer.InkAnalyzerStateChanging, AddressOf Me.InkAnalyzer_StateChanging
    AddHandler Me.theInkAnalyzer.StrokesReparented, AddressOf Me.ReparentStroke
    AddHandler Me.theInkAnalyzer.IntermediateResultsUpdated, AddressOf Me.ResultsAvailable
    AddHandler Me.theInkAnalyzer.ResultsUpdated, AddressOf Me.ResultsAvailable

End Sub 'AttachDataProxyEventHandlers
        private void AttachDataProxyEventHandlers()
        {
            // If the document model supports on demand data proxy, then add an
            // event handler for the PopulateContextNode event. This event is raised
            // when the InkAnalyzer accesses a partially populated ContextNode created
            // by the document model.
            if (this.theDocumentModel.SupportsOnDemandDataProxy)
            {
                this.theInkAnalyzer.PopulateContextNode +=
                    new Microsoft.Ink.PopulateContextNodeEventHandler(
                        this.PopulateContextNode);
            }

            // Add the other data proxy related event handlers. These events are raised
            // by the InkAnalyzer to communicate ink analysis results to the document model.
            this.theInkAnalyzer.ContextNodeCreated +=
                new Microsoft.Ink.ContextNodeCreatedEventHandler(
                    this.AddContextNode);
            this.theInkAnalyzer.ContextNodeDeleting +=
                new Microsoft.Ink.ContextNodeDeletingEventHandler(
                    this.RemoveContextNode);
            this.theInkAnalyzer.ContextNodeLinkAdding +=
                new Microsoft.Ink.ContextNodeLinkAddingEventHandler(
                    this.AddContextNodeLink);
            this.theInkAnalyzer.ContextNodeLinkDeleting +=
                new Microsoft.Ink.ContextNodeLinkDeletingEventHandler(
                    this.RemoveContextNodeLink);
            this.theInkAnalyzer.ContextNodeMovingToPosition +=
                new Microsoft.Ink.ContextNodeMovingToPositionEventHandler(
                    this.MoveContextNodeToPosition);
            this.theInkAnalyzer.ContextNodePropertiesUpdated +=
                new Microsoft.Ink.ContextNodePropertiesUpdatedEventHandler(
                    this.UpdateContextNodeProperties);
            this.theInkAnalyzer.ContextNodeReparenting +=
                new Microsoft.Ink.ContextNodeReparentingEventHandler(
                    this.ReparentContextNode);
            this.theInkAnalyzer.InkAnalyzerStateChanging +=
                new Microsoft.Ink.InkAnalyzerStateChangingEventHandler(
                    this.InkAnalyzer_StateChanging);
            this.theInkAnalyzer.StrokesReparented +=
                new Microsoft.Ink.StrokesReparentedEventHandler(
                    this.ReparentStrokes);
            this.theInkAnalyzer.IntermediateResultsUpdated +=
                new Microsoft.Ink.ResultsUpdatedEventHandler(
                    this.ResultsAvailable);
            this.theInkAnalyzer.ResultsUpdated +=
                new Microsoft.Ink.ResultsUpdatedEventHandler(
                    this.ResultsAvailable);
        }

下面的示例定义 AddContextNode 方法,用以处理 ContextNodeCreated 事件。事件信息将传递给文档模型对象 theDocumentModel。

此示例不提供文档模型的定义,也不演示文档模型如何处理传入的信息。

'/ <summary>
'/ Handles the InkAnalyzer.ContextNodeCreated event.
'/ </summary>
'/ <param name="sender">The source of the event.</param>
'/ <param name="e">The event data.</param>
'/ <remarks>
'/ Note: when this event is fired, the ContextNode has not been populated
'/ with extended and other properties. Handle the ContextNodePropertiesUpdated
'/ event to populate the corresponding ContextNode in the document model.
'/ </remarks>
Private Sub AddContextNode( _
    ByVal sender As Object, _
    ByVal e As Microsoft.Ink.ContextNodeCreatedEventArgs)

    ' Do not add unclassified ink nodes to the document model.
    If Microsoft.Ink.ContextNodeType.UnclassifiedInk _
        <> e.NodeCreated.Type Then

        Me.theDocumentModel.AddNode(e.NodeCreated)
    End If

End Sub 'AddContextNode

        /// <summary>
        /// Handles the InkAnalyzer.ContextNodeCreated event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The event data.</param>
        /// <remarks>
        /// Note: when this event is fired, the ContextNode has not been populated
        /// with extended and other properties. Handle the ContextNodePropertiesUpdated
        /// event to populate the corresponding ContextNode in the document model.
        /// </remarks>
        private void AddContextNode(
            object sender, Microsoft.Ink.ContextNodeCreatedEventArgs e)
        {
            // Do not add unclassified ink nodes to the document model.
            if (Microsoft.Ink.ContextNodeType.UnclassifiedInk
                != e.NodeCreated.Type)
            {
                this.theDocumentModel.AddNode(e.NodeCreated);
            }
        }

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

InkAnalyzer 类

InkAnalyzer 成员

Microsoft.Ink 命名空间

InkAnalyzer.ContextNodeDeleting

InkAnalyzer.ContextNodeLinkAdding

InkAnalyzer.ContextNodeMovingToPosition

InkAnalyzer.ContextNodePropertiesUpdated

InkAnalyzer.StrokesReparented

Microsoft.Ink.ContextNodeCreatedEventArgs