Пример #1
0
 private void ZXingScanView_CodeDecoded(object sender, ZXingResultEventArgs e)
 {
     if (e.result != null)
     {
         TryWriteTag("ResultString", e.result.Text);
         TryWriteTag("ScanTime", e.result.Timestamp);
         TryWriteTag("BarcodeFormat", e.result.BarcodeFormat);
     }
 }
Пример #2
0
        private void DecodeBarcode()
        {
            var reader = new BarcodeReader();
            IList <BarcodeFormat> pf = new List <BarcodeFormat>()
            {
                BarcodeFormat.All_1D,
                BarcodeFormat.DATA_MATRIX,
                BarcodeFormat.QR_CODE,
                BarcodeFormat.PDF_417,
                BarcodeFormat.MAXICODE,
            };

            reader.Options.PossibleFormats = pf;
            while (true)
            {
                if (!IsHandleCreated)
                {
                    return;
                }
                if (currentBitmapForDecoding != null)
                {
                    var result = reader.Decode(currentBitmapForDecoding);
                    if (result != null)
                    {
                        Invoke(new Action <Result>(ShowResult), result);
                        ZXingResultEventArgs zrea = new ZXingResultEventArgs(result);
                        CodeDecoded?.Invoke(this, zrea);
                    }
                    currentBitmapForDecoding.Dispose();
                    currentBitmapForDecoding = null;
                }
                if (Thread.CurrentThread.IsAlive)
                {
                    Thread.Sleep(200);
                }
                else
                {
                    Thread.CurrentThread.Abort();
                }
            }
        }