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); }
public async void SetCaptureElement(CaptureElement captureElement) { if (_qrScanner != null) { return; } _qrScanner = new QrCodeScanner(captureElement); _qrScanner.CodeScanned += CodeScanned; await _qrScanner.StartAsync(); }
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; }); }
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); }
public void SetScanner(QrCodeScanner scanner) { _scanner = scanner; }
public QrCodeScanController(MobileBarcodeScanningOptions options, QrCodeScanner scanner) { ScanningOptions = options; Scanner = scanner; }