From 3e4e108d0c6317edb18bbf9c41419fd6d6a0eebb Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 28 十一月 2019 17:53:10 +0800 Subject: [PATCH] 2019-11-28-2 --- ZigbeeApp/GateWay.Ios/AppDelegate.cs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 52 insertions(+), 4 deletions(-) diff --git a/ZigbeeApp/GateWay.Ios/AppDelegate.cs b/ZigbeeApp/GateWay.Ios/AppDelegate.cs old mode 100755 new mode 100644 index 71e2a0f..c22056e --- 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) => @@ -74,6 +76,7 @@ } } AppCenter.Start("0ca801a2-742b-42fb-ba10-7ba4391371aa", typeof(Analytics), typeof(Crashes)); + GDMapKit.setGDApiKey("866fae25f336bc8d9a79b1d19267fffb");//楂樺痉鍦板浘key return true; } @@ -211,4 +214,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