From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs |  497 ++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 290 insertions(+), 207 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs
index b392c11..b261f23 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TemporaryPassword.cs
@@ -6,7 +6,7 @@
 
 namespace Shared.Phone.UserCenter.DoorLock
 {
-    public class TemporaryPassword : DoorLockCommonLayout, ZigBee.Common.IStatus
+    public class TemporaryPassword : DoorLockCommonLayout
     {
         /// <summary>
         /// 鏋勯�犲嚱鏁�
@@ -16,17 +16,40 @@
         {
             this.doorLock = doorLock;
             BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
-            ZigBee.Device.ZbGateway.StatusList.Add(this);
         }
 
-        #region 鈼� 鍙橀噺鐢虫槑__________________________
+        #region  鍙橀噺鐢虫槑
+        /// <summary>
+        /// 褰撳墠闂ㄩ攣
+        /// </summary>
         ZigBee.Device.DoorLock doorLock;
-        public System.Collections.Generic.List<Button> pawButtonList = new System.Collections.Generic.List<Button> { };//涓存椂瀵嗙爜涓殑6浣嶆暟瀛�
-        Button passwordText; //涓存椂瀵嗙爜
+        /// <summary>
+        /// 涓存椂瀵嗙爜涓殑6浣嶆暟瀛�
+        /// </summary>
+        public System.Collections.Generic.List<Button> pawButtonList = new System.Collections.Generic.List<Button> { };
+        /// <summary>
+        /// 涓存椂瀵嗙爜
+        /// </summary>
+        Button passwordText;
+        /// <summary>
+        /// 涓儴甯冪殑椤堕儴甯冨眬
+        /// </summary>
         FrameLayout MidTopFrameLayout;
-        Action<string, string> action;//鎺ユ敹閫氱煡
+        /// <summary>
+        /// 鎺ユ敹閫氱煡
+        /// </summary>
+        Action<string, string> action;
+        /// <summary>
+        /// 淇濆瓨瀹屾垚鎸夐挳
+        /// </summary>
         Button btnFinifh;
+        /// <summary>
+        /// 褰撳墠鏈夋晥鏃ユ湡鏃堕棿
+        /// </summary>
         DateTime cunVDateTime;
+        /// <summary>
+        /// 褰撳墠澶辨晥鏃ユ湡鏃堕棿
+        /// </summary>
         DateTime cunIVDateTime;
         #endregion
 
@@ -68,86 +91,15 @@
 
             EventHandler<MouseEventArgs> eHandler = (sender, e) =>
             {
-                var dialog = new Dialog { };
-                dialog.Show();
-
-                var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
-                dialog.AddChidren(flMain);
-                flMain.MouseUpEventHandler += (sender11, e11) =>
-                {
-                    dialog.Close();
-                };
-
-                var delBackgroundFrameLayout = new FrameLayout
-                {
-                    X = Application.GetRealWidth(596),
-                    Y = Application.GetRealHeight(164),
-                    Height = Application.GetRealHeight(173),
-                    Width = Application.GetRealWidth(449),
-                    BackgroundImagePath = "DoorLock/DelBackground.png",
-                };
-                flMain.AddChidren(delBackgroundFrameLayout);
-
-                var btnDelIcon2 = new Button
-                {
-                    Height = Application.GetRealHeight(81),
-                    Width = Application.GetRealWidth(81),
-                    X = Application.GetRealWidth(81),
-                    Y = Application.GetRealHeight(55),
-                    UnSelectedImagePath = "DoorLock/DelIcon.png",
-                };
-                delBackgroundFrameLayout.AddChidren(btnDelIcon2);
-
-                var btnDelText = new Button
-                {
-                    Height = Application.GetRealHeight(58),
-                    Width = Application.GetRealWidth(311),
-                    X = Application.GetRealWidth(173),
-                    Y = Application.GetRealHeight(69),
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Text = Language.StringByID(R.MyInternationalizationString.ClearTempPassword),
-                    TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
-                    TextSize = 12,
-                };
-                delBackgroundFrameLayout.AddChidren(btnDelText);
-
-                EventHandler<MouseEventArgs> eHandler2 = (sender2, e2) =>
-                {
-                    var dialog1 = new Dialog { };
-                    var doorDialog = new Shared.Phone.UserCenter.DoorLock.DoorlockDialog(dialog1, Language.StringByID(R.MyInternationalizationString.Tip));
-                    doorDialog.Show();
-                    doorDialog.dialogMidFraFrameLayout.Width = Application.GetRealWidth(415);
-                    doorDialog.dialogMidFraFrameLayout.Height = Application.GetRealHeight(58);
-                    doorDialog.dialogMidFraFrameLayout.X = Application.GetRealWidth(190);
-                    doorDialog.dialogMidFraFrameLayout.Y = Application.GetRealHeight(202);
-                    doorDialog.dialogMidFraFrameLayout.AddChidren(doorDialog.dialogMidText);
-                    doorDialog.dialogMidText.Text = Language.StringByID(R.MyInternationalizationString.SureToDeleteTempPassword);
-                    doorDialog.dialogMidText.TextSize = 14;
-                    doorDialog.dialogMidFraFrameLayout.AddChidren(doorDialog.dialogMidText);
-                    doorDialog.dialogBtnConfirm.Text = Language.StringByID(R.MyInternationalizationString.Confrim);
-                    doorDialog.dialogBtnCancel.MouseUpEventHandler += (sender1, e1) =>
-                    {
-                        dialog.Close();
-                        dialog1.Close();
-                    };
-                    doorDialog.dialogBtnConfirm.MouseUpEventHandler += (sender1, e1) =>
-                    {
-                        dialog.Close();
-                        dialog1.Close();
-                        ClearEventHandler(btnDelText, dialog1);
-                    };
-                };
-                delBackgroundFrameLayout.MouseDownEventHandler += eHandler2;
-                btnDelIcon2.MouseDownEventHandler += eHandler2;
-                btnDelText.MouseDownEventHandler += eHandler2;
+                ClearDialog();
             };
             btnDelFrameLayout.MouseDownEventHandler += eHandler;
             btnDelIcon.MouseDownEventHandler += eHandler;
-            #endregion 
+            #endregion
             MidTopFrameLayout = new FrameLayout()
             {
-                X = Application.GetRealWidth(181),
-                Y = Application.GetRealHeight(92),
+                X = Application.GetMinRealAverage(181),
+                Y = Application.GetMinRealAverage(92),
                 Width = Application.GetRealWidth(717),
                 Height = Application.GetRealHeight(570),
                 BackgroundImagePath = "DoorLock/TempPasswordBackground.png",
@@ -156,6 +108,9 @@
             MidFrameLayoutContent();
         }
 
+        /// <summary>
+        /// 涓儴甯冨眬
+        /// </summary>
         public void MidFrameLayoutContent()
         {
             MidTopFrameLayout.RemoveAll();
@@ -163,7 +118,7 @@
             {
                 Height = Application.GetRealHeight(43),
                 Width = Application.GetRealWidth(259),
-                X = Application.GetRealWidth(230),
+                X = Application.GetRealWidth(227),
                 Y = Application.GetRealHeight(418),
                 UnSelectedImagePath = "DoorLock/TempPasswordBackground1.png",
             };
@@ -181,7 +136,7 @@
                 Y = Application.GetRealHeight(48),
                 TextAlignment = TextAlignment.Center,
                 Text = Language.StringByID(R.MyInternationalizationString.ClickGenerate),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                 TextSize = 12,
                 Visible = true,
                 Enable = true,
@@ -190,11 +145,9 @@
 
             var randomPassword = new EditText()
             {
-                X = Application.GetRealWidth(233),
                 Y = Application.GetRealHeight(153),
                 Height = Application.GetRealHeight(84),
-                Width = Application.GetRealWidth(251),
-                TextAlignment = TextAlignment.CenterRight,
+                TextAlignment = TextAlignment.Center,
                 TextSize = 24,
                 SecureTextEntry = false,
                 Enable = false,
@@ -215,47 +168,48 @@
             var validTime = new Button()
             {
                 Height = Application.GetRealHeight(55),
-                Width = Application.GetRealWidth(115),
-                X = Application.GetRealWidth(92),
+                Width = Application.GetRealWidth(207),
                 Y = Application.GetRealHeight(386),
                 TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
-                TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 14,
+                TextAlignment = TextAlignment.CenterRight,
+                TextSize = 16,
+                Text = "--:--", 
             };
             MidTopFrameLayout.AddChidren(validTime);
 
             var validTimeDate = new Button()
             {
                 Height = Application.GetRealHeight(49),
-                Width = Application.GetRealWidth(135),
-                X = Application.GetRealWidth(84),
+                Width = Application.GetRealWidth(208),
                 Y = Application.GetRealHeight(441),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
-                TextSize = 10,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
+                TextSize = 12,
+                TextAlignment = TextAlignment.CenterRight, 
             };
             MidTopFrameLayout.AddChidren(validTimeDate);
 
             var inValidTime = new Button()
             {
                 Height = Application.GetRealHeight(55),
-                Width = Application.GetRealWidth(118),
+                Width = Application.GetRealWidth(717 - 507),
                 X = Application.GetRealWidth(507),
-                Y = Application.GetRealHeight(389),
+                Y = Application.GetRealHeight(386),
                 TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
                 TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 14,
+                TextSize = 16,
+                Text = "--:--", 
             };
             MidTopFrameLayout.AddChidren(inValidTime);
 
             var inValidTimeDate = new Button()
             {
                 Height = Application.GetRealHeight(49),
-                Width = Application.GetRealWidth(135),
+                Width = Application.GetRealWidth(717 - 508),
                 X = Application.GetRealWidth(508),
-                Y = Application.GetRealHeight(444),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
+                Y = Application.GetRealHeight(441),
+                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                 TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 10,
+                TextSize = 12, 
             };
             MidTopFrameLayout.AddChidren(inValidTimeDate);
 
@@ -263,25 +217,11 @@
 
             #region 鏁版嵁澶勭悊
             TimeDisplay(validTime, validTimeDate, inValidTime, inValidTimeDate, false);
-            if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.IsModify)
-            {
-                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                btnFinifh.Enable = true;
-                topPic.Visible = true;
-                topPic.Enable = true;
-            }
-            else
-            {
-                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
-                btnFinifh.Enable = false;
-                topPic.Visible = false;
-                topPic.Enable = false;
-            }
+
             if (string.IsNullOrEmpty(doorLock.LocalTempPassword))
             {
                 randomPassword.Text = "- - - - - -";
                 temPasswordVisiable.Visible = false;
-                randomPassword.X = Application.GetRealWidth(215);
                 randomPassword.TextColor = Shared.Common.ZigbeeColor.Current.XMGray4;
                 Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.IsModify = true;
                 topPic.Visible = true;
@@ -305,21 +245,36 @@
                 }
             }
 
-            temPasswordVisiable.MouseUpEventHandler += (sender, e) =>
+            if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.IsModify)
             {
-                temPasswordVisiable.IsSelected = !temPasswordVisiable.IsSelected;
-                if (!temPasswordVisiable.IsSelected)
-                {
-                    randomPassword.TextColor = Shared.Common.ZigbeeColor.Current.XMGray4;
-                    randomPassword.SecureTextEntry = true;
-                }
-                else
-                {
-                    randomPassword.TextColor = Shared.Common.ZigbeeColor.Current.XMOrange;
-                    randomPassword.SecureTextEntry = false;
-                }
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InTempPasswordVisiable = !randomPassword.SecureTextEntry;
-            };
+                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                btnFinifh.Enable = true;
+                topPic.Visible = true;
+                topPic.Enable = true;
+            }
+            else
+            {
+                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+                btnFinifh.Enable = false;
+                topPic.Visible = false;
+                topPic.Enable = false;
+            }
+
+            temPasswordVisiable.MouseUpEventHandler += (sender, e) =>
+      {
+          temPasswordVisiable.IsSelected = !temPasswordVisiable.IsSelected;
+          if (!temPasswordVisiable.IsSelected)
+          {
+              randomPassword.TextColor = Shared.Common.ZigbeeColor.Current.XMGray4;
+              randomPassword.SecureTextEntry = true;
+          }
+          else
+          {
+              randomPassword.TextColor = Shared.Common.ZigbeeColor.Current.XMOrange;
+              randomPassword.SecureTextEntry = false;
+          }
+          Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InTempPasswordVisiable = !randomPassword.SecureTextEntry;
+      };
             topPic.MouseUpEventHandler += (sender, e) =>
             {
                 randomPassword.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetTempPassword();
@@ -335,7 +290,9 @@
             };
             #endregion
         }
