示例#1
0
 public override void ScanningOptionsUpdate(ScanningOptionsBase options)
 {
     if (options is ZXingOptions zOpt)
     {
         if (zOpt.TryHarder.HasValue)
         {
             _reader.Options.TryHarder = zOpt.TryHarder.Value;
         }
         if (zOpt.PureBarcode.HasValue)
         {
             _reader.Options.PureBarcode = zOpt.PureBarcode.Value;
         }
         if (zOpt.AutoRotate.HasValue)
         {
             _reader.AutoRotate = zOpt.AutoRotate.Value;
         }
         if (zOpt.UseCode39ExtendedMode.HasValue)
         {
             _reader.Options.UseCode39ExtendedMode = zOpt.UseCode39ExtendedMode.Value;
         }
         if (!string.IsNullOrEmpty(zOpt.CharacterSet))
         {
             _reader.Options.CharacterSet = zOpt.CharacterSet;
         }
         if (zOpt.TryInverted.HasValue)
         {
             _reader.TryInverted = zOpt.TryInverted.Value;
         }
         if (zOpt.AssumeGS1.HasValue)
         {
             _reader.Options.AssumeGS1 = zOpt.AssumeGS1.Value;
         }
     }
 }
示例#2
0
 public virtual void SetScannerOptions(ScanningOptionsBase value)
 {
     if (value == null)
     {
         return;
     }
     _scanningOptions = value;
     Decoder.ScanningOptionsUpdate(value);
 }
示例#3
0
        public void StartScanning(Action <IScanResult> scanResultCallback, ScanningOptionsBase options = null)
        {
            //fix Android 7 bug: camera freezes because surfacedestroyed function isn't always called correct, the old surfaceview was still visible.
            this.Visibility = ViewStates.Visible;

            CameraPreviewSettings.Instance.SetScannerOptions(options);

            CameraAnalyzer.ResultFound += (sender, result) => { scanResultCallback?.Invoke(result); };
            CameraAnalyzer.ResumeAnalysis();
        }
        async void Default_Vision_Clicked(object sender, System.EventArgs e)
        {
            if (!await CheckCameraPermisstions())
            {
                return;
            }
            var options = new ScanningOptionsBase();

            scanPage = new ScannerPage(options, null);

            await Navigation.PushAsync(scanPage);
        }
示例#5
0
        public void StartScanning(Action <IScanResult> scanResultHandler, ScanningOptionsBase options = null)
        {
            if (!stopped)
            {
                return;
            }

            stopped = false;

            var perf = PerformanceCounter.Start();

            Setup(this.Frame);

            CameraPreviewSettings.Instance.SetScannerOptions(options);
            this.resultCallback = scanResultHandler;

            Logger.Log("StartScanning");

            this.InvokeOnMainThread(() =>
            {
                if (!SetupCaptureSession())
                {
                    //Setup 'simulated' view:
                    Logger.Log("Capture Session FAILED");
                }

                if (Runtime.Arch == Arch.SIMULATOR)
                {
                    var simView              = new UIView(new CGRect(0, 0, this.Frame.Width, this.Frame.Height));
                    simView.BackgroundColor  = UIColor.LightGray;
                    simView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                    this.InsertSubview(simView, 0);
                }
            });

            if (!analyzing)
            {
                analyzing = true;
            }

            PerformanceCounter.Stop(perf, "PERF: StartScanning() Took {0} ms.");

            var evt = this.OnScannerSetupComplete;

            if (evt != null)
            {
                evt();
            }
        }
示例#6
0
        public ScannerPage(ScanningOptionsBase options = null, View customOverlay = null) : base()
        {
            _scannerView = new ScannerView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Options           = options,
            };

            _scannerView.SetBinding(ScannerView.IsAnalyzingProperty, new Binding(nameof(IsAnalyzing)));
            _scannerView.SetBinding(ScannerView.IsScanningProperty, new Binding(nameof(IsScanning)));
            _scannerView.SetBinding(ScannerView.ResultProperty, new Binding(nameof(Result)));

            _scannerView.OnScanResult += (result) =>
            {
                this.OnScanResult?.Invoke(result);
            };



            var grid = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            grid.Children.Add(_scannerView);

            if (customOverlay != null)
            {
                Overlay = customOverlay;
                grid.Children.Add(Overlay);
            }

            // The root page of your application
            Content = grid;
        }
示例#7
0
 public virtual void ScanningOptionsUpdate(ScanningOptionsBase options)
 {
 }