From fd1f19e8479c764fa28b0da3a2f9b34a3debe772 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 03 八月 2023 21:47:04 +0800
Subject: [PATCH] 2023年08月03日21:47:02
---
HDL-ON_iOS/Scan.cs | 101 ++++++++++++++++++++++++++++++++------------------
1 files changed, 64 insertions(+), 37 deletions(-)
diff --git a/HDL-ON_iOS/Scan.cs b/HDL-ON_iOS/Scan.cs
index 9bc60b9..8f159ad 100644
--- a/HDL-ON_iOS/Scan.cs
+++ b/HDL-ON_iOS/Scan.cs
@@ -2,7 +2,7 @@
using HDL_ON_iOS;
using Shared;
using ZXing.Mobile;
-
+using HDL.Shared.IOS.ScanQRCode;
namespace HDL_ON
{
public class Scan
@@ -27,51 +27,78 @@
}
- static MobileBarcodeScanner scanner;
- public async void OpenScan(Action<string> action)
+ void ScanResult(string result)
{
- string cancel = "鍙栨秷";
- string flashText = "";
- string titleText = "浜岀淮鐮佹壂鎻�";
- if (Language.CurrentLanguage != "Chinese")
- {
- cancel = "Cancel";
- flashText = "";
- titleText = "Scan";
- }
-
- if (scanner == null)
- {
- var mZXingOverlayView = new ZXingOverlayView(cancel, flashText, titleText);
- scanner = new MobileBarcodeScanner(AppDelegate.rootViewController) { FlashButtonText = flashText, TopText = titleText, BottomText = "", CancelButtonText = cancel };
- scanner.UseCustomOverlay = true;
-
- scanner.CustomOverlay = mZXingOverlayView;
- var bOn = false;
- mZXingOverlayView.OnCancel += () =>
- {
- scanner?.Cancel();
- };
-
- mZXingOverlayView.OnTorch += () =>
- {
- bOn = !bOn;
- scanner?.Torch(bOn);
- };
-
- }
-
- var result = await scanner.Scan();
-
if (result != null)
{
- action?.Invoke(result.Text);
+ action?.Invoke(result);
}
else
{
action?.Invoke(null);
Console.WriteLine("浜岀淮鐮佽繑鍥炲�间负null");
}
+
+ }
+
+ static MobileBarcodeScanner scanner;
+
+
+ Action<string> action;
+
+ public void OpenScan(Action<string> action)
+ {
+ this.action = action;
+
+ string cancel = "鍙栨秷";
+ //string flashText = "";
+ string titleText = "浜岀淮鐮佹壂鎻�";
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ cancel = "Cancel";
+ //flashText = "";
+ titleText = "Scan";
+ }
+ var d1 = new HDLQRCodeScanFinish(ScanResult);
+ HDL.Shared.IOS.ScanQRCode.HDLScanQRCodeSDK.SharedInstance().ScanQRCodeWith(cancel, titleText, d1);
+
+
+
+ //if (scanner == null)
+ //{
+ // var mZXingOverlayView = new ZXingOverlayView(cancel, flashText, titleText);
+ // scanner = new MobileBarcodeScanner(AppDelegate.rootViewController) { FlashButtonText = flashText, TopText = titleText, BottomText = "", CancelButtonText = cancel };
+ // scanner.UseCustomOverlay = true;
+
+ // scanner.CustomOverlay = mZXingOverlayView;
+ // var bOn = false;
+ // mZXingOverlayView.OnCancel += () =>
+ // {
+ // scanner?.Cancel();
+ // };
+
+ // mZXingOverlayView.OnTorch += () =>
+ // {
+ // bOn = !bOn;
+ // scanner?.Torch(bOn);
+ // };
+
+ //}
+
+ //var result = await scanner.Scan();
+
+ //if (result != null)
+ //{
+ // action?.Invoke(result.Text);
+ //}
+ //else
+ //{
+ // action?.Invoke(null);
+ // Console.WriteLine("浜岀淮鐮佽繑鍥炲�间负null");
+ //}
+
+
+
}
public static byte[] BytesFromText(string text, int width = 300, int height = 300)
--
Gitblit v1.8.0