다음을 통해 공유


AnalysisStatus 클래스

업데이트: 2007년 11월

분석이 성공적으로 완료되었는지 여부, 경고가 발생했는지 여부, 그리고 변경 사항(있는 경우)이 적용된 위치를 설명하여 분석 작업의 상태를 나타냅니다.

네임스페이스:  Microsoft.Ink
어셈블리:  Microsoft.Ink.Analysis(Microsoft.Ink.Analysis.dll)

구문

‘선언
Public Class AnalysisStatus
‘사용 방법
Dim instance As AnalysisStatus
public class AnalysisStatus
public ref class AnalysisStatus
public class AnalysisStatus
public class AnalysisStatus

예제

다음 예제에서는 잉크 분석 후 경고를 검색하는 방법을 보여 줍니다. 대개 설치되어 있지 않은 남아공 공용어 인식기를 사용하여 분석을 수행하는 경우 분석이 InkRecognizerInitializationFailed 경고의 AnalysisWarningCode 값과 함께 실패합니다. 이 예제에서는 System.Diagnostics.Debug.WriteLine을 사용하여 출력 창으로 디버깅 정보만 보냅니다.

' Analyze using Afrikaans recognizer.
' You are unlikely to have this recognizer, so it will raise a warning.
Dim afrikaansInkAnalyzer As New InkAnalyzer(theInkCollector.Ink, Me)
Dim afrikaansLanguageId As Integer = 1078


' Access to the Strokes property returns a copy of the Strokes object.
' This copy must be implicitly (via using statement) or explicitly
' disposed of in order to avoid a memory leak.
Dim allStrokes As Strokes = theInkCollector.Ink.Strokes
afrikaansInkAnalyzer.AddStrokes(allStrokes, afrikaansLanguageId)
Dim status As AnalysisStatus = afrikaansInkAnalyzer.Analyze()
' Dispose of the copy of the theInkCollector.Ink.Strokes object
allStrokes.Dispose()