-        //搴曢儴鐣岄潰鍜屾暟鎹鐞�
+        /// <summary>
+        /// 搴曢儴甯冨眬澶勭悊
+        /// </summary>
         public void BottomFrameLayoutContent()
         {
             var bottomFrameLayout = new FrameLayout()
@@ -345,6 +302,7 @@
                 BackgroundColor = ZigbeeColor.Current.XMWhite,
             };
             this.midFrameLayout.AddChidren(bottomFrameLayout);
+            bottomFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
 
             var informationEdit = new Button()
             {
@@ -397,7 +355,7 @@
                 {
                     Width = Application.GetRealWidth(58),
                     Height = Application.GetRealHeight(58),
-                    UnSelectedImagePath = "Item/Next.png",
+                    UnSelectedImagePath = "Item/RightNext.png",
                     SelectedImagePath = "Item/Down.png",
                 };
                 btnNextFrameLayout.AddChidren(btnNext);
@@ -405,7 +363,7 @@
                 var btnLine = new FrameLayout()
                 {
                     Width = Application.GetRealWidth(965),
-                    Height = Application.GetRealHeight(5),
+                    Height = 1,
                     X = Application.GetRealWidth(58),
                     BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                 };
@@ -432,6 +390,17 @@
                     {
                         if (curIndex == 0)
                         {
+                            if (string.IsNullOrEmpty(doorLock.LocalTempPassword))
+                            {
+                                //璇�"鐐瑰嚮鐢熸垚"涓存椂瀵嗙爜锛�
+                                Application.RunOnMainThread(() =>
+                                {
+                                    var mess = Language.StringByID(R.MyInternationalizationString.SetTempPasswordTip1);
+                                    ShowMassage(ShowMsgType.Tip, mess);
+
+                                });
+                                return;
+                            }
                             var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "ValidTime");
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
@@ -443,6 +412,16 @@
                         }
                         if (curIndex == 1)
                         {
+                            if (string.IsNullOrEmpty(doorLock.LocalTempPassword))
+                            {
+                                //璇�"鐐瑰嚮鐢熸垚"涓存椂瀵嗙爜锛�
+                                Application.RunOnMainThread(() =>
+                                {
+                                    var mess = Language.StringByID(R.MyInternationalizationString.SetTempPasswordTip1);
+                                    this.ShowMassage(ShowMsgType.Tip, mess);
+                                });
+                                return;
+                            }
                             var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "InValidTime");
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
@@ -494,6 +473,7 @@
                 BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect,
                 TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                 TextSize = 16,
+                IsBold = true,
                 Enable = false,
             };
             bottomFrameLayout.AddChidren(btnFinifh);
