다음을 통해 공유


InkAnalyzerBase.AddStrokesToCustomRecognizer 메서드

업데이트: 2007년 11월

사용자 지정 인식기 노드에 여러 스트로크에 대한 스트로크 데이터를 추가합니다.

네임스페이스:  System.Windows.Ink.AnalysisCore
어셈블리:  IACore(IACore.dll)

구문

‘선언
Public Function AddStrokesToCustomRecognizer ( _
    strokeIds As Integer(), _
    strokePacketCount As Integer(), _
    strokePacketData As Integer(), _
    strokePacketDescription As Guid(), _
    customRecognizer As ContextNodeBase _
) As ContextNodeBase
‘사용 방법
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

매개 변수

  • strokeIds
    형식: array<System.Int32[]
    스트로크 식별자가 들어 있는 배열입니다.
  • strokePacketCount
    형식: array<System.Int32[]
    각 스트로크의 패킷 수가 들어 있는 배열입니다.
  • strokePacketData
    형식: array<System.Int32[]
    스트로크에 대한 패킷 데이터가 들어 있는 배열입니다.
  • strokePacketDescription
    형식: array<System.Guid[]
    패킷 속성 식별자가 들어 있는 배열입니다.

반환 값

형식: System.Windows.Ink.AnalysisCore.ContextNodeBase
잉크 분석기에서 스트로크를 추가한 컨텍스트 노드입니다.

설명

InkAnalyzerBaseType 속성 값이 UnclassifiedInk()인 ContextNodeBase에 스트로크를 추가합니다.

잉크 분석기는 분석 도중 활성 입력 스레드의 문화권 식별자를 스트로크에 할당하고 잉크 인식기 아래에서 분류되지 않은 첫 번째 잉크 노드에 스트로크를 추가합니다. 분류되지 않은 노드가 없으면 이러한 노드가 만들어집니다. 사용자 지정 인식기가 문화권 식별자를 지원하지 않는 경우에는 잉크 분석기가 분석을 계속하고 AnalysisWarningBase 경고를 생성합니다. 이 경고의 WarningCode 속성은 LanguageIdNotRespected라는 AnalysisWarningCode 값으로 설정됩니다.

AddStrokes를 한 번 호출하여 패킷 설명이 동일한 스트로크만 추가할 수 있습니다.

이 메서드는 DirtyRegion을 영역의 현재 값과 추가된 스트로크의 경계 상자를 합친 영역으로 확장합니다.

다음과 같은 경우 InkAnalyzerBase에서 예외가 throw됩니다.

  • 추가할 스트로크 중 하나와 식별자가 같은 스트로크가 InkAnalyzerBase에 이미 포함된 경우

  • 다른 InkAnalyzerBase 개체와 연결된 ContextNodeBase가 customRecognizer 매개 변수에 포함된 경우

  • customRecognizer 매개 변수에 Type 속성 값이 CustomRecognizer()가 아닌 ContextNodeBase가 포함된 경우

예제

이 예제에서는 Strokes 컬렉션을 패킷 데이터로 변환하고 사용자 지정 인식기 노드에 스트로크를 추가하는 메서드를 정의합니다. 이 메서드는 잉크 분석기에서 스트로크를 추가한 ContextNodeBase를 반환합니다.

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

플랫폼

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

InkAnalyzerBase 클래스

InkAnalyzerBase 멤버

System.Windows.Ink.AnalysisCore 네임스페이스