From 34754c8a599b1a9b4024b400eb6c64eab0488bab Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 02 八月 2023 14:08:34 +0800
Subject: [PATCH] 备份

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs |   85 ++++++++++++++++++------------------------
 1 files changed, 36 insertions(+), 49 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs
index 16705c7..5c17463 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs
@@ -23,6 +23,8 @@
         Function device;
         VideoDoorlockUser doorlockUser;
         public Action delCallBackAction;
+        public Action<string> updataUserNameAction;
+        Loading waitPage;
 
 
         public VideoDoorlockUserManagerPage(Function function,VideoDoorlockUser user)
@@ -31,11 +33,24 @@
             device = function;
             doorlockUser = user;
             BackgroundColor = CSS_Color.BackgroundColor;
-            
+            waitPage = new Loading();
+
+        }
+
+        public override void RemoveFromParent()
+        {
+            base.RemoveFromParent();
+            bodyView = null;
+            if (waitPage != null)
+            {
+                waitPage.RemoveFromParent();
+                waitPage = null;
+            }
         }
 
         public void LoadPage()
         {
+            bodyView.AddChidren(waitPage);
             new TopViewDiv(bodyView, Language.StringByID(StringId.UserManagement)).LoadTopView();
 
             contentView = new VerticalScrolViewLayout()
@@ -112,7 +127,7 @@
                     {
                         return;
                     }
-                    if (System.Text.Encoding.UTF8.GetBytes(str).Length > 20)
+                    if (System.Text.Encoding.Unicode.GetBytes(str).Length > 20)
                     {
                         new Tip()
                         {
@@ -122,19 +137,20 @@
                         }.Show(bodyView);
                         return;
                     }
-                    var waitPage = new Loading();
-                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
-                    bodyView.AddChidren(waitPage);
                     new System.Threading.Thread(() =>
                     {
                         try
                         {
+                            Application.RunOnMainThread(() => {
+                                waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                            });
                             var pack = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId, str);
                             if (pack.Code == StateCode.SUCCESS)
                             {
                                 Application.RunOnMainThread(() =>
                                 {
                                     btnUserName.Text = str;
+                                    updataUserNameAction?.Invoke(str);
                                 });
                             }
                             else
@@ -168,11 +184,6 @@
                             Application.RunOnMainThread(() =>
                             {
                                 waitPage.Hide();
-                                if(waitPage!= null)
-                                {
-                                    waitPage.RemoveFromParent();
-                                    waitPage = null;
-                                }
                             });
                         }
                     })
@@ -337,13 +348,13 @@
                     fingerprintView.AddChidren(btnClearFingerprints);
                     btnClearFingerprints.MouseUpEventHandler = (sender, e) =>
                     {
-                        var waitPage = new Loading();
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
-                    bodyView.AddChidren(waitPage);
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserFingerPassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -380,11 +391,6 @@
                                 Application.RunOnMainThread(() =>
                                 {
                                     waitPage.Hide();
-                                    if (waitPage != null)
-                                    {
-                                        waitPage.RemoveFromParent();
-                                        waitPage = null;
-                                    }
                                 });
                             }
                         })
@@ -454,13 +460,13 @@
                     digitalPasswordView.AddChidren(btnClearDigitalPassword);
                     btnClearDigitalPassword.MouseUpEventHandler = (sender, e) =>
                     {
-                        var waitPage = new Loading();
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
-                    bodyView.AddChidren(waitPage);
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserNumberPassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -497,11 +503,6 @@
                                 Application.RunOnMainThread(() =>
                                 {
                                     waitPage.Hide();
-                                    if (waitPage != null)
-                                    {
-                                        waitPage.RemoveFromParent();
-                                        waitPage = null;
-                                    }
                                 });
                             }
                         })
@@ -570,13 +571,13 @@
                     };
                     nfcView.AddChidren(btnClearNfc);
                     btnClearNfc.MouseUpEventHandler = (sender, e) => {
-                        var waitPage = new Loading();
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
-                    bodyView.AddChidren(waitPage);
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserCardPassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -612,11 +613,6 @@
                                 Application.RunOnMainThread(() =>
                                 {
                                     waitPage.Hide();
-                                    if (waitPage != null)
-                                    {
-                                        waitPage.RemoveFromParent();
-                                        waitPage = null;
-                                    }
                                 });
                             }
                         })
@@ -685,13 +681,13 @@
                     };
                     faceView.AddChidren(btnClearFace);
                     btnClearFace.MouseUpEventHandler = (sender, e) => {
-                        var waitPage = new Loading();
-                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
-                    bodyView.AddChidren(waitPage);
                         new System.Threading.Thread(() =>
                         {
                             try
                             {
+                                Application.RunOnMainThread(() => {
+                                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                                });
                                 var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUserFacePassword(device.deviceId, doorlockUser.lockUserIndex);
                                 if (pack != null && pack.Code == StateCode.SUCCESS)
                                 {
@@ -727,11 +723,6 @@
                                 Application.RunOnMainThread(() =>
                                 {
                                     waitPage.Hide();
-                                    if (waitPage != null)
-                                    {
-                                        waitPage.RemoveFromParent();
-                                        waitPage = null;
-                                    }
                                 });
                             }
                         })
@@ -772,12 +763,13 @@
             {
                 new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DeleteDoorlockUserTip, () =>
                 {
-                    var waitPage = new Loading();
-                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                     new System.Threading.Thread(() =>
                     {
                         try
                         {
+                            Application.RunOnMainThread(() => {
+                                waitPage.Start(Language.StringByID(StringId.PleaseWait));
+                            });
                             var pack = ApiUtlis.Ins.HttpRequest.DeleteDoorlockUser(device.deviceId, doorlockUser.lockUserIndex);
                             if (pack != null && pack.Code == StateCode.SUCCESS)
                             {
@@ -818,11 +810,6 @@
                             Application.RunOnMainThread(() =>
                             {
                                 waitPage.Hide();
-                                if (waitPage != null)
-                                {
-                                    waitPage.RemoveFromParent();
-                                    waitPage = null;
-                                }
                             });
                         }
                     })

--
Gitblit v1.8.0