@@ -504,7 +484,10 @@
             };
         }
 
-        //纭畾浜嬩欢澶勭悊
+        /// <summary>
+        /// 纭畾浜嬩欢澶勭悊
+        /// </summary>
+        /// <param name="btnFinifh"></param>
         void FinifhEventHandler(Button btnFinifh)
         {
             System.Threading.Tasks.Task.Run(async () =>
@@ -517,7 +500,8 @@
                         //璇�"鐐瑰嚮鐢熸垚"涓存椂瀵嗙爜锛�
                         Application.RunOnMainThread(() =>
                         {
-                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.SetTempPasswordTip1), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                            var mess = Language.StringByID(R.MyInternationalizationString.SetTempPasswordTip1);
+                            this.ShowMassage(ShowMsgType.Tip, mess);
                         });
                         return;
                     }
@@ -530,7 +514,8 @@
                         //鏃犳晥鐨勬椂闂磋缃�
                         Application.RunOnMainThread(() =>
                         {
-                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.SetTempPasswordTip), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                            var mess = Language.StringByID(R.MyInternationalizationString.SetTempPasswordTip);
+                            this.ShowMassage(ShowMsgType.Tip, mess);
                         });
                         return;
                     }
@@ -592,7 +577,10 @@
                                     addDoorLockTempPasswordData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                                     addDoorLockTempPasswordData.IsOtherAccountCtrl = true;
                                 }
