Ejemplo n.º 1
0
        protected override void OnElementChanged(ElementChangedEventArgs <ScannerView> e)
        {
            base.OnElementChanged(e);
            FormsView = Element;

            if (PlatformView == null)
            {
                PlatformView = new CPSurfaceView(this.Context)
                {
                    LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                };
                _cameraAnalyzer = PlatformView.CameraAnalyzer;

                PlatformView.SurfaceTextureAvailable   += NativeSurface_SurfaceTextureAvailable;
                PlatformView.SurfaceTextureDestroyed   += NativeSurface_SurfaceTextureDestroyed;
                PlatformView.SurfaceTextureSizeChanged += NativeSurface_SurfaceTextureSizeChanged;
                base.SetNativeControl(PlatformView);

                if (FormsView.IsScanning)
                {
                    PlatformView.StartScanning(FormsView.RaiseScanResult, FormsView.Options);
                }

                if (!FormsView.IsAnalyzing)
                {
                    PlatformView.PauseAnalysis();
                }
            }
        }
Ejemplo n.º 2
0
        private void Init()
        {
            if (_cameraAnalyzer == null)
            {
                _cameraAnalyzer = new CameraAnalyzer(this);
            }

            _cameraAnalyzer.ResumeAnalysis();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 4
0
 public void ResumeAnalysis()
 {
     CameraAnalyzer.ResumeAnalysis();
 }
Ejemplo n.º 5
0
 public void PauseAnalysis()
 {
     CameraAnalyzer.PauseAnalysis();
 }
Ejemplo n.º 6
0
 public void StopScanning()
 {
     CameraAnalyzer.ShutdownCamera();
     //fix Android 7 bug: camera freezes because surfacedestroyed function isn't always called correct, the old surfaceview was still visible.
     this.Visibility = ViewStates.Gone;
 }