From 4cf5bc1b5f954646e006c7e491c4b20657409567 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 13 六月 2023 13:30:30 +0800
Subject: [PATCH] 本地加密秘钥写入

---
 Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountView.cs |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountView.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountView.cs
index 1f481e5..a6bc6ef 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountView.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountView.cs
@@ -170,6 +170,77 @@
             };
             contentView.AddChidren (btnModifyNullLine);
             #endregion
+
+
+            #region LocalEncryption
+            var LocalEncryptionView = new FrameLayout () {
+                Height = Application.GetRealHeight (100),
+            };
+            contentView.AddChidren (LocalEncryptionView);
+
+            Button btnLocalEncryptionTitle = new Button () {
+                X = Application.GetRealWidth (40),
+                Text = "Set local encryption",
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = SkinStyle.Current.TextColor1,
+            };
+            LocalEncryptionView.AddChidren (btnLocalEncryptionTitle);
+
+            Button btnLocalEncryptionRight = new Button () {
+                X = Application.GetRealWidth (580),
+                Width = Application.GetRealWidth (28),
+                Height = Application.GetRealHeight (40),
+                Gravity = Gravity.CenterVertical,
+                UnSelectedImagePath = "Item/Right.png",
+                SelectedImagePath = "Item/RightSelected.png",
+            };
+            LocalEncryptionView.AddChidren (btnLocalEncryptionRight);
+
+            EventHandler<MouseEventArgs> localEncryptionHandler = (sender, e) => {
+
+                var waitPage = new Loading ();
+                this.AddChidren (waitPage);
+                waitPage.Start ("wait...");
+                new System.Threading.Thread (() => {
+                    try {
+                        byte [] AseKeyBytes = UserConfig.Instance.GenerateLocalEncryptionKey ();
+                        byte [] sendBytes = new byte [17];
+                        sendBytes [0] = (byte)1; //0:涓嶅姞瀵� 1:鍔犲瘑
+                        Array.Copy (AseKeyBytes, 0, sendBytes, 1, 16);
+
+                        UserConfig.Instance.IsLocalEncrypt = false;
+                        var control = new Control ();
+                        control.Send (new Target () {
+                            IPEndPoint = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000),
+                            Command = Command.SetGateWayLocalEncryption,
+                            SubnetID = 255,
+                            DeviceID = 0,
+                            AddData = sendBytes
+                        }, SendCount.Three, true, true);
+                        var backBytes = control.UsefulBytes;
+                    }catch(Exception ex) {
+
+                    } finally {
+                        Application.RunOnMainThread (() => {
+                            waitPage.Hide ();
+                        });
+                    }
+                }) { IsBackground = true }.Start ();
+            };
+            LocalEncryptionView.MouseUpEventHandler += localEncryptionHandler;
+            btnLocalEncryptionTitle.MouseUpEventHandler += localEncryptionHandler;
+            btnModifyPasswordRight.MouseUpEventHandler += localEncryptionHandler;
+
+            Button btnLocalEncryptionLine = new Button () {
+                Height = Application.GetRealHeight (5),
+                BackgroundColor = SkinStyle.Current.MainColor,
+            };
+            contentView.AddChidren (btnLocalEncryptionLine);
+            #endregion
+
+
+
+
             Button btnLogout = new Button () {
                 Y = contentView.Bottom,
                 Height = Application.GetRealHeight (93),

--
Gitblit v1.8.0