-                                addDoorLockTempPasswordData.TempPwd = doorLock.tempPasswordObject.TempPassword;
+                                //瀵瑰瘑鐮佽繘琛屽姞瀵嗗鐞�
+                                string hdlKey = "hD1(La3o";
+                                var enPsw = UserCenterLogic.EncryptPassword(hdlKey, doorLock.tempPasswordObject.TempPassword);
+                                addDoorLockTempPasswordData.TempPwd = enPsw;
                                 if (doorLock.DeviceAddr != null)
                                 {
                                     addDoorLockTempPasswordData.LocalDoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
@@ -606,7 +594,8 @@
                                 {
                                     Application.RunOnMainThread(() =>
                                     {
-                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
+                                        var mess = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime);
+                                        this.ShowMassage(ShowMsgType.Tip, mess);
                                     });
                                     return;
                                 }
@@ -614,7 +603,8 @@
                                 {
                                     Application.RunOnMainThread(() =>
                                     {
-                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.SetFailedXm1), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
+                                        var mess = Language.StringByID(R.MyInternationalizationString.SetFailedXm1);
+                                        this.ShowMassage(ShowMsgType.Tip, mess);
                                     });
                                     return;
                                 }
@@ -626,7 +616,8 @@
                             {
                                 Application.RunOnMainThread(() =>
                                 {
-                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.SetFailedXm), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                                    var mess = Language.StringByID(R.MyInternationalizationString.SetFailedXm);
+                                    this.ShowMassage(ShowMsgType.Tip, mess);
                                 });
                                 return;
                             }