' Display any warnings
If status.Warnings.Count > 0 Then
    ' Initialize warning message
    Dim message As String = "Analysis resulted in the following warnings:" & Environment.NewLine

    ' Note: We should only expect to see the BackgroundException warning if
    ' we were performing background analysis.
    ' Loop through warnings
    Dim warning As AnalysisWarning
    For Each warning In status.Warnings
        Select Case warning.WarningCode
            Case Microsoft.Ink.AnalysisWarningCode.Aborted
                message = message & "Analysis operation was aborted. "
            Case Microsoft.Ink.AnalysisWarningCode.BackgroundException
                ' This is a fatal warning. Throw an exception.
                ' First, attempt to save as much document state as possible 
                ' ...

                ' Rethrow the exception so that it can be caught by an exception
                ' handler (or if there is no exception handler, a program error 
                ' debugger such as Dr. Watson can be invoked)
                Throw (warning.BackgroundException)
            Case Microsoft.Ink.AnalysisWarningCode.ConfirmedWithoutInkRecognition
                message = message & "Node was confirmed without ink recognition having been performed. "
            Case Microsoft.Ink.AnalysisWarningCode.ContextNodeLocationNotSet
                message = message & "Node does not have a proper location set. "
            Case Microsoft.Ink.AnalysisWarningCode.FactoidCoercionNotSupported
                message = message & "Factoid coercion failed "
                If (Not warning.AnalysisHint Is Nothing) AndAlso (Not warning.AnalysisHint.Factoid Is Nothing) Then
                    message = message & "for factoid: " & warning.AnalysisHint.Factoid & ". "
                End If
            Case Microsoft.Ink.AnalysisWarningCode.FactoidNotSupported
                If (Not warning.AnalysisHint Is Nothing) AndAlso (Not warning.AnalysisHint.Factoid Is Nothing) Then
                    message = message & warning.AnalysisHint.Factoid & " factoid was not respected. "
                End If
            Case Microsoft.Ink.AnalysisWarningCode.GuideNotSupported
                message = message & "Guide was not respected. "
            Case Microsoft.Ink.AnalysisWarningCode.AddInkToRecognizerFailed
                message = message & "Ink could not be added to the InkRecognizer. "
            Case Microsoft.Ink.AnalysisWarningCode.InkRecognizerInitializationFailed
                message = message & "The InkRecognizer failed to initialize. "
            Case Microsoft.Ink.AnalysisWarningCode.NoMatchingInkRecognizerFound
                message = message & "There are no ink recognizers meeting the language or capabilities needed. "
            Case Microsoft.Ink.AnalysisWarningCode.LanguageIdNotRespected
                message = message & "The language ID set on a stroke did not match the language ID of the InkRecognizer. "
            Case Microsoft.Ink.AnalysisWarningCode.PartialDictionaryTermsNotSupported
                message = message & "Partial dictionary terms could not be returned from the text recognizer. "
            Case Microsoft.Ink.AnalysisWarningCode.TextRecognitionProcessFailed
                message = message & "The text recognition process failed. "
            Case Microsoft.Ink.AnalysisWarningCode.SetPrefixSuffixFailed
                message = message & "The text recognizer was unable to respect either the prefix or suffix. "
                If (Not warning.AnalysisHint Is Nothing) AndAlso (Not warning.AnalysisHint.PrefixText Is Nothing) Then
                    message = message & "Prefix: " & warning.AnalysisHint.PrefixText & ". "
                End If
                If (Not warning.AnalysisHint Is Nothing) AndAlso (Not warning.AnalysisHint.SuffixText Is Nothing) Then
                    message = message & "Suffix: " & warning.AnalysisHint.SuffixText & ". "
                End If
            Case Microsoft.Ink.AnalysisWarningCode.WordlistNotSupported
                message = message & "Wordlist was not respected. "
            Case Microsoft.Ink.AnalysisWarningCode.WordModeNotSupported
                message = message & "Word mode was not respected. "
        End Select


        ' Add node id information
        Dim id As Guid
        For Each id In warning.GetNodeIds()
            message = message & "Id: " & id.ToString() & " "
        Next id


        ' Add hint information
        If Not (warning.AnalysisHint Is Nothing) Then
            Dim hint As AnalysisHintNode = warning.AnalysisHint
            message = message & Environment.NewLine & "Hint information: "
            message = message & "AllowPartialDictionaryTerms"
            If hint.AllowPartialDictionaryTerms = True Then
                message = message & " = True "
            Else
                message = message & " = False "
            End If
            message = message & "CoerceToFactoid"
            If hint.CoerceToFactoid = True Then
                message = message & " = True "
            Else
                message = message & " = False "
            End If
            If Not hint.Factoid Is Nothing Then
                message = message & "Factoid = " & warning.AnalysisHint.Factoid & " "
            End If
            If hint.Guide.DrawnBox <> Rectangle.Empty Then
                message = message & "Guide Drawn Box = " & hint.Guide.DrawnBox.ToString()
            End If
            If hint.Guide.WritingBox <> Rectangle.Empty Then
                message = message & "Guide Writing Box = " & hint.Guide.WritingBox.ToString()
            End If
            message = message & String.Format("Guide = ({0}, {1})", _
                 hint.Guide.Columns, hint.Guide.Rows)
            If Not hint.Name Is Nothing Then
                message = message & "Name = " & warning.AnalysisHint.Name & " "
            End If
            If Not hint.PrefixText Is Nothing Then
                message = message & "PrefixText = " & warning.AnalysisHint.PrefixText & " "
            End If
            If Not hint.SuffixText Is Nothing Then
                message = message & "SuffixText = " & warning.AnalysisHint.SuffixText & " "
            End If
            message = message & "WordMode"
            If hint.WordMode = True Then
                message = message & " = True"
            Else
                message = message & " = False"
            End If
        End If

        message = message & Environment.NewLine
    Next warning

    ' Show in the output window
    System.Diagnostics.Debug.WriteLine(message)
End If
If status.Successful Then
    Me.labelResult.Text = afrikaansInkAnalyzer.GetRecognizedString()
