Share via


ContextNodeBase.Confirm Method

Sets the confirmation type, which restricts what the InkAnalyzerBase can change about the node.

Namespace:  System.Windows.Ink.AnalysisCore
Assembly:  IACore (in IACore.dll)

Syntax

'Declaration
Public Sub Confirm ( _
    type As ConfirmationType _
)
'Usage
Dim instance As ContextNodeBase 
Dim type As ConfirmationType

instance.Confirm(type)
public void Confirm(
    ConfirmationType type
)
public:
void Confirm(
    ConfirmationType type
)
public function Confirm(
    type : ConfirmationType
)

Parameters

Remarks

Use Confirm to enable the end user to confirm that the InkAnalyzerBase has correctly analyzed the strokes. After Confirm has been called, the InkAnalyzerBase will not change the ContextNodeBase objects for those strokes during later analysis.

For example, if the end user writes the word "to" and then your application calls Analyze, the InkAnalyzerBase will create an InkWord node with the value of "to". If the end user then adds "me" after "to" as one word and the application makes another call to Analyze, the InkAnalyzerBase would likely create one InkWord node with the value "tome". However, if after the first call to Analyze, the application calls Confirm on the InkWord node for "to" with the value NodeTypeAndProperties, a different behavior occurs. When the end user adds the "me" and the application makes another call to Analyze, the "to" node is not changed. The InkAnalyzerBase would recognize two InkWord nodes for "to me".

You can confirm only ContextNodeBase objects of type InkWord and InkDrawing. If you attempt to call Confirm on a node that is not a leaf node, an InvalidOperationException is thrown.

If you call InkAnalyzerBase.RemoveStroke, the ContextNodeBase object is automatically set to unconfirmed if the stroke being removed is related to a confirmed ContextNodeBase object.

SetStrokes, SetStrokeType, and SetStrokesType throws an InvalidOperationException if the ContextNodeBase object is already confirmed. ReparentStrokes throws the exception if either source or destination node is confirmed.

Examples

The following example is an event handler for the MouseUp event on a Panel, theNotesPanel, which is collecting ink through an InkCollector named theInkCollector. The application has a Boolean value named confirmMode, which is set by a MenuItem named confirmMenuItem. When in "confirm" mode, the user clicks on a word to confirm it (or to turn off confirmation if the node is already confirmed). The example converts the mouse up event into ink coordinates, using HitTest and FindNodesOfType to find the appropriate nodes. After the nodes are found, Confirm is called to toggle the confirmation. Finally, the application is taken out of "confirm" mode.

Private Sub theNotesPanel_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles theNotesPanel.MouseUp
    If Me.confirmMode = True Then 
        ' Translate coordinates into ink dimensions 
        Dim hitPoint As New Point(e.X, e.Y)
        Dim panelGraphics As Graphics = Me.theNotesPanel.CreateGraphics()
        Me.theInkCollector.Renderer.PixelToInkSpace(panelGraphics, hitPoint)
        panelGraphics.Dispose()

        ' Find the strokes that the user selected 
        Dim selectedStrokes As Strokes = Me.theInkCollector.Ink.HitTest(hitPoint, 10)

        ' The integer array must be exactly the right size. Arrays 
        ' begin at zero, so the upper bound is selectedStrokes.Count - 1. 
        Dim selectedStrokeIds(selectedStrokes.Count - 1) As Integer 

        For i As Integer = 0 To selectedStrokes.Count - 1
            selectedStrokeIds(i) = selectedStrokes(i).Id
        Next 

        ' Find the ink word nodes that correspond to those strokes 
        Dim selectedNodes As ContextNodeBaseCollection = _
            Me.theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord, _
            selectedStrokeIds)

        ' Toggle the confirmation type on these nodes 
        Dim selectedNode As ContextNodeBase
        For Each selectedNode In selectedNodes
            If selectedNode.IsConfirmed( _
               Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties) Then
                selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.None)
            Else
                selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties)
            End If 
        Next selectedNode

        ' No longer in "confirm" mode 
        Me.confirmMode = False 
        Me.ConfirmMenuItem.Checked = False 
        Me.theInkCollector.Enabled = True 
    End If 

End Sub
private void theNotesPanel_MouseUp(object sender, MouseEventArgs e)
{
    if (this.confirmMode)
    {
        // Translate coordinates into ink dimensions
        Point hitPoint = new Point(e.X, e.Y);
        Graphics panelGraphics = this.theNotesPanel.CreateGraphics();
        this.theInkCollector.Renderer.PixelToInkSpace(panelGraphics, ref hitPoint);
        panelGraphics.Dispose();

        // Find the strokes that the user selected
        Strokes selectedStrokes = this.theInkCollector.Ink.HitTest(hitPoint, 10);

        int[] selectedStrokeIds = new int[selectedStrokes.Count];

        for (int i = 0; i < selectedStrokes.Count; i++)
        {
            selectedStrokeIds[i] = selectedStrokes[i].Id;
        }

        // Find the ink word nodes that correspond to those strokes
        ContextNodeBaseCollection selectedNodes =
            this.theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord,
            selectedStrokeIds);

        // Toggle the confirmation type on these nodes 
        foreach (ContextNodeBase selectedNode in selectedNodes)
        {
            if (selectedNode.IsConfirmed(
                System.Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties))
            {
                selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.None);
            }
            else
            {
                selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties);
            }
        }

        // No longer in "confirm" mode
        this.confirmMode = false;
        this.confirmMenuItem.Checked = false;
            this.theInkCollector.Enabled = true;
    }

}

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

ContextNodeBase Class

ContextNodeBase Members

System.Windows.Ink.AnalysisCore Namespace