@@ -635,7 +626,8 @@
                         {
                             Application.RunOnMainThread(() =>
                             {
-                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.SetFailedXm), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                                var mess = Language.StringByID(R.MyInternationalizationString.SetFailedXm);
+                                this.ShowMassage(ShowMsgType.Tip, mess);
                             });
                             return;
                         }
@@ -644,7 +636,8 @@
                     {
                         Application.RunOnMainThread(() =>
                         {
-                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                            var mess = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
+                            this.ShowMassage(ShowMsgType.Tip, mess);
                         });
                         return;
                     }
@@ -664,8 +657,77 @@
             });
         }
 
-        //娓呴櫎浜嬩欢澶勭悊
-        async void ClearEventHandler(Button btnDelText = null, Dialog dialog = null)
+        /// <summary>
+        /// 娓呴櫎UI
+        /// </summary>
+        void ClearDialog()
+        {
+            var dialog = new Dialog { };
+            dialog.Show();
+
+            var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
+            dialog.AddChidren(flMain);
+            flMain.MouseUpEventHandler += (sender11, e11) =>
+            {
+                dialog.Close();
+            };
+
+            var delBackgroundFrameLayout = new FrameLayout
+            {
+                X = Application.GetRealWidth(596),
+                Y = Application.GetRealHeight(164),
+                Height = Application.GetRealHeight(173),
+                Width = Application.GetRealWidth(449),
+                BackgroundImagePath = "DoorLock/DelBackground.png",
+            };
+            flMain.AddChidren(delBackgroundFrameLayout);
+
+            var btnDelIcon2 = new Button
+            {
+                Height = Application.GetRealHeight(81),
+                Width = Application.GetRealWidth(81),
+                X = Application.GetRealWidth(81),
+                Y = Application.GetRealHeight(55),
+                UnSelectedImagePath = "DoorLock/DelIcon.png",
+            };
+            delBackgroundFrameLayout.AddChidren(btnDelIcon2);
+
+            var btnDelText = new Button
+            {
+                Height = Application.GetRealHeight(58),
+                Width = Application.GetRealWidth(311),
+                X = Application.GetRealWidth(173),
+                Y = Application.GetRealHeight(69),
+                TextAlignment = TextAlignment.CenterLeft,
+                Text = Language.StringByID(R.MyInternationalizationString.ClearTempPassword),
+                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
+                TextSize = 14,
+                IsBold = true,
+            };
+            delBackgroundFrameLayout.AddChidren(btnDelText);
+
+            EventHandler<MouseEventArgs> eHandler2 = (sender2, e2) =>
+            {
+                dialog.Close();
+                string msg = Language.StringByID(R.MyInternationalizationString.SureToDeleteTempPassword);
+                var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.DoorlockConfirm));
+                alert.Show();
+                //浣跨敤纭鍨嬪脊妗嗘椂,鐨勫洖璋冨嚱鏁�
+                alert.ConfirmClickEvent += () =>
+                {
+                    ClearEventHandler(btnDelText);
+                };
+            };
+            delBackgroundFrameLayout.MouseDownEventHandler += eHandler2;
+            btnDelIcon2.MouseDownEventHandler += eHandler2;
+            btnDelText.MouseDownEventHandler += eHandler2;
+        }
+
+        /// <summary>
+        /// 娓呴櫎浜嬩欢澶勭悊
+        /// </summary>
+        /// <param name="btnDelText"></param>
+        async void ClearEventHandler(Button btnDelText = null)
         {
             if (btnDelText == null)
             {
@@ -680,7 +742,7 @@
                     var resultData = await doorLock.DefaultControlAsync(passData);
                     if (resultData != null && resultData.defaultControlResponseData != null)
                     {
-                        if (resultData.defaultControlResponseData.status == 0)
+                        if (resultData.defaultControlResponseData.status == 0 || resultData.defaultControlResponseData.status == 2)
                         {
                             var delDoorLockTempPasswordData = new ZigBee.Device.DoorLock.DelDoorLockTempPasswordData();
                             if (UserCenterResourse.UserInfo.AuthorityNo != 1)
@@ -707,7 +769,8 @@
                                 {
                                     Application.RunOnMainThread(() =>
                                     {
-                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ClearFailedXm1) + ".", Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
+                                        var mess = Language.StringByID(R.MyInternationalizationString.ClearFailedXm1);
+                                        this.ShowMassage(ShowMsgType.Tip, mess);
                                     });
                                 }
                             }
@@ -715,7 +778,8 @@
                             {
                                 Application.RunOnMainThread(() =>
                                 {
-                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
+                                    var mess = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime);
+                                    this.ShowMassage(ShowMsgType.Tip, mess);
                                 });
                             }
                         }
