Exemple #1
0
        public override void ViewDidAppear(bool animated)
        {
            _scannerView.OnScannerSetupComplete += HandleOnScannerSetupComplete;

            _originalStatusBarStyle = UIApplication.SharedApplication.StatusBarStyle;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.Default;
                SetNeedsStatusBarAppearanceUpdate();
            }
            else
            {
                UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.BlackTranslucent, false);
            }
            Task.Factory.StartNew(() =>
            {
                BeginInvokeOnMainThread(() => _scannerView.StartScanning(result => {
                    Console.WriteLine(result);
                    if (!ContinuousScanning)
                    {
                        _scannerView.StopScanning();
                    }

                    var evt = OnScannedResult;
                    evt?.Invoke(result);
                }, ScanningOptions));
            });
        }
        /// <summary>
        /// Method to handle DONE button click event
        /// </summary>
        private void BtnDone_TouchUpInside(object sender, EventArgs e)
        {
            if (txtContactNumber != null)
            {
                scannerView.StopScanning();

                if (txtContactNumber != null)
                {
                    this.OnScannedResult?.Invoke(new ZXing.Result(txtContactNumber.Text.Trim(), null, null, ZXing.BarcodeFormat.QR_CODE));
                }
                else
                {
                    this.OnScannedResult?.Invoke(new ZXing.Result(string.Empty, null, null, ZXing.BarcodeFormat.QR_CODE));
                }
            }
        }
Exemple #3
0
 public override void ViewDidDisappear(bool animated)
 {
     _scannerView?.StopScanning();
     if (_scannerView != null)
     {
         _scannerView.OnScannerSetupComplete -= HandleOnScannerSetupComplete;
     }
 }