Share via


Metodo InkAnalyzerBase.AddStrokesToCustomRecognizer

Aggiornamento: novembre 2007

Aggiunge i dati relativi a più tratti a un nodo di riconoscimento personalizzato.

Spazio dei nomi:  System.Windows.Ink.AnalysisCore
Assembly:  IACore (in IACore.dll)

Sintassi

'Dichiarazione
Public Function AddStrokesToCustomRecognizer ( _
    strokeIds As Integer(), _
    strokePacketCount As Integer(), _
    strokePacketData As Integer(), _
    strokePacketDescription As Guid(), _
    customRecognizer As ContextNodeBase _
) As ContextNodeBase
'Utilizzo
Dim instance As InkAnalyzerBase
Dim strokeIds As Integer()
Dim strokePacketCount As Integer()
Dim strokePacketData As Integer()
Dim strokePacketDescription As Guid()
Dim customRecognizer As ContextNodeBase
Dim returnValue As ContextNodeBase

returnValue = instance.AddStrokesToCustomRecognizer(strokeIds, _
    strokePacketCount, strokePacketData, _
    strokePacketDescription, customRecognizer)
public ContextNodeBase AddStrokesToCustomRecognizer(
    int[] strokeIds,
    int[] strokePacketCount,
    int[] strokePacketData,
    Guid[] strokePacketDescription,
    ContextNodeBase customRecognizer
)
public:
ContextNodeBase^ AddStrokesToCustomRecognizer(
    array<int>^ strokeIds, 
    array<int>^ strokePacketCount, 
    array<int>^ strokePacketData, 
    array<Guid>^ strokePacketDescription, 
    ContextNodeBase^ customRecognizer
)
public ContextNodeBase AddStrokesToCustomRecognizer(
    int[] strokeIds,
    int[] strokePacketCount,
    int[] strokePacketData,
    Guid[] strokePacketDescription,
    ContextNodeBase customRecognizer
)
public function AddStrokesToCustomRecognizer(
    strokeIds : int[], 
    strokePacketCount : int[], 
    strokePacketData : int[], 
    strokePacketDescription : Guid[], 
    customRecognizer : ContextNodeBase
) : ContextNodeBase

Parametri

  • strokeIds
    Tipo: array<System.Int32[]
    Matrice che contiene gli identificatori di tratto.
  • strokePacketCount
    Tipo: array<System.Int32[]
    Matrice che contiene il numero di pacchetti in ogni tratto.
  • strokePacketData
    Tipo: array<System.Int32[]
    Matrice che contiene i dati del pacchetto per i tratti.
  • strokePacketDescription
    Tipo: array<System.Guid[]
    Matrice che contiene gli identificatori di proprietà del pacchetto.

Valore restituito

Tipo: System.Windows.Ink.AnalysisCore.ContextNodeBase
Nodo di contesto al quale l'analizzatore dell'input penna ha aggiunto i tratti.

Note

L'oggetto InkAnalyzerBase aggiunge i tratti a un oggetto ContextNodeBase con un valore della proprietà Type di UnclassifiedInk().

Durante l'analisi, l'analizzatore dell'input penna assegna l'identificatore delle impostazioni cultura del thread di input attivo al tratto e aggiunge il tratto al primo nodo dell'input penna non classificato nel sistema di riconoscimento dell'input penna. Se non esiste alcun nodo non classificato, ne viene creato uno. Se il sistema di riconoscimento personalizzato non supporta l'identificatore delle impostazioni cultura, l'analizzatore dell'input penna continua l'analisi e genera un avviso AnalysisWarningBase. Questo avviso dispone della proprietà WarningCode impostata sul valore di AnalysisWarningCode pari a LanguageIdNotRespected.

Solo i tratti con le stesse descrizioni del pacchetto possono essere aggiunti in una sola chiamata a AddStrokes.

Questo metodo espande l'oggetto DirtyRegion all'unione del valore corrente dell'area e del riquadro dei tratti aggiunti.