@@ -723,14 +787,15 @@
                         {
                             Application.RunOnMainThread(() =>
                             {
-                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ClearFailedXm1), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
+                                var mess = Language.StringByID(R.MyInternationalizationString.ClearFailedXm1);
+                                this.ShowMassage(ShowMsgType.Tip, mess);
                             });
                         }
                     }
                     else
                     {
-                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDelText);
-
+                        var mess = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
+                        this.ShowMassage(ShowMsgType.Tip, mess);
                     }
                 }
             }
@@ -739,17 +804,16 @@
             {
                 Application.RunOnMainThread(() =>
                 {
-                    if (dialog != null)
-                    {
-                        dialog.Close();
-                    }
+
                     MidFrameLayoutContent();
                     CommonPage.Loading.Hide();
                 });
             }
         }
 
-        //璇诲彇浜戠瀛樺偍鏁版嵁
+        /// <summary>
+        /// 璇诲彇浜戠瀛樺偍鏁版嵁
+        /// </summary>
         void ReadTempPasswordData()
         {
             System.Threading.Tasks.Task.Run(async () =>
@@ -778,7 +842,10 @@
                                 tpObj.UserId = int.Parse(curDoorLockTempPaw.TempPwdId);
                                 tpObj.ValidTime = curDoorLockTempPaw.ValidBeginTime;
                                 tpObj.InValidTime = curDoorLockTempPaw.ValidEndTime;
-                                doorLock.LocalTempPassword = tpObj.TempPassword = curDoorLockTempPaw.TempPwd;
+                                //瑙e瘑瀵嗙爜
+                                string hdlKey = "hD1(La3o";
+                                var desPsw = UserCenterLogic.DecryptPassword(hdlKey, curDoorLockTempPaw.TempPwd);
+                                doorLock.LocalTempPassword = tpObj.TempPassword = desPsw;
                                 doorLock.tempPasswordObject = tpObj;
                                 TimeDateData(doorLock.tempPasswordObject.ValidTime, doorLock.tempPasswordObject.InValidTime);
                             }
@@ -794,7 +861,8 @@
                     }
                     else
                     {
-                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+                        var mess = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime);
+                        this.ShowMassage(ShowMsgType.Tip, mess);
                     }
                 }
                 catch { }
