using System;
|
using ZXing.Mobile;
|
using Shared;
|
|
namespace com.hdl.on
|
{
|
public static class Scan
|
{
|
public static void OpenScan (Action<string> action)
|
{
|
(Shared.Application.Activity as BaseActivity).SetCamera ((obj) => {
|
if (obj) {
|
var scanner = new MobileBarcodeScanner { };
|
// ZXing
|
scanner.UseCustomOverlay = false;
|
// 底部两个按钮文字
|
scanner.FlashButtonText = "";//"识别";
|
scanner.CancelButtonText = Language.CurrentLanguage == "Chinese" ? "取消" : "Cancel";
|
|
// 方框上,下方文字提示
|
scanner.TopText = Language.CurrentLanguage == "Chinese" ? "请将条形码对准方框内" : "Please align the bar code in the scan box";
|
scanner.BottomText = "";
|
|
// 延时三秒自动扫秒
|
var opt = new MobileBarcodeScanningOptions ();
|
opt.DelayBetweenContinuousScans = 3000;
|
scanner.ScanContinuously (opt, (obj2) => {
|
scanner.Cancel ();
|
action?.Invoke (obj2.Text);
|
});
|
}else{
|
action?.Invoke ("");
|
}
|
});
|
}
|
}
|
}
|