예제 #1
0
        private void ReadBarCode_Click(object sender, EventArgs e)
        {
            if (this.BackgroundImage == null)
            {
                return;
            }

            var bmp = new Bitmap(this.BackgroundImage);

            new MethodInvoker(() =>
            {
                Barcode[] readBarCodes = null;
                Voucher data           = new Voucher();

                lock (typeof(BarcodeReader))
                {
                    BarcodeReader reader = new BarcodeReader(Strings.VScan_BarcodeReaderSDKDeveloperLicenseKey);
                    reader.LicenseManager.AddLicenseKey(Strings.VScan_BarcodeReaderSDKUnlimitedRuntimeLicenseKey);
                    reader.BarcodesToRead = 1;
                    reader.BarcodeTypes   = BarcodeTypeEnum.BT_Inter2of5;
                    readBarCodes          = reader.ReadFromBitmapRotateAll(ref bmp, data);
                }

                bmp.DisposeSf();

                if (readBarCodes.Length == 0)
                {
                    throw new AppExclamationException("Can not find barcode");
                }
                else if (readBarCodes.Length > 1)
                {
                    throw new AppExclamationException("Too many barcodes");
                }
                m_BarcodeArea = data.BarCodeArea;
                data.DisposeSf();
                Invalidate();
            }).FireAndForget();
        }