示例#1
0
 /// <summary>
 /// Handles completed scanning events.
 /// Navigates to results page if scanning was successful.
 /// </summary>
 /// <param name="resultList">list of recognition results</param>
 /// <param name="recognitionType">type of recognition</param>
 void mRecognizer_OnScanningDone(IList <Microblink.IRecognitionResult> resultList, RecognitionType recognitionType)
 {
     // navigate to results page if type of recognition is SUCCESSFUL
     if (recognitionType == RecognitionType.SUCCESSFUL)
     {
         // Find barcode results in list of results.
         bool resultFound = false;
         foreach (var result in resultList)
         {
             if (result.Valid && !result.Empty)
             {
                 // check if result is a PDF417 result
                 if (result is Microblink.PDF417RecognitionResult)
                 {
                     // obtain the PDF417 result
                     Microblink.PDF417RecognitionResult pdf417Result = (Microblink.PDF417RecognitionResult)result;
                     // set it as input for results page
                     ResultsPage.dataType      = "PDF417";
                     ResultsPage.uncertain     = pdf417Result.Uncertain ? "yes" : "no";
                     ResultsPage.raw           = pdf417Result.RawData;
                     ResultsPage.rawExt        = null;
                     ResultsPage.stringData    = pdf417Result.StringData;
                     ResultsPage.stringDataExt = null;
                     // mark as found
                     resultFound = true;
                     break;
                 }
                 // check if result is a ZXing result
                 else if (result is Microblink.ZXingRecognitionResult)
                 {
                     // obtain the ZXing result
                     Microblink.ZXingRecognitionResult zxingResult = (Microblink.ZXingRecognitionResult)result;
                     // set it as input for results page
                     ResultsPage.dataType      = zxingResult.BarcodeTypeString;
                     ResultsPage.uncertain     = null;
                     ResultsPage.raw           = zxingResult.RawData;
                     ResultsPage.rawExt        = zxingResult.ExtendedRawData;
                     ResultsPage.stringData    = zxingResult.StringData;
                     ResultsPage.stringDataExt = zxingResult.ExtendedStringData;
                     // mark as found
                     resultFound = true;
                     break;
                 }
             }
         }
         // navigate to results page if some result was found
         if (resultFound)
         {
             NavigationService.Navigate(new Uri("/ResultsPage.xaml", UriKind.Relative));
         }
     }
 }
        /// <summary>
        /// Handles completed scanning events.
        /// Navigates to results page if scanning was successful.
        /// </summary>
        /// <param name="resultList">list of recognition results</param>
        /// <param name="recognitionType">type of recognition</param>
        void mRecognizer_OnScanningDone(IList <Microblink.IRecognitionResult> resultList, RecognitionType recognitionType)
        {
            // terminate direct API
            Recognizer.GetSingletonInstance().Terminate();
            // navigate to results page
            bool resultFound = false;

            if (recognitionType == RecognitionType.SUCCESSFUL)
            {
                // Find croatian payslip results in list of results.
                foreach (var result in resultList)
                {
                    if (result.Valid && !result.Empty)
                    {
                        // check if result is a PDF417 result
                        if (result is Microblink.PDF417RecognitionResult)
                        {
                            // obtain the PDF417 result
                            Microblink.PDF417RecognitionResult pdf417Result = (Microblink.PDF417RecognitionResult)result;
                            // set it as input for results page
                            ResultsPage.results = pdf417Result.Elements;
                            // mark as found
                            resultFound = true;
                            break;
                        }
                        // check if result is a ZXing result
                        else if (result is Microblink.ZXingRecognitionResult)
                        {
                            // obtain the ZXing result
                            Microblink.ZXingRecognitionResult zxingResult = (Microblink.ZXingRecognitionResult)result;
                            // set it as input for results page
                            ResultsPage.results = zxingResult.Elements;
                            resultFound         = true;
                            break;
                        }
                    }
                }
            }
            // send scan status to results page
            ResultsPage.resultFound = resultFound;
            // navigate to results page
            NavigationService.Navigate(new Uri("/ResultsPage.xaml", UriKind.Relative));
            // reenable photo choosing
            ReenableButton();
        }
 /// <summary>
 /// Handles completed scanning events.
 /// Navigates to results page if scanning was successful.
 /// </summary>
 /// <param name="resultList">list of recognition results</param>
 /// <param name="recognitionType">type of recognition</param>
 void mRecognizer_OnScanningDone(IList <Microblink.IRecognitionResult> resultList, RecognitionType recognitionType)
 {
     if (recognitionType == RecognitionType.SUCCESSFUL)
     {
         if (OnComplete != null)
         {
             OnComplete(resultList);
             if (Option_Beep)
             {
                 mBeepSound.Play();
             }
         }
         if (!Option_NoDialog)
         {
             // Find barcode results in list of results.
             bool resultFound = false;
             IReadOnlyDictionary <string, object> elements = null;
             foreach (var result in resultList)
             {
                 if (result.Valid && !result.Empty)
                 {
                     // check if result is a PDF417 result
                     if (result is Microblink.PDF417RecognitionResult)
                     {
                         // obtain the PDF417 result
                         Microblink.PDF417RecognitionResult pdf417Result = (Microblink.PDF417RecognitionResult)result;
                         elements = pdf417Result.Elements;
                         // mark as found
                         resultFound = true;
                         break;
                     }
                     // check if result is a ZXing result
                     else if (result is Microblink.ZXingRecognitionResult)
                     {
                         // obtain the ZXing result
                         Microblink.ZXingRecognitionResult zxingResult = (Microblink.ZXingRecognitionResult)result;
                         elements = zxingResult.Elements;
                         // mark as found
                         resultFound = true;
                         break;
                     }
                     // check if result is a Bardecoder result
                     else if (result is Microblink.BarDecoderRecognitionResult)
                     {
                         // obtain the Bardecoder result
                         Microblink.BarDecoderRecognitionResult bdecoderResult = (Microblink.BarDecoderRecognitionResult)result;
                         elements = bdecoderResult.Elements;
                         // mark as found
                         resultFound = true;
                         break;
                     }
                     // check if result is a USDL result
                     else if (result is Microblink.USDLRecognitionResult)
                     {
                         // obtain the USDL result
                         Microblink.USDLRecognitionResult usdlResult = (Microblink.USDLRecognitionResult)result;
                         elements = usdlResult.Elements;
                         // mark as found
                         resultFound = true;
                         break;
                     }
                 }
             }
             // display dialog if result are found
             if (resultFound && elements != null)
             {
                 StringBuilder msg = new StringBuilder();
                 foreach (string key in elements.Keys)
                 {
                     msg.Append(key);
                     msg.Append(": ");
                     msg.Append(elements[key] != null ? elements[key].ToString().Trim() : "");
                     msg.Append("\n");
                 }
                 MessageBox.Show(msg.ToString());
             }
         }
         // navigate back to caller page
         NavigationService.GoBack();
     }
 }