AutoFocus() public method

public AutoFocus ( ) : void
return void
示例#1
0
        private async Task scanBarcode()
        {
            //Creates the barcode scanner and adds camera
            var options = new ZXing.Mobile.MobileBarcodeScanningOptions
            {
                CameraResolutionSelector = HandleCameraResolutionSelectorDelegate
            };

            options.PossibleFormats = new List <ZXing.BarcodeFormat>()
            {
                ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13
            };

            var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);

            scanner.AutoFocus();

            //Grabs the scanner result and displays it in the new page
            //The new page is the itemController
            var result = await scanner.Scan(options, true);

            string code = result.Text;

            if (result != null)
            {
                ItemController controller = new ItemController();
                this.NavigationController.PushViewController(controller, true);
                controller.barCodeLableText = code;
                controller.itemNameText     = "Bandage, Adhsv Shr Strp 1x3 (100/bx 24bx/cs) Mgm16";
                controller.itemNumberText   = "15";
                //controller.addLabelText = query;

                Console.WriteLine("Scanned Barcode: " + result.Text);
            }
        }
示例#2
0
        public async Task <string> ScanAsync()
        {
            // https://forums.xamarin.com/discussion/comment/284749/#Comment_284749
            var optionsCustom = new MobileBarcodeScanningOptions()
            {
                AutoRotate      = false,
                TryInverted     = true,
                TryHarder       = true,
                PossibleFormats = new List <BarcodeFormat> {
                    BarcodeFormat.QR_CODE
                },
                // CharacterSet = "ISO-8859-1",
                CameraResolutionSelector = HandleCameraResolutionSelectorDelegate
                                           // DisableAutofocus = false
            };

            var scanner = new ZXing.Mobile.MobileBarcodeScanner()
            {
                TopText          = "QR Code scannen",
                BottomText       = "Bitte warten",
                CancelButtonText = "Abbrechen"
            };

            ZXing.Result scanResult = null;

            // https://forums.xamarin.com/discussion/72077/zxing-barcode-reader-autofocus
            Thread autofocusThread = new Thread(new ThreadStart(delegate
            {
                while (scanResult == null)
                {
                    scanner.AutoFocus();
                    Thread.Sleep(2000);
                }
            }));

            autofocusThread.Start();

            // scanner.AutoFocus();
            try
            {
                scanResult = await scanner.Scan(optionsCustom);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (autofocusThread.IsAlive)
                {
                    autofocusThread.Abort();
                }
            }

            return(scanResult.Text);
        }
示例#3
0
        public async void CallWebViewSendData()
        {
            var scanner = new ZXing.Mobile.MobileBarcodeScanner();

            scanner.AutoFocus();
            var options = new ZXing.Mobile.MobileBarcodeScanningOptions();

            options.DelayBetweenAnalyzingFrames = 1000;


            scanner.TopText = "Scanning..";

            var result = await scanner.Scan(options);

            if (result != null)
            {
                wv.LoadUrl("javascript:msg(" + @"'" + result.Text + @"'" + ");");
            }
        }
        private async Task ShowQRCodeScannerAsync()
        {
            var options = new ZXing.Mobile.MobileBarcodeScanningOptions();

            options.PossibleFormats = new List <ZXing.BarcodeFormat>()
            {
                ZXing.BarcodeFormat.QR_CODE
            };

            var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);

            scanner.TopText = "Scan QR Code from lottiefiles.com";
            scanner.AutoFocus();

            var result = await scanner.Scan(options, true);

            if (result != null)
            {
                LoadAnimationFromUrl(result.Text);
            }
        }
        private async void QRScanButton_Click(object sender, EventArgs e)
        {
            MobileBarcodeScanner.Initialize(this.Activity.Application);

            var options = new ZXing.Mobile.MobileBarcodeScanningOptions();

            options.PossibleFormats = new List <ZXing.BarcodeFormat>()
            {
                ZXing.BarcodeFormat.QR_CODE
            };

            var scanner = new ZXing.Mobile.MobileBarcodeScanner();

            scanner.AutoFocus();
            scanner.UseCustomOverlay = true;
            scanner.CustomOverlay    = GetQRCodeCustomOverlay();

            var result = await scanner.Scan(options);

            if (result != null)
            {
                LoadUrl(result.Text);
            }
        }