L'oggetto InkAnalyzerBase genera un'eccezione nelle circostanze indicate di seguito.

  • L'oggetto InkAnalyzerBase contiene già un tratto con lo stesso identificatore di uno dei tratti da aggiungere.

  • Il parametro customRecognizer contiene un oggetto ContextNodeBase associato a un oggetto InkAnalyzerBase diverso.

  • Il parametro customRecognizer contiene un oggetto ContextNodeBase che non ha un valore della proprietà Type di CustomRecognizer().

Esempi

In questo esempio viene definito un metodo che converte un insieme Strokes nei dati di pacchetto e aggiunge i tratti a un nodo di riconoscimento personalizzato. Il metodo restituisce l'oggetto ContextNodeBase al quale l'analizzatore dell'input penna ha aggiunto i tratti.

''' <summary>
''' Adds a collection of strokes to a custom recognizer node.
''' </summary>
''' <param name="baseInkAnalyzer">The ink analyzer that contains the
''' custom recognizer node.</param>
''' <param name="theStrokes">The strokes to add.</param>
''' <param name="theCustomRecognizerNode">The custom recognizer node
''' to which to add the strokes.</param>
''' <returns>The node to which the analyzer added the strokes.</returns>
''' <remarks>
''' This method converts stroke data to packet data for example only.
''' The InkAnalyzerBase is used when your application is handling packet
''' data. If your application uses stroke data from an Ink object, then
''' you would use InkAnalyzer.
''' </remarks>
Public Overloads Shared Function MyAddStrokesToCustomRecognizer( _
ByVal baseInkAnalyzer As System.Windows.Ink.AnalysisCore.InkAnalyzerBase, _
ByVal theStrokes As Microsoft.Ink.Strokes, _
ByVal theCustomRecognizerNode As System.Windows.Ink.AnalysisCore.ContextNodeBase) _
As System.Windows.Ink.AnalysisCore.ContextNodeBase

    If Nothing Is baseInkAnalyzer Then
        Throw New ArgumentNullException("baseInkAnalyzer")
    End If

    If Nothing Is theStrokes Then
        Throw New ArgumentNullException("theStrokes")
    End If

    If 0 = theStrokes.Count Then
        Throw New ArgumentException("Empty strokes collection.")
    End If

    If System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.CustomRecognizer <> theCustomRecognizerNode.Type Then
        Throw New ArgumentException("The context node is not a custom recognizer node.", "theCustomRecognizer")
    End If

    If Nothing Is baseInkAnalyzer.FindNode(theCustomRecognizerNode.Id) Then
        Throw New ArgumentException("The custom recognizer node is not attached to the ink analyzer.")
    End If

    ' Only strokes that have the same packet description GUIDs
    ' can be added in one call to InkAnalyzerBase.AddStrokes.
    Dim thePacketDescription As Guid() = theStrokes(0).PacketDescription

    ' Accumulate the stroke data in collections.
    Dim theStrokeIdentifiers As New ArrayList()
    Dim thePacketCounts As New ArrayList()
    Dim thePacketData As New ArrayList()

    Dim aStroke As Microsoft.Ink.Stroke
    For Each aStroke In theStrokes
        If Not InkAnalyzerHelper.AreElementwiseEquivalent(aStroke.PacketDescription, thePacketDescription) Then
            Throw New ApplicationException("The strokes collection contains strokes with different packet descriptions.")
        End If

        ' Add the stroke data to the collections.
        theStrokeIdentifiers.Add(aStroke.Id)
        thePacketCounts.Add(aStroke.PacketCount)
        thePacketData.AddRange(aStroke.GetPacketData())
    Next aStroke

    ' Add the stroke data to the base layer ink analyzer.
    Dim result As System.Windows.Ink.AnalysisCore.ContextNodeBase = _
        baseInkAnalyzer.AddStrokesToCustomRecognizer( _
            DirectCast(theStrokeIdentifiers.ToArray(GetType(Integer)), Integer()), _
            DirectCast(thePacketCounts.ToArray(GetType(Integer)), Integer()), _
            DirectCast(thePacketData.ToArray(GetType(Integer)), Integer()), _
            thePacketDescription, _
            theCustomRecognizerNode)

    Return result

End Function 'AddStrokesToCustomRecognizer
/// <summary>
/// Adds a collection of strokes to a custom recognizer node.
/// </summary>
/// <param name="baseInkAnalyzer">The ink analyzer that contains the
/// custom recognizer node.</param>
/// <param name="theStrokes">The strokes to add.</param>
/// <param name="theCustomRecognizerNode">The custom recognizer node
/// to which to add the strokes.</param>
/// <returns>The node to which the analyzer added the strokes.</returns>
/// <remarks>
/// This method converts stroke data to packet data for example only.
/// The InkAnalyzerBase is used when your application is handling packet
/// data. If your application uses stroke data from an Ink object, then
/// you would use InkAnalyzer.
/// </remarks>
public static System.Windows.Ink.AnalysisCore.ContextNodeBase MyAddStrokesToCustomRecognizer(
    System.Windows.Ink.AnalysisCore.InkAnalyzerBase baseInkAnalyzer,
    Microsoft.Ink.Strokes theStrokes,
    System.Windows.Ink.AnalysisCore.ContextNodeBase theCustomRecognizerNode)
{
    if (null == baseInkAnalyzer)
    {
        throw new ArgumentNullException("baseInkAnalyzer");
    }

    if (null == theStrokes)
    {
        throw new ArgumentNullException("theStrokes");
    }

    if (0 == theStrokes.Count)
    {
        throw new ArgumentException("Empty strokes collection.");
    }

    if (System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.CustomRecognizer
        != theCustomRecognizerNode.Type)
    {
        throw new ArgumentException(
            "The context node is not a custom recognizer node.",
            "theCustomRecognizer");
    }

    if (null == baseInkAnalyzer.FindNode(theCustomRecognizerNode.Id))
    {
        throw new ArgumentException(
            "The custom recognizer node is not attached to the ink analyzer.");
    }

    // Only strokes that have the same packet description GUIDs
    // can be added in one call to InkAnalyzerBase.AddStrokes.
    Guid[] thePacketDescription = theStrokes[0].PacketDescription;

    // Accumulate the stroke data in collections.
    ArrayList theStrokeIdentifiers = new ArrayList();
    ArrayList thePacketCounts = new ArrayList();
    ArrayList thePacketData = new ArrayList();

    foreach (Microsoft.Ink.Stroke aStroke in theStrokes)
    {
        if (!InkAnalyzerHelper.AreElementwiseEquivalent(
            aStroke.PacketDescription, thePacketDescription))
        {
            throw new ApplicationException(
                "The strokes collection contains strokes with different packet descriptions.");
        }

        // Add the stroke data to the collections.
        theStrokeIdentifiers.Add(aStroke.Id);
        thePacketCounts.Add(aStroke.PacketCount);
        thePacketData.AddRange(aStroke.GetPacketData());
    }

    // Add the stroke data to the base layer ink analyzer.
    System.Windows.Ink.AnalysisCore.ContextNodeBase result =
        baseInkAnalyzer.AddStrokesToCustomRecognizer(
            theStrokeIdentifiers.ToArray(typeof(int)) as int[],
            thePacketCounts.ToArray(typeof(int)) as int[],
            thePacketData.ToArray(typeof(int)) as int[],
            thePacketDescription,
            theCustomRecognizerNode);

    return result;
}

Piattaforme

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Framework

Supportato in: 3.0

Vedere anche

Riferimenti

InkAnalyzerBase Classe

Membri InkAnalyzerBase

Spazio dei nomi System.Windows.Ink.AnalysisCore