다음을 통해 공유


AnalysisAlternate.AlternateNodes Property

Gets the ContextNode objects that are associated with the current AnalysisAlternate.

Namespace: System.Windows.Ink
Assembly: IAWinFX (in iawinfx.dll)
XML Namespace:  https://schemas.microsoft.com/winfx/2006/xaml/presentation

Syntax

'Declaration
Public ReadOnly Property AlternateNodes As ContextNodeCollection
'Usage
Dim instance As AnalysisAlternate
Dim value As ContextNodeCollection

value = instance.AlternateNodes
public ContextNodeCollection AlternateNodes { get; }
public:
property ContextNodeCollection^ AlternateNodes {
    ContextNodeCollection^ get ();
}
/** @property */
public ContextNodeCollection get_AlternateNodes ()
public function get AlternateNodes () : ContextNodeCollection
Not applicable.

Property Value

The ContextNode objects that are associated with this alternate.

Remarks

Because they correspond to alternates, these ContextNode objects are not descendants of the RootNode of the InkAnalyzer unless they are the top alternate, which is the first element in an AnalysisAlternateCollection.

AlternateNodes always return a collection of leaf nodes. For example, if the AnalysisAlternate is for a LineNode, AlternateNodes returns a collection of InkWordNode objects, not LineNode objects.

Example

This example checks to see if an AnalysisAlternate, selectedAlternate, has the same segmentation as the top alternate in an AnalysisAlternateCollection, currentAlternates. Segmentation refers to how the strokes are broken up into ContextNode objects.

Dim hasSameSegmentationAsTop As Boolean = True
If currentAlternates.Count > 0 Then
    Dim topAlternate As AnalysisAlternate = currentAlternates(0)
    ' First check if selected alternate is the top alternate
    If selectedAlternate = topAlternate Then
        hasSameSegmentationAsTop = True
    Else
        ' Check to see if they have the same strokes
        If topAlternate.AlternateNodes.Count <> selectedAlternate.AlternateNodes.Count Then
            hasSameSegmentationAsTop = False
        Else
            ' Check that each node matches the alternates
            Dim i As Integer
            For i = 0 To topAlternate.AlternateNodes.Count - 1
                If topAlternate.AlternateNodes(i).Strokes.Count <> _
                   selectedAlternate.AlternateNodes(i).Strokes.Count Then

                    hasSameSegmentationAsTop = False
                    Exit For
                End If

                Dim stroke As Stroke
                For Each stroke In topAlternate.AlternateNodes(i).Strokes
                    If Not selectedAlternate.AlternateNodes(i).Strokes.Contains(stroke) Then
                        hasSameSegmentationAsTop = False
                        Exit For
                    End If
                Next stroke
            Next i
        End If
    End If
End If
bool hasSameSegmentationAsTop = true;
if (currentAlternates.Count > 0)
{
    AnalysisAlternate topAlternate = currentAlternates[0];
    // First check if selected alternate is the top alternate
    if (selectedAlternate == topAlternate)
    {
        hasSameSegmentationAsTop = true;
    }
    else
    {
        // Check to see if they have the same strokes
        if (topAlternate.AlternateNodes.Count != selectedAlternate.AlternateNodes.Count)
        {
            hasSameSegmentationAsTop = false;
        }
        else
        {
            // Check that each node matches the alternates
            for (int i = 0;
                (i < topAlternate.AlternateNodes.Count) && hasSameSegmentationAsTop; i++)
            {
                if (topAlternate.AlternateNodes[i].Strokes.Count !=
                      selectedAlternate.AlternateNodes[i].Strokes.Count)
                {
                    hasSameSegmentationAsTop = false;
                    break;
                }

                foreach (Stroke stroke in topAlternate.AlternateNodes[i].Strokes)
                {
                    if (!selectedAlternate.AlternateNodes[i].Strokes.Contains(stroke))
                    {
                        hasSameSegmentationAsTop = false;
                        break;
                    }
                }
            }
        }
    }
}

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

AnalysisAlternate Class
AnalysisAlternate Members
System.Windows.Ink Namespace