@@ -809,7 +877,12 @@
             });
         }
 
-        //鏈湴鏃堕棿鏁版嵁澶勭悊
+        /// <summary>
+        /// 鏈湴鏃堕棿鏁版嵁澶勭悊
+        /// </summary>
+        /// <param name="validTimeDateTime"></param>
+        /// <param name="inValidTime"></param>
+        /// <param name="isClearLocalTime"></param>
         void TimeDateData(DateTime validTimeDateTime, DateTime inValidTime, bool isClearLocalTime = false)
         {
             if (doorLock.tempPasswordObject != null)
@@ -844,7 +917,14 @@
             }
         }
 
-        //鏃堕棿鏄剧ず鏁版嵁澶勭悊
+        /// <summary>
+        /// 鏃堕棿鏄剧ず鏁版嵁澶勭悊
+        /// </summary>
+        /// <param name="validTime"></param>
+        /// <param name="validTimeDate"></param>
+        /// <param name="inValidTime"></param>
+        /// <param name="inValidTimeDate"></param>
+        /// <param name="isDefaultTime"></param>
         void TimeDisplay(Button validTime, Button validTimeDate, Button inValidTime, Button inValidTimeDate, bool isDefaultTime)
         {
             string hour = "";
@@ -852,18 +932,39 @@
             if (isDefaultTime)
             {
                 var cur = DateTime.Now;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour = cur.Hour;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour = cur.Hour;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute = cur.Minute;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute = cur.Minute;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateSecond = cur.Second;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateSecond = cur.Second;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateYear = cur.Year;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateYear = cur.Year;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMonth = cur.Month;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth = cur.Month;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateDay = cur.Day;
-                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateDay = cur.Day + 1;
+                DoorLockCommonInfo.ValidDateHour = cur.Hour;
+                DoorLockCommonInfo.ValidDateMinute = cur.Minute;
+                DoorLockCommonInfo.ValidDateSecond = cur.Second;
+                DoorLockCommonInfo.InValidDateHour = cur.Hour;
+                DoorLockCommonInfo.InValidDateMinute = cur.Minute;
+                DoorLockCommonInfo.InValidDateSecond = cur.Second;
+                DoorLockCommonInfo.ValidDateYear = cur.Year;
+                DoorLockCommonInfo.ValidDateMonth = cur.Month;
+                DoorLockCommonInfo.ValidDateDay = cur.Day;
+
+                var curD = DoorLockCommonInfo.LastDayOfMonth(cur);
+                if (DoorLockCommonInfo.ValidDateDay == curD.Day)
+                {
+                    if (DoorLockCommonInfo.ValidDateMonth == 12)
+                    {
+                        DoorLockCommonInfo.InValidDateYear = cur.Year + 1;
+                        DoorLockCommonInfo.InValidDateMonth = 1;
+                        DoorLockCommonInfo.InValidDateDay = 1;
+                    }
+                    else
+                    {
+                        DoorLockCommonInfo.InValidDateYear = cur.Year;
+                        DoorLockCommonInfo.InValidDateMonth = cur.Month + 1;
+                        DoorLockCommonInfo.InValidDateDay = 1;
+                    }
+                }
+                else
+                {
+                    DoorLockCommonInfo.InValidDateYear = cur.Year;
+                    DoorLockCommonInfo.InValidDateMonth = cur.Month;
+                    DoorLockCommonInfo.InValidDateDay = cur.Day + 1;
+                }
+
                 //doorLock.ReSave();
             }
             if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour < 10)
