Пример #1
0
        public static ScanQrOverlayView Create(QrCodeScanner scanner)
        {
            var viewArrays        = NSBundle.MainBundle.LoadNib(Key, null, null);
            var scanQrOverlayView = Runtime.GetNSObject <ScanQrOverlayView>(viewArrays.ValueAt(0));

            scanQrOverlayView.SetScanner(scanner);

            return(scanQrOverlayView);
        }
Пример #2
0
        public async void SetCaptureElement(CaptureElement captureElement)
        {
            if (_qrScanner != null)
            {
                return;
            }

            _qrScanner              = new QrCodeScanner(captureElement);
            _qrScanner.CodeScanned += CodeScanned;
            await _qrScanner.StartAsync();
        }
Пример #3
0
        public static void ScanContinuously(
            string message,
            QRCodeScanned onQrCodeScannedFunction,
            TaskCompletionSource <bool> taskCompletionSource,
            string closeButtonTitle,
            bool tryInverted)
        {
            var scanner     = new QrCodeScanner();
            var overlayView = ScanQrOverlayView.Create(scanner);

            scanner.CustomOverlay = overlayView;
            overlayView.SetCancelButtonText(closeButtonTitle);
            overlayView.SetDescriptionText(message);
            var position = 0;

            var isScanningContinouslyExecuting = false;

            scanner.ScanContinuously(new MobileBarcodeScanningOptions()
            {
                DelayBetweenContinuousScans = 3000,
                TryInverted = tryInverted
            }, async result =>
            {
                if (isScanningContinouslyExecuting)
                {
                    return;
                }
                isScanningContinouslyExecuting = true;

                var scanQrUpdate = await onQrCodeScannedFunction.Invoke(position, result.Text);

                if (scanQrUpdate == null)
                {
                    return;
                }

                if (scanQrUpdate.WillCancel)
                {
                    taskCompletionSource.SetResult(true);
                    taskCompletionSource = null;
                    scanner.Cancel();
                    return;
                }

                overlayView.SetDescriptionText(scanQrUpdate.UpdateMessage);
                position++;
                isScanningContinouslyExecuting = false;
            });
        }
Пример #4
0
        public static async Task <string> ScanQrCode(string message, string closeButtonTitle, bool tryInverted)
        {
            var scanner     = new QrCodeScanner();
            var overlayView = ScanQrOverlayView.Create(scanner);

            overlayView.SetCancelButtonText(closeButtonTitle);
            overlayView.SetDescriptionText(message);

            scanner.CustomOverlay = overlayView;

            var options = MobileBarcodeScanningOptions.Default;

            options.TryInverted = tryInverted;

            var result = await scanner.Scan(options);

            return(result?.Text);
        }
Пример #5
0
 public void SetScanner(QrCodeScanner scanner)
 {
     _scanner = scanner;
 }
Пример #6
0
 public QrCodeScanController(MobileBarcodeScanningOptions options, QrCodeScanner scanner)
 {
     ScanningOptions = options;
     Scanner         = scanner;
 }