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)) ); }
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)) ); }
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; }
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); }