Share via


InkAnalyzer.ContextNodeCreated Event

Occurs after the InkAnalyzer creates a ContextNode.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

Syntax

'Declaration
Public Event ContextNodeCreated As ContextNodeCreatedEventHandler
'Usage
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);
}
JScript does not support events.

Remarks

Use this event when your application maintains its own data structure, which is synchronized with that of the InkAnalyzer. This event occurs during the reconcile phase of ink analysis, or in response to an InkAnalyzer method that creates a ContextNode.

When the InkAnalyzer creates a ContextNode, the new ContextNode does not contain any strokes, does not contain links to other ContextNode objects, and may not have all of its properties set. Also, the new ContextNode is added to the end of its parent's SubNodes collection. After this event, the InkAnalyzer may raise the following events.

For more information about synchronizing your application data with the InkAnalyzer, see Data Proxy with Ink Analysis.

Examples

This example defines a method, AttachDataProxyEventHandlers, that attaches data proxy event handlers to an 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);
        }

The following example defines a method, AddContextNode, that handles the ContextNodeCreated event. The event information is passed to the document model object, theDocumentModel.

This example does not provide the definition of the document model or demonstrate how it processes the information passed to it.

'/ <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);
            }
        }

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkAnalyzer Class

InkAnalyzer Members

Microsoft.Ink Namespace

InkAnalyzer.ContextNodeDeleting

InkAnalyzer.ContextNodeLinkAdding

InkAnalyzer.ContextNodeMovingToPosition

InkAnalyzer.ContextNodePropertiesUpdated

InkAnalyzer.StrokesReparented

Microsoft.Ink.ContextNodeCreatedEventArgs