public void StartScanning(Action<ZXing.Result> scanCallback, MobileBarcodeScanningOptions options = null)
        {
            ScanCallback = scanCallback;
            ScanningOptions = options ?? MobileBarcodeScanningOptions.Default;

            this.topText.Text = TopText;
            this.bottomText.Text = BottomText;

            if (UseCustomOverlay && CustomOverlay != null)
            {
                gridCustomOverlay.Children.Clear();
                gridCustomOverlay.Children.Add(CustomOverlay);

                gridCustomOverlay.Visibility = Visibility.Visible;
                gridDefaultOverlay.Visibility = Visibility.Collapsed;
            }
            else
            {
                gridCustomOverlay.Visibility = Visibility.Collapsed;
                gridDefaultOverlay.Visibility = Visibility.Visible;
            }

            MobileBarcodeScanner.Log("ZXingScannerControl.StartScanning");

            // Initialize a new instance of SimpleCameraReader with Auto-Focus mode on
            if (_reader == null)
            {
                MobileBarcodeScanner.Log("Creating SimpleCameraReader");

                _reader = new SimpleCameraReader(options);
                _reader.ScanInterval = ScanningOptions.DelayBetweenAnalyzingFrames;

                // We need to set the VideoBrush we're going to display the preview feed on
                // IMPORTANT that it gets set before Camera initializes
                _previewVideo.SetSource(_reader.Camera);

                // The reader throws an event when a result is available 
                _reader.DecodingCompleted += (o, r) => DisplayResult(r);

                // The reader throws an event when the camera is initialized and ready to use
                _reader.CameraInitialized += ReaderOnCameraInitialized;
            }
        }
        public void StopScanning()
        {
            gridCustomOverlay.Children.Remove(CustomOverlay);
            _reader.Stop();
			_reader = null;
        }
        public void StopScanning()
        {
            if (UseCustomOverlay && CustomOverlay != null)
                gridCustomOverlay.Children.Remove(CustomOverlay);

            _reader.Stop();
			_reader = null;
        }
        public void StopScanning()
        {
            _reader.Stop();
			_reader = null;
        }
Example #5
0
		protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.topText.Text = TopText;
            this.bottomText.Text = BottomText;

            if (UseCustomOverlay && CustomOverlay != null)
            {
               this.gridCustomOverlay.Children.Add(CustomOverlay);
    
                this.gridCustomOverlay.Visibility = System.Windows.Visibility.Visible;
                this.gridDefaultOverlay.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                //this.gridCustomOverlay.Children.Clear();
                this.gridCustomOverlay.Visibility = System.Windows.Visibility.Collapsed;
                this.gridDefaultOverlay.Visibility = System.Windows.Visibility.Visible;
            }

            // Initialize a new instance of SimpleCameraReader with Auto-Focus mode on
            _reader = new SimpleCameraReader(Scanner, ScanningOptions);
			_reader.ScanInterval = ScanningOptions.DelayBetweenAnalyzingFrames;

            OnRequestAutoFocus += () =>
            {
                _reader.Camera.Focus();
            };

            OnRequestTorch += (on) =>
            {
                if (on)
                    _reader.Camera.FlashMode = FlashMode.On;
                else
                    _reader.Camera.FlashMode = FlashMode.Auto;
            };

            OnRequestToggleTorch += () => {
                if (_reader.Camera.FlashMode == FlashMode.On)
                    _reader.Camera.FlashMode = FlashMode.Auto;
                else
                    _reader.Camera.FlashMode = FlashMode.On;
            };

            OnRequestCancel += () => {
                LastScanResult = null;

                _reader.Stop();

                Finish(); 
            };

            OnRequestIsTorchOn += () => {
                return _reader.Camera.FlashMode == FlashMode.On;
            };
            // We need to set the VideoBrush we're going to display the preview feed on
            // IMPORTANT that it gets set before Camera initializes
            //a   _previewVideo.SetSource((CaptureSource)_reader.Camera);

	        //		_reader.ScanOnAutoFocus = false;
			
			_previewVideo.SetSource(_reader.Camera);

			 
            // The reader throws an event when a result is available 
            _reader.DecodingCompleted += (o, r) => DisplayResult(r);

            // The reader throws an event when the camera is initialized and ready to use
            _reader.CameraInitialized += ReaderOnCameraInitialized;

            base.OnNavigatedTo(e);


        }
 public void StopScanning()
 {
     _reader.Stop();
     _reader = null;
 }