From a7adf98ff4ac801342853b1f9231cc1ab5acebf3 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 14 十一月 2019 17:25:42 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC
---
ZigbeeApp/GateWay.Ios/AppDelegate.cs | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/ZigbeeApp/GateWay.Ios/AppDelegate.cs b/ZigbeeApp/GateWay.Ios/AppDelegate.cs
index 71e2a0f..21a52c7 100755
--- a/ZigbeeApp/GateWay.Ios/AppDelegate.cs
+++ b/ZigbeeApp/GateWay.Ios/AppDelegate.cs
@@ -23,13 +23,15 @@
set;
}
+ internal static UINavigationController rootViewController;
+
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
- base.FinishedLaunching(application, launchOptions);
+ //base.FinishedLaunching(application, launchOptions);
Shared.Application.FontSize = 12;
Window = new UIWindow(UIScreen.MainScreen.Bounds);
- var root = new UINavigationController(new MainViewController()) { NavigationBarHidden = true };
- Window.RootViewController = root;
+ rootViewController = new UINavigationController(new MainViewController()) { NavigationBarHidden = true };
+ Window.RootViewController = rootViewController;
Window.MakeKeyAndVisible();
DeviceTokenAction += (deviceToken) =>
@@ -211,4 +213,49 @@
}
}
-
+namespace Shared
+{
+ public static class QRCode
+ {
+ static ZXing.Mobile.MobileBarcodeScanner scanner;
+ public static async System.Threading.Tasks.Task ScanQRcode(Action<string> action, string topText = "", string bottomText = "", string cancel = "Cancel")
+ {
+ if (scanner == null)
+ {
+ scanner = new ZXing.Mobile.MobileBarcodeScanner(GateWay.Ios.AppDelegate.rootViewController) { FlashButtonText = "", TopText = topText, BottomText = bottomText, CancelButtonText = cancel };
+ }
+
+ var result = await scanner.Scan();
+
+ if (result != null)
+ action?.Invoke(result.Text);
+ else
+ action?.Invoke(null);
+ }
+
+ public static byte[] BytesFromText(string text, int width = 300, int height = 300)
+ {
+ var barcodeWriter = new ZXing.Mobile.BarcodeWriter
+ {
+ Format = ZXing.BarcodeFormat.QR_CODE,
+ Options = new ZXing.Common.EncodingOptions
+ {
+ Width = width,
+ Height = height,
+ Margin = 10
+ }
+ };
+
+ barcodeWriter.Renderer = new ZXing.Mobile.BitmapRenderer();
+ var uiImage = barcodeWriter.Write(text);
+ var data = uiImage.AsJPEG();
+
+ var resultBytes = new byte[data.Length];
+ System.Runtime.InteropServices.Marshal.Copy(data.Bytes, resultBytes, 0, resultBytes.Length);
+
+ return resultBytes;
+ }
+ }
+}
+
+
--
Gitblit v1.8.0