@@ -885,7 +986,7 @@
             //鏈夋晥鏃堕棿
             if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour == 100)
             {
-                validTime.Text = "00:00";
+                validTime.Text = "--:--";
             }
             else
             {
@@ -911,48 +1012,30 @@
 
             if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour == 100)
             {
-                inValidTime.Text = "00:00";
+                inValidTime.Text = "--:--";
             }
             else
             {
                 inValidTime.Text = hour + ":" + minute;
             }
-            validTimeDate.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMonth + Language.StringByID(R.MyInternationalizationString.Month) + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateDay + Language.StringByID(R.MyInternationalizationString.Day);
-            inValidTimeDate.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth + Language.StringByID(R.MyInternationalizationString.Month) + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateDay + Language.StringByID(R.MyInternationalizationString.Day);
-        }
 
-        #region 鈼� 鎺ュ彛瀹炵幇__________________________
-        /// <summary>
-        /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange()
-        /// </summary>
-        /// <returns>The changed.</returns>
-        /// <param name="common">Common.</param>
-        public void Changed(CommonDevice common)
-        {
+            if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMonth == 0)
+            {
+                validTimeDate.Text = "-" + Language.StringByID(R.MyInternationalizationString.Month) + "-" + Language.StringByID(R.MyInternationalizationString.Day);
+            }
+            else
+            {
+                validTimeDate.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMonth + Language.StringByID(R.MyInternationalizationString.Month) + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateDay + Language.StringByID(R.MyInternationalizationString.Day);
+            }
 
+            if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth == 0)
+            {
+                inValidTimeDate.Text = "-" + Language.StringByID(R.MyInternationalizationString.Month) + "-" + Language.StringByID(R.MyInternationalizationString.Day);
+            }
+            else
+            {
+                inValidTimeDate.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth + Language.StringByID(R.MyInternationalizationString.Month) + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateDay + Language.StringByID(R.MyInternationalizationString.Day);
+            }
         }
-        /// <summary>
-        /// 澶勭悊鍙樺寲浜嬩欢
-        /// </summary>
-        /// <param name="common"></param>
-        /// <param name="typeTag"></param>
-        public void DeviceInfoChange(CommonDevice common, string typeTag)
-        {
-        }
-        /// <summary>
-        /// Changeds the IL ogic status.
-        /// </summary>
-        /// <param name="logic">Logic.</param>
-        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
-        {
-        }
-        /// <summary>
-        /// Changeds the IS cene status.
-        /// </summary>
-        /// <param name="scene">Scene.</param>
-        public void ChangedISceneStatus(Scene scene)
-        {
-        }
-        #endregion
     }
 }

--
Gitblit v1.8.0