AnalysisStatus Class
.NET Framework 3.0
Represents the status of the analysis operation by indicating the success of the analysis, occurrences of warnings, and where or if any changes occurred.
Namespace: System.Windows.Ink
Assembly: IAWinFX (in iawinfx.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: IAWinFX (in iawinfx.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
This example shows how to look for warnings after an ink analysis. When you perform the analysis with the Afrikaans recognizer, which you probably have not installed, the analysis fails with an AnalysisWarningCode value of NoMatchingInkRecognizerFound. In this example, the debugging information is simply sent to the Output window using 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() Dim afrikaansLanguageId As Integer = 1078 afrikaansInkAnalyzer.AddStrokes(theInkCanvas.Strokes, afrikaansLanguageId) Dim status As AnalysisStatus = afrikaansInkAnalyzer.Analyze() ' Note: We should only expect to see the BackgroundException warning if ' we were performing background analysis. ' Display any warnings If Not status.Successful Then ' Initialize warning message Dim message As String = "Analysis resulted in the following warnings:" & Environment.NewLine ' Loop through warnings Dim warning As AnalysisWarning For Each warning In status.Warnings Select Case warning.WarningCode Case AnalysisWarningCode.Aborted message &= "Analysis operation was aborted. " Case 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 AnalysisWarningCode.ConfirmedWithoutInkRecognition message &= "Node was confirmed without ink recognition having been performed. " Case AnalysisWarningCode.ContextNodeLocationNotSet message &= "Node does not have a proper location set. " Case AnalysisWarningCode.FactoidCoercionNotSupported message &= "Factoid coercion failed " If Not (warning.AnalysisHint Is Nothing) AndAlso _ Not (warning.AnalysisHint.Factoid Is Nothing) Then message &= "for factoid: " & warning.AnalysisHint.Factoid & ". " End If Case AnalysisWarningCode.FactoidNotSupported If Not (warning.AnalysisHint Is Nothing) AndAlso _ Not (warning.AnalysisHint.Factoid Is Nothing) Then message &= warning.AnalysisHint.Factoid & " factoid was not respected. " End If Case AnalysisWarningCode.GuideNotSupported message &= "Guide was not respected. " Case AnalysisWarningCode.AddInkToRecognizerFailed message &= "Ink could not be added to the InkRecognizer. " Case AnalysisWarningCode.InkRecognizerInitializationFailed message &= "The InkRecognizer failed to initialize. " Case AnalysisWarningCode.NoMatchingInkRecognizerFound message &= "There are no ink recognizers meeting the language or capabilities needed. " Case AnalysisWarningCode.LanguageIdNotRespected message &= "The language ID set on a stroke did not match the language ID of the InkRecognizer. " Case AnalysisWarningCode.PartialDictionaryTermsNotSupported message &= "Partial dictionary terms could not be returned from the text recognizer. " Case AnalysisWarningCode.TextRecognitionProcessFailed message &= "The text recognition process failed. " Case AnalysisWarningCode.SetPrefixSuffixFailed 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 &= "Prefix: " & warning.AnalysisHint.PrefixText & ". " End If If Not (warning.AnalysisHint Is Nothing) AndAlso _ Not (warning.AnalysisHint.SuffixText Is Nothing) Then message &= "Suffix: " & warning.AnalysisHint.SuffixText & ". " End If Case AnalysisWarningCode.WordlistNotSupported message &= "Wordlist was not respected. " Case AnalysisWarningCode.WordModeNotSupported message &= "Word mode was not respected. " End Select ' Add node id information Dim id As Guid For Each id In warning.GetNodeIds() message &= "Id: " & id.ToString() & " " Next id ' Add hint information If Not (warning.AnalysisHint Is Nothing) Then Dim hint As AnalysisHintNode = warning.AnalysisHint message &= Environment.NewLine & "Hint information: " message &= "AllowPartialDictionaryTerms" If hint.AllowPartialDictionaryTerms Then message &= " = true " Else message &= " = false " End If message &= "CoerceToFactoid" If hint.CoerceToFactoid Then message &= " = true " Else message &= " = false " End If If Not (hint.Factoid Is Nothing) Then message &= "Factoid = " & warning.AnalysisHint.Factoid & " " End If message &= "Guide Drawn Box = (" _ & hint.Guide.DrawnBoxTop.ToString() & ", " _ & hint.Guide.DrawnBoxLeft.ToString() & ", " _ & hint.Guide.DrawnBoxBottom.ToString() & ", " _ & hint.Guide.DrawnBoxRight.ToString() & ", " & ")" message &= "Guide Writing Box = (" _ & hint.Guide.WritingBoxTop.ToString() & ", " _ & hint.Guide.WritingBoxLeft.ToString() & ", " _ & hint.Guide.WritingBoxBottom.ToString() & ", " _ & hint.Guide.WritingBoxRight.ToString() & ", " & ")" If Not (hint.Name Is Nothing) Then message &= "Name = " & warning.AnalysisHint.Name & " " End If If Not (hint.PrefixText Is Nothing) Then message &= "PrefixText = " & warning.AnalysisHint.PrefixText & " " End If If Not (hint.SuffixText Is Nothing) Then message &= "SuffixText = " & warning.AnalysisHint.SuffixText & " " End If message &= "WordMode" If hint.WordMode Then message &= " = true" Else message &= " = false" End If End If message &= Environment.NewLine Next warning ' Show in the output window System.Diagnostics.Debug.WriteLine(message) End If If status.Successful Then MessageBox.Show(afrikaansInkAnalyzer.GetRecognizedString()) End If
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.Community Additions
ADD
Show: