From e5f993f52e09eb46878baced83bb8492f147d41c Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 04 十一月 2019 17:58:40 +0800
Subject: [PATCH] 2019-11-04-1

---
 ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs |  121 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 106 insertions(+), 15 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs
index bfbff84..8aa6678 100644
--- a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs
@@ -3,11 +3,16 @@
 using Shared.Common;
 using Shared.R;
 
-namespace Shared.Phone.Logic.DoorLockLogic
+namespace Shared.Phone.Device.Logic.DoorLockLogic
 {
     public class LockLogicList : FrameLayout
     {
 
+        public LockLogicList()
+        {
+            Tag = "LockLogicList";
+        }
+        VerticalScrolViewLayout middle;
         public async void Show()
         {
 
@@ -26,10 +31,10 @@
                 TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                 TextAlignment = TextAlignment.CenterLeft,
                 X = Application.GetRealWidth(176),
-                Width = Application.GetRealWidth(400),
+                Width = Application.GetRealWidth(600),
                 Height = Application.GetRealHeight(69),
                 Y = Application.GetRealHeight(92),
-                TextID = MyInternationalizationString.selection,
+                TextID = MyInternationalizationString.linkageevent,
             };
             topRowLayout.AddChidren(titleName);
 
@@ -75,8 +80,10 @@
                 Common.Logic.CurrentLogic = new Common.Logic();
                 Common.Logic.CurrentLogic.IsEnable = 1;//榛樿涓哄紑
                 Common.Logic.CurrentLogic.LogicType = 1;
+                Common.Logic.CurrentLogic.Relationship = 1;
                 //Config.Instance.Guid鐢ㄦ潵璇嗗埆璐﹀彿韬唤锛�
                 var accounts = new System.Collections.Generic.Dictionary<string, string>();
+                accounts.Add("Type","1");
                 accounts.Add("Account", Config.Instance.Guid);
                 Common.Logic.CurrentLogic.Accounts.Add(accounts);
                 Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.automation1);
@@ -87,7 +94,7 @@
             };
             #endregion
 
-            var middle = new VerticalScrolViewLayout
+            middle = new VerticalScrolViewLayout
             {
                 Y = topRowLayout.Bottom,
                 Height = Application.GetRealHeight(1920 - 184),
@@ -98,26 +105,43 @@
             CommonPage.Loading.Start();
             if (Common.Logic.LockLogicList.Count == 0)
             {
-                var Idlist = await Device.Logic.Send.GetLogicId();
+                var Idlist = await Send.GetLogicId(1);
                 if (Idlist.Count != 0)
                 {
-                    var listlogic = await Device.Logic.Send.ReadList(Idlist.Count);
-                    for (int i = 0; i < Idlist.Count; i++)
+                    var listlogic = await Send.ReadList(Idlist.Count, 1);
+                    //foreach鍙兘闆嗗悎宸茶淇敼,鏋氫妇鎿嶄綔鍙兘涓嶄細鎵ц,鍙兘鍑虹幇宕╂簝(寤鸿for)銆�
+                    for (int j = 0; j < listlogic.Count; j++)
                     {
-                        var LogicId = Idlist[i];
-                        //foreach鍙兘闆嗗悎宸茶淇敼,鏋氫妇鎿嶄綔鍙兘涓嶄細鎵ц,鍙兘鍑虹幇宕╂簝(寤鸿for)銆�
-                        for (int j = 0; j < listlogic.Count; j++)
+                        var logic = listlogic[j];
+                        if (logic.LogicType == 0)
                         {
-                            var logic = listlogic[j];
-                            if (logic.LogicId == LogicId)
+                            continue;
+                        }
+                        bool yes = false;
+                        for (int a = 0; a < logic.Accounts.Count; a++)
+                        {
+                            if (logic.Accounts[a]["Account"].ToString() == Config.Instance.Guid)
                             {
-                                Common.Logic.LockLogicList.Add(logic);
+                                //鏌ユ壘鑷繁璐﹀彿涓嬬殑鍒涘缓鑱斿姩浜嬩欢锛�
+                                yes = true;
+                                break;
                             }
+                        }
+                        if (yes)
+                        {
+                            Common.Logic.LockLogicList.Add(listlogic[j]);
                         }
                     }
                 }
             }
             //鑷姩鍖�
+            Automationview();
+            CommonPage.Loading.Hide();
+        }
+
+        void Automationview()
+        {
+            middle.RemoveAll();
             for (int i = 0; i < Common.Logic.LockLogicList.Count; i++)
             {
                 var logic = Common.Logic.LockLogicList[i];
@@ -125,7 +149,7 @@
                 {
                     Width = Application.GetRealWidth(1080),
                     Height = Application.GetRealHeight(190),
-                    LineColor = ZigbeeColor.Current.LogicBackgroundColor,
+                    LineColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                     BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
 
                 };
@@ -155,8 +179,75 @@
                 };
                 logicRowlayout.AddChidren(logicswitchBtn);
 
+                logicswitchBtn.MouseUpEventHandler += (sender, e) =>
+                {
+                    logicswitchBtn.IsSelected = !logicswitchBtn.IsSelected;
+                    if (logicswitchBtn.IsSelected)
+                    {
+                        //閫昏緫寮�
+                        logic.IsEnable = 1;
+                    }
+                    else
+                    {
+                        //閫昏緫鍏�
+                        logic.IsEnable = 0;
+                    }
+                    Send.LogicControlSwitch(logic);
+
+                };
+                if (logic.IsEnable == 1)
+                {
+                    logicswitchBtn.IsSelected = true;
+                }
+                else if (logic.IsEnable == 0)
+                {
+                    logicswitchBtn.IsSelected = false;
+                }
+                ///缂栬緫
+                var edit = new Button
+                {
+                    BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor1,
+                    Text = Language.StringByID(MyInternationalizationString.edit),
+                    TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
+                };
+                logicRowlayout.AddRightView(edit);
+                edit.MouseUpEventHandler += (sender, e) =>
+                {
+                    Common.Logic.CurrentLogic = logic;
+                    var lockLogicCommunalPage = new LockLogicCommunalPage();
+                    UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage);
+                    UserView.HomePage.Instance.PageIndex += 1;
+                    lockLogicCommunalPage.Show(() => { logicnameBtn.Text = logic.LogicName; Automationview(); });
+
+                };
+
+
+                ///鍒犻櫎
+                var del = new Button
+                {
+                    BackgroundColor = ZigbeeColor.Current.LogicDelBlackColor1,
+                    Text = Language.StringByID(MyInternationalizationString.del),
+                    TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
+                };
+                logicRowlayout.AddRightView(del);
+                del.MouseUpEventHandler += (sender, e) =>
+                {
+                    var alert = new Alert(Language.StringByID(MyInternationalizationString.tip), Language.StringByID(MyInternationalizationString.doyouwanttodelete),
+                                             Language.StringByID(MyInternationalizationString.cancel), Language.StringByID(MyInternationalizationString.confrim));
+                    alert.ResultEventHandler += (sender1, e1) =>
+                    {
+                        if (e1)
+                        {
+                            Common.Logic.LockLogicList.Remove(logic);
+                            Automationview();
+                            Send.DelLogic(logic.LogicId);
+                        }
+                    };
+                    alert.Show();
+
+                };
             }
-            CommonPage.Loading.Hide();
+
         }
     }
 }

--
Gitblit v1.8.0