示例#1
0
        private void OnNavigated(object sender, NavigationEventArgs e)
        {
            if (!(e.Content is Pdf417ScannerPage))
            {
                return;
            }

            var phoneApplicationFrame = Application.Current.RootVisual as PhoneApplicationFrame;

            if (phoneApplicationFrame != null)
            {
                phoneApplicationFrame.Navigated -= this.OnNavigated;
            }

            var pdf417Scanner = (Pdf417ScannerPage)e.Content;

            if (pdf417Scanner != null)
            {
                pdf417Scanner.OnComplete += pdf417Scanner_OnComplete;
                pdf417Scanner.OnFailure  += pdf417Scanner_OnFailure;
                pdf417Scanner.OnCancel   += pdf417Scanner_OnCancel;
            }
            else
            {
                DispatchCommandResult(Pdf417ScannerResult.CancelResult());
            }
        }
示例#2
0
        public static PluginResult CancelResult()
        {
            PluginResult        result    = new PluginResult(PluginResult.Status.OK);
            Pdf417ScannerResult resultMsg = new Pdf417ScannerResult();

            resultMsg.cancelled = true;
            result.Message      = JsonHelper.Serialize(resultMsg);
            return(result);
        }
示例#3
0
        void pdf417Scanner_OnComplete(IList <IRecognitionResult> resultList)
        {
            Pdf417ScannerResult pluginResult = new Pdf417ScannerResult();

            pluginResult.cancelled  = false;
            pluginResult.resultList = new List <Pdf417ScannerBaseResult>();
            foreach (var recognitionResult in resultList)
            {
                if (recognitionResult.Valid && !recognitionResult.Empty)
                {
                    if (recognitionResult is PDF417RecognitionResult)
                    {
                        PDF417RecognitionResult    pdf417Result  = (PDF417RecognitionResult)recognitionResult;
                        Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                        barcodeResult.type = "PDF417";
                        barcodeResult.data = pdf417Result.StringData;
                        byte[] rawData = pdf417Result.RawData.GetAllData();
                        barcodeResult.raw = ByteArrayToHex(rawData);
                        pluginResult.resultList.Add(barcodeResult);
                    }
                    else if (recognitionResult is ZXingRecognitionResult)
                    {
                        ZXingRecognitionResult     zxingResult   = (ZXingRecognitionResult)recognitionResult;
                        Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                        barcodeResult.type = zxingResult.BarcodeTypeString;
                        barcodeResult.data = zxingResult.StringData;
                        pluginResult.resultList.Add(barcodeResult);
                    }
                    else if (recognitionResult is BarDecoderRecognitionResult)
                    {
                        BarDecoderRecognitionResult bcodeResult   = (BarDecoderRecognitionResult)recognitionResult;
                        Pdf417ScannerBarcodeResult  barcodeResult = new Pdf417ScannerBarcodeResult();
                        barcodeResult.type = bcodeResult.BarcodeTypeString;
                        barcodeResult.data = bcodeResult.StringData;
                        pluginResult.resultList.Add(barcodeResult);
                    }
                    else if (recognitionResult is USDLRecognitionResult)
                    {
                        USDLRecognitionResult   uResult    = (USDLRecognitionResult)recognitionResult;
                        Pdf417ScannerUSDLResult usdlResult = new Pdf417ScannerUSDLResult();
                        usdlResult.fields = new Dictionary <string, string>();
                        foreach (string key in uResult.Elements.Keys)
                        {
                            if (uResult.Elements[key] is string)
                            {
                                usdlResult.fields.Add(key, (string)uResult.Elements[key]);
                            }
                        }
                        pluginResult.resultList.Add(usdlResult);
                    }
                }
            }
            // dispatct JSON result
            string json = pluginResult.GetJSON();

            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, json));
        }
 public static PluginResult CancelResult()
 {
     PluginResult result = new PluginResult(PluginResult.Status.OK);
     Pdf417ScannerResult resultMsg = new Pdf417ScannerResult();
     resultMsg.cancelled = true;
     result.Message = JsonHelper.Serialize(resultMsg);
     return result;
 }
 void pdf417Scanner_OnComplete(IList<IRecognitionResult> resultList)
 {
     Pdf417ScannerResult pluginResult = new Pdf417ScannerResult();
     pluginResult.cancelled = false;
     pluginResult.resultList = new List<Pdf417ScannerBaseResult>();
     foreach (var recognitionResult in resultList) {
         if (recognitionResult.Valid && !recognitionResult.Empty) {
             if (recognitionResult is PDF417RecognitionResult) {
                 PDF417RecognitionResult pdf417Result = (PDF417RecognitionResult)recognitionResult;
                 Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                 barcodeResult.type = "PDF417";
                 barcodeResult.data = pdf417Result.StringData;
                 byte[] rawData = pdf417Result.RawData.GetAllData();
                 barcodeResult.raw = ByteArrayToHex(rawData);
                 pluginResult.resultList.Add(barcodeResult);
             } else if (recognitionResult is ZXingRecognitionResult) {
                 ZXingRecognitionResult zxingResult = (ZXingRecognitionResult)recognitionResult;
                 Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                 barcodeResult.type = zxingResult.BarcodeTypeString;
                 barcodeResult.data = zxingResult.StringData;
                 pluginResult.resultList.Add(barcodeResult);
             } else if (recognitionResult is BarDecoderRecognitionResult) {
                 BarDecoderRecognitionResult bcodeResult = (BarDecoderRecognitionResult)recognitionResult;
                 Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                 barcodeResult.type = bcodeResult.BarcodeTypeString;
                 barcodeResult.data = bcodeResult.StringData;
                 pluginResult.resultList.Add(barcodeResult);
             } else if (recognitionResult is USDLRecognitionResult) {
                 USDLRecognitionResult uResult = (USDLRecognitionResult)recognitionResult;
                 Pdf417ScannerUSDLResult usdlResult = new Pdf417ScannerUSDLResult();
                 usdlResult.fields = new Dictionary<string,string>();
                 foreach (string key in uResult.Elements.Keys) {
                     if (uResult.Elements[key] is string) {
                         usdlResult.fields.Add(key, (string)uResult.Elements[key]);
                     }
                 }
                 pluginResult.resultList.Add(usdlResult);
             }
         }
     }
     // dispatct JSON result
     string json = pluginResult.GetJSON();
     DispatchCommandResult(new PluginResult(PluginResult.Status.OK, json));
 }
示例#6
0
 void pdf417Scanner_OnCancel()
 {
     DispatchCommandResult(Pdf417ScannerResult.CancelResult());
 }