Поделиться через


ContextNode.Confirm - метод

Обновлен: Ноябрь 2007

Sets the confirmation type, thereby restricting what the InkAnalyzer can change about the node.

Пространство имен:  System.Windows.Ink
Сборка:  IAWinFX (в IAWinFX.dll)

Синтаксис

'Декларация
Public Sub Confirm ( _
    type As ConfirmationType _
)
'Применение
Dim instance As ContextNode
Dim type As ConfirmationType

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

Параметры

Заметки

After Confirm has been called, the InkAnalyzer will not change the ContextNode objects associated with those strokes when the InkAnalyzer performs subsequent analysis.

For example, if the end user writes the word "to" and then your application calls Analyze, the InkAnalyzer 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 InkAnalyzer will 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 with the "to" value NodeTypeAndProperties, adding "me" does not change the node. The InkAnalyzer would recognize two InkWord nodes for "to me".

You can confirm only ContextNode 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 InkAnalyzerRemoveStroke(Int32), and the stroke being removed is related to a confirmed ContextNode object, the ContextNode object is automatically set to unconfirmed..

SetStrokes(array<Int32[]) and ReparentStroke(Int32, ContextNode) throws an InvalidOperationException if the ContextNode object is already confirmed. ReparentStroke(Int32, ContextNode) throws the exception if either source or destination node is confirmed.

Примеры

The following example allows the user to indicate which strokes have been analyzed correctly. This example is an event handler for a PreviewMouseUp event on an InkCanvas, theInkCanvas. When the CheckBox, confirmMode, is checked, the user clicks a word to confirm it (or to turn off confirmation if the node is already confirmed). The example uses StrokeCollection.HitTest(Point) and FindNodesOfType to find the appropriate nodes. After the nodes are found, Confirm is called to toggle the confirmation. Finally, the TreeView is rebuilt to show which nodes have been confirmed and the PreviewMouseUp event is handled.

Sub theInkCanvas_PreviewMouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)

    If Me.confirmMode.IsChecked Then

        ' Find the ink word nodes that correspond to those strokes
        Dim position As Point = e.GetPosition(theInkCanvas)
        Dim hitStrokes As StrokeCollection = theInkCanvas.Strokes.HitTest(position)

        Dim selectedNodes As ContextNodeCollection = _
            Me.theInkAnalyzer.FindNodesOfType(ContextNodeType.InkWord, _
            hitStrokes)

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

        ' Rebuild the TreeView to show which context nodes are confirmed.
        Me.BuildTree()

        ' Handle the MouseDown event to prevent the InkCanvas from
        ' selecting the stroke.
        e.Handled = True
    End If

End Sub 'theInkCanvas_PreviewMouseDown
void theInkCanvas_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    if ((bool)this.confirmMode.IsChecked)
    {
        // Find the ink word nodes that correspond to those strokes
        Point position = e.GetPosition(theInkCanvas);
        StrokeCollection hitStrokes = theInkCanvas.Strokes.HitTest(position);

        ContextNodeCollection selectedNodes =
            this.theInkAnalyzer.FindNodesOfType(ContextNodeType.InkWord,
            hitStrokes);

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

        // Rebuild the TreeView to show which context nodes are confirmed.
        this.BuildTree();

        // Handle the MouseDown event to prevent the InkCanvas from
        // selecting the stroke.
        e.Handled = true;
    }
}

Платформы

Windows Vista

Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.

Сведения о версии

.NET Framework

Поддерживается в версии: 3.0

См. также

Ссылки

ContextNode Класс

ContextNode - члены

System.Windows.Ink - пространство имен

ContextNodeIsNodeTypeAndPropertiesConfirmed()