End If

            // Analyze using Afrikaans recognizer.
            // You are unlikely to have this recognizer, so it will raise a warning.
            InkAnalyzer afrikaansInkAnalyzer = new InkAnalyzer(theInkCollector.Ink, this);
            int afrikaansLanguageId = 1078;

            // Access to the Strokes property returns a copy of the Strokes object.
            // This copy must be implicitly (via using statement) or explicitly
            // disposed of in order to avoid a memory leak.
            Strokes allStrokes = theInkCollector.Ink.Strokes;
            afrikaansInkAnalyzer.AddStrokes(allStrokes, afrikaansLanguageId);
            AnalysisStatus status = afrikaansInkAnalyzer.Analyze();
            // Dispose of the copy of the theInkCollector.Ink.Strokes object
            allStrokes.Dispose();

            // Note: We should only expect to see the BackgroundException warning if
            // we were performing background analysis.
            // Display any warnings
            if (!status.Successful)
            {
                // Initialize warning message
                string message = "Analysis resulted in the following warnings:" + Environment.NewLine;

                // Loop through warnings
                foreach (AnalysisWarning warning in status.Warnings)
                {
                    switch (warning.WarningCode)
                    {
                        case Microsoft.Ink.AnalysisWarningCode.Aborted:
                            message += "Analysis operation was aborted. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.BackgroundException:
                            // This is a fatal warning. Throw an exception.
                            // First, attempt to save as much doc state as possible 
                            // ...

                            // Rethrow the exception so that it can be caught by an exception
                            // handler (or if there is no exception handler, a program error 
                            // debugger such as Dr. Watson can be invoked)
                            throw(warning.BackgroundException);
                        case Microsoft.Ink.AnalysisWarningCode.ConfirmedWithoutInkRecognition:
                            message += "Node was confirmed without ink recognition having been performed. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.ContextNodeLocationNotSet:
                            message += "Node does not have a proper location set. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.FactoidCoercionNotSupported:
                            message += "Factoid coercion failed ";
                            if (warning.AnalysisHint != null && warning.AnalysisHint.Factoid != null)
                            {
                                message += "for factoid: " + warning.AnalysisHint.Factoid + ". ";
                            } 
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.FactoidNotSupported:
                            if (warning.AnalysisHint != null && warning.AnalysisHint.Factoid != null)
                            {
                                message += warning.AnalysisHint.Factoid + " factoid was not respected. ";
                            }
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.GuideNotSupported:
                            message += "Guide was not respected. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.AddInkToRecognizerFailed:
                            message += "Ink could not be added to the InkRecognizer. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.InkRecognizerInitializationFailed:
                            message += "The InkRecognizer failed to initialize. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.NoMatchingInkRecognizerFound:
                            message += "There are no ink recognizers meeting the language or capabilities needed. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.LanguageIdNotRespected:
                            message += "The language ID set on a stroke did not match the language ID of the InkRecognizer. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.PartialDictionaryTermsNotSupported:
                            message += "Partial dictionary terms could not be returned from the text recognizer. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.TextRecognitionProcessFailed:
                            message += "The text recognition process failed. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.SetPrefixSuffixFailed:
                            message += "The text recognizer was unable to respect either the prefix or suffix. ";
                            if (warning.AnalysisHint != null && warning.AnalysisHint.PrefixText != null)
                            {
                                message += "Prefix: " + warning.AnalysisHint.PrefixText + ". ";
                            }
                            if (warning.AnalysisHint != null && warning.AnalysisHint.SuffixText != null)
                            {
                                message += "Suffix: " + warning.AnalysisHint.SuffixText + ". ";
                            }
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.WordlistNotSupported:
                            message += "Wordlist was not respected. ";
                            break;
                        case Microsoft.Ink.AnalysisWarningCode.WordModeNotSupported:
                            message += "Word mode was not respected. ";
                            break;
                    }

                    // Add node id information
                    foreach (Guid id in warning.GetNodeIds())
                        message += "Id: " + id.ToString() + " ";

                    // Add hint information
                    if (warning.AnalysisHint != null)
                    {
                        AnalysisHintNode hint = warning.AnalysisHint;
                        message += Environment.NewLine + "Hint information: ";
                        message += "AllowPartialDictionaryTerms";
                        if (hint.AllowPartialDictionaryTerms)
                            message += " = true ";
                        else
                            message += " = false ";
                        message += "CoerceToFactoid";
                        if (hint.CoerceToFactoid)
                            message += " = true ";
                        else
                            message += " = false ";
                        if (hint.Factoid != null)
                            message += "Factoid = " + warning.AnalysisHint.Factoid + " ";
                        if (hint.Guide.DrawnBox != Rectangle.Empty)
                            message += "Guide Drawn Box = " + hint.Guide.DrawnBox.ToString();
                        if (hint.Guide.WritingBox != Rectangle.Empty)
                            message += "Guide Writing Box = " + hint.Guide.WritingBox.ToString();
                        if (hint.Name != null)
                            message += "Name = " + warning.AnalysisHint.Name + " ";
                        if (hint.PrefixText != null)
                            message += "PrefixText = " + warning.AnalysisHint.PrefixText + " ";
                        if (hint.SuffixText != null)
                            message += "SuffixText = " + warning.AnalysisHint.SuffixText + " ";
                        message += "WordMode";
                        if (hint.WordMode)
                            message += " = true";
                        else
                            message += " = false";
                    }
                    message += Environment.NewLine;
                }

                // Show in the output window
                System.Diagnostics.Debug.WriteLine(message);
            }

            if (status.Successful)
            {
                this.resultsLabel.Text = afrikaansInkAnalyzer.GetRecognizedString();
            }

상속 계층 구조

System.Object
  Microsoft.Ink.AnalysisStatus

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows Vista

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

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

AnalysisStatus 멤버

Microsoft.Ink 네임스페이스

InkAnalyzer.Analyze

Microsoft.Ink.ResultsUpdatedEventArgs

System.Windows.Ink.AnalysisCore.AnalysisWarningCode