コード例 #1
0
		public async Task<BarCodeResult> Read(BarCodeReadConfiguration config, CancellationToken cancelToken) {
			config = config ?? BarCodeReadConfiguration.Default;
            var scanner = this.GetInstance();
			cancelToken.Register(scanner.Cancel);
            scanner.BottomText = config.BottomText ?? scanner.BottomText;
            scanner.CancelButtonText = config.CancelText ?? scanner.CancelButtonText;
            scanner.FlashButtonText = config.FlashlightText ?? scanner.FlashButtonText;
            scanner.TopText = config.TopText ?? scanner.TopText;

            var result = await scanner.Scan(this.GetXingConfig(config));
            return (result == null || String.IsNullOrWhiteSpace(result.Text)
                ? BarCodeResult.Fail
                : new BarCodeResult(result.Text, FromXingFormat(result.BarcodeFormat))
            );
        }
コード例 #2
0
        public async Task <BarCodeResult> Read(BarCodeReadConfiguration config, CancellationToken cancelToken)
        {
            config = config ?? BarCodeReadConfiguration.Default;
            var scanner = this.GetInstance();

            cancelToken.Register(scanner.Cancel);
            scanner.BottomText       = config.BottomText ?? scanner.BottomText;
            scanner.CancelButtonText = config.CancelText ?? scanner.CancelButtonText;
            scanner.FlashButtonText  = config.FlashlightText ?? scanner.FlashButtonText;
            scanner.TopText          = config.TopText ?? scanner.TopText;

            var result = await scanner.Scan(this.GetXingConfig(config));

            return(result == null || String.IsNullOrWhiteSpace(result.Text)
                ? BarCodeResult.Fail
                : new BarCodeResult(result.Text, FromXingFormat(result.BarcodeFormat))
                   );
        }
コード例 #3
0
		private MobileBarcodeScanningOptions GetXingConfig(BarCodeReadConfiguration cfg) {
            var opts = new MobileBarcodeScanningOptions {
                AutoRotate = cfg.AutoRotate,
                CharacterSet = cfg.CharacterSet,
                DelayBetweenAnalyzingFrames = cfg.DelayBetweenAnalyzingFrames,
                InitialDelayBeforeAnalyzingFrames = cfg.InitialDelayBeforeAnalyzingFrames,
                PureBarcode = cfg.PureBarcode,
                TryHarder = cfg.TryHarder,
                TryInverted = cfg.TryInverted,
                UseFrontCameraIfAvailable = cfg.UseFrontCameraIfAvailable
            };

            if (cfg.Formats != null && cfg.Formats.Count > 0) {
                opts.PossibleFormats = cfg.Formats
                    .Select(x => (BarcodeFormat)(int)x)
                    .ToList();
            }
            return opts;
        }
コード例 #4
0
        private MobileBarcodeScanningOptions GetXingConfig(BarCodeReadConfiguration cfg)
        {
            var opts = new MobileBarcodeScanningOptions {
                AutoRotate   = cfg.AutoRotate,
                CharacterSet = cfg.CharacterSet,
                DelayBetweenAnalyzingFrames       = cfg.DelayBetweenAnalyzingFrames,
                InitialDelayBeforeAnalyzingFrames = cfg.InitialDelayBeforeAnalyzingFrames,
                PureBarcode = cfg.PureBarcode,
                TryHarder   = cfg.TryHarder,
                TryInverted = cfg.TryInverted,
                UseFrontCameraIfAvailable = cfg.UseFrontCameraIfAvailable
            };

            if (cfg.Formats != null && cfg.Formats.Count > 0)
            {
                opts.PossibleFormats = cfg.Formats
                                       .Select(x => (BarcodeFormat)(int)x)
                                       .ToList();
            }
            return(opts);
        }