From 9a0b765c583bd69929de3a7495138b3e878e4543 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 05 九月 2023 16:14:27 +0800
Subject: [PATCH] 0-10v更新,网关在线状态更新
---
HDL-ON_iOS/Scan.cs | 109 +++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 75 insertions(+), 34 deletions(-)
diff --git a/HDL-ON_iOS/Scan.cs b/HDL-ON_iOS/Scan.cs
index 15d717d..8f159ad 100644
--- a/HDL-ON_iOS/Scan.cs
+++ b/HDL-ON_iOS/Scan.cs
@@ -2,62 +2,103 @@
using HDL_ON_iOS;
using Shared;
using ZXing.Mobile;
-
+using HDL.Shared.IOS.ScanQRCode;
namespace HDL_ON
{
public class Scan
{
- public static string TipMsg = "";
+ public string TipMsg = "";
public Scan()
{
}
+ private static Scan ins;
- static MobileBarcodeScanner scanner;
- public static async void OpenScan(Action<string> action)
+ public static Scan Ins
{
- string cancel = "鍙栨秷";
- string flashText = "";
- string titleText = "浜岀淮鐮佹壂鎻�";
- if (Language.CurrentLanguage != "Chinese")
+ get
{
- cancel = "Cancel";
- flashText = "";
- titleText = "Scan";
+ if (ins == null)
+ {
+ ins = new Scan();
+ }
+ return ins;
}
- 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();
-
+ void ScanResult(string result)
+ {
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