From 2e7e5f9af5b32cfe1fc3c6ba40bf7eb984bbd0a4 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 11 五月 2020 17:52:06 +0800
Subject: [PATCH] ???????

---
 ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs |   91 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 85 insertions(+), 6 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs
index c593a35..742b6f6 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs
@@ -21,17 +21,27 @@
             this.AddChidren(view.TopRowView());
             view.toptitleNameBtn.TextID = MyInternationalizationString.linkageevent;
             view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); };
+            //鍔犲ぇ鐐瑰嚮鐑敭
+            var addiocnclick = new Button
+            {
+                Width = Application.GetRealWidth(108+58),
+                Height = Application.GetRealHeight(72+20),
+                X = Application.GetRealWidth(1080 - 108 - 58),
+                Y = Application.GetRealHeight(184 - 72),
+            };
+            view.topRowLayout.AddChidren(addiocnclick);
 
             var addiocn = new Button
             {
-                Width = Application.GetRealWidth(72),
-                Height = Application.GetRealHeight(72),
+                Width = Application.GetMinRealAverage(72),
+                Height = Application.GetMinRealAverage(72),
                 X = Application.GetRealWidth(1080 - 108 - 58),
                 UnSelectedImagePath = "ZigeeLogic/lockadd.png",
                 Y = Application.GetRealHeight(184 - 72 - 20),
             };
             view.topRowLayout.AddChidren(addiocn);
-            addiocn.MouseUpEventHandler += (sender, e) =>
+
+            EventHandler<MouseEventArgs> addclick = (sender, e) =>
             {
                 //new涓�涓柊閫昏緫瀵硅薄锛�
                 Common.Logic.CurrentLogic = new Common.Logic();
@@ -44,6 +54,10 @@
                 UserView.HomePage.Instance.PageIndex += 1;
                 lockLogicCommunalPage.Show(() => { });
             };
+
+            addiocnclick.MouseUpEventHandler += addclick;
+            addiocn.MouseUpEventHandler += addclick;
+
             #endregion
             middle = new VerticalRefreshLayout
             {
@@ -68,8 +82,12 @@
         /// </summary>
         public async void Read()
         {
+
+
+
+
             CommonPage.Loading.Start();
-            if (Common.Logic.LockLogicList.Count == 0)
+            if (!BoolExist())
             {
                 var Idlist = await Send.GetLogicId(1);
                 if (Idlist.Count != 0)
@@ -86,7 +104,8 @@
                         bool yes = false;
                         for (int a = 0; a < logic.Accounts.Count; a++)
                         {
-                            if (logic.Accounts[a]["MacAddr"].ToString() != Send.CurrentDoorLock.DeviceAddr && logic.Accounts[a]["Epoint"].ToString() != Send.CurrentDoorLock.DeviceEpoint.ToString())
+                            //Option4鏄澶噈ac锛汷ption2鏄澶囩鍙o紱
+                            if (logic.Accounts[a]["Option4"].ToString() != Send.CurrentDoorLock.DeviceAddr && logic.Accounts[a]["Option2"].ToString() != Send.CurrentDoorLock.DeviceEpoint.ToString())
                             {
                                 //鏌ユ壘鏄惁鏄偅涓棬閿侊紱
                                 //濡傛灉涓嶆槸璇ラ棬閿佽仈鍔ㄤ簨浠朵笉鏄剧ず鍑烘潵;
@@ -117,7 +136,8 @@
         {
             middle.RemoveAll();
 
-            if (Common.Logic.LockLogicList.Count == 0)
+            //if (Common.Logic.LockLogicList.Count == 0)
+            if (!BoolExist())
             {
                 //灏辨槸涓轰簡鏄剧ず寮曞娣诲姞鍥炬爣;
                 var noFrameLayout = new FrameLayout
@@ -156,6 +176,11 @@
             for (int i = 0; i < Common.Logic.LockLogicList.Count; i++)
             {
                 var logic = Common.Logic.LockLogicList[i];
+                if (!Exist(logic))
+                {
+                    continue;
+                }
+                
                 var logicRowlayout = new RowLayout
                 {
                     Width = Application.GetRealWidth(1080),
@@ -259,5 +284,59 @@
             }
 
         }
+
+
+        /// <summary>
+        /// 鏌ユ壘璇ラ棬閿佹槸鍚﹀瓨鍦ㄨ嚜鍔ㄥ寲
+        /// </summary>
+        /// <returns></returns>
+        private bool BoolExist()
+        {
+            bool yes = false;
+            for (int i = 0; i < Common.Logic.LockLogicList.Count; i++)
+            {
+                var logic = Common.Logic.LockLogicList[i];
+                if (logic.LogicType != 1)
+                {
+                    continue;
+                }
+                
+                if (Exist(logic))
+                {
+                    yes = true;
+                    //瀛樺湪灏遍��鍑�
+                    break;
+                }
+            }
+            return yes;
+        }
+
+        /// <summary>
+        /// 鏌ユ壘杩欎竴鏉¤嚜鍔ㄥ寲鏄惁灞炰簬璇ラ棬閿�
+        /// </summary>
+        /// <returns></returns>
+        private bool Exist(Common.Logic logic)
+        {
+            bool yes = false;
+            for (int j = 0; j < logic.Accounts.Count; j++)
+            {
+                //Option4鏄澶噈ac锛汷ption2鏄澶囩鍙o紱
+                if (logic.Accounts[j]["Option4"].ToString() != Send.CurrentDoorLock.DeviceAddr && logic.Accounts[j]["Option2"].ToString() != Send.CurrentDoorLock.DeviceEpoint.ToString())
+                {
+                    //鏌ユ壘鏄惁鏄偅涓棬閿侊紱
+                    //濡傛灉涓嶆槸璇ラ棬閿佽仈鍔ㄤ簨浠朵笉鏄剧ず鍑烘潵;
+                    yes = false;
+                    break;
+                }
+                if (logic.Accounts[j]["Account"].ToString() == Config.Instance.Guid)
+                {
+                    //鏌ユ壘鑷繁璐﹀彿涓嬬殑鍒涘缓鑱斿姩浜嬩欢锛�
+                    yes = true;
+                    break;
+                }
+
+            }
+            return yes;
+        }
     }
 }

--
Gitblit v1.8.0