Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AnalysisStatus Class

Represents the status of the analysis operation by indicating whether the analysis completed successfully, whether any warnings occurred, and where the changes, if any, were applied.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

public class AnalysisStatus

The following 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 InkRecognizerInitializationFailed warning. 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.
			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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2015 Microsoft