From a4d29f9f72452ccae2f607e6ad31cad493822da4 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 06 五月 2020 11:36:47 +0800
Subject: [PATCH] 2020-05-06-1

---
 ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs |  145 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 110 insertions(+), 35 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs b/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs
index d616479..4501171 100644
--- a/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs
@@ -8,12 +8,31 @@
 {
     public class SoneLogicList : FrameLayout
     {
+        /// <summary>
+        /// 缁橲one闂ㄩ攣寰愭鏇存柊鐣岄潰鐢ㄧ殑
+        /// </summary>
+        ///
         public SoneLogicList()
         {
             Tag = "SoneLogic";
         }
-        public async void Show()
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="action">缁欏緪姊呭埛鏂扮晫闈㈢敤鐨�</param>
+        /// <param name="bool_If"></param>
+        public async void Show(Action action, bool bool_If = false)
         {
+            #region  寰愭鍙繖鏍峰仛鐨�
+            string key = Send.CurrentDoorLock.DeviceAddr + "_" + Send.CurrentDoorLock.DeviceEpoint;
+            if (Send.CurrentDoorLock.IsDoorLockNormallyMode.ContainsKey(key))
+            {
+                if (Send.CurrentDoorLock.IsDoorLockNormallyMode[key] == true)
+                {
+                    bool_If = true;
+                }
+            }
+            #endregion
             #region  鐣岄潰鐨勫竷灞�浠g爜
             UserView.HomePage.Instance.ScrollEnabled = false;//閿佷綇宸︽粦
             TopView view = new TopView();
@@ -22,7 +41,13 @@
             view.clickBtn.MouseDownEventHandler += (sender, e) =>
             {
                 UserView.HomePage.Instance.ScrollEnabled = true;
+                if (action != null)
+                {
+                    action();
+                }
+
                 RemoveFromParent();
+
             };
 
             var middle = new FrameLayout
@@ -54,10 +79,11 @@
                 SelectedImagePath = "ZigeeLogic/openMode.png",
             };
             fLayout.AddChidren(modeIconBtn);
-            var logic = await SkipView.GetLogicIfon();
-            if (logic != null)
-            {
 
+            if (bool_If)
+            {
+                /// 鏌ユ壘鏄惁瀛樺湪鏃舵晥鎬ц嚜鍔ㄥ寲锛涙湁鐨勮瘽灏辫繑鍥炶嚜鍔ㄥ寲瀵硅薄;
+                var logic = await SkipView.GetLogicIfon();
 
                 fLayout.Height = Application.GetRealHeight(780);//鏀瑰彉楂樺害
                 modeIconBtn.IsSelected = true;//鏀瑰彉鍥炬爣鐘舵��
@@ -82,26 +108,32 @@
                     TextSize = 16,
                 };
                 openModeFl.AddChidren(closeBtn);
-                closeBtn.MouseUpEventHandler += (sender,e) => {
-                    
-
-                    var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm,
-                   Language.StringByID(MyInternationalizationString.doyouwanttodelete),
-                   Language.StringByID(MyInternationalizationString.confrim));
-                    alert.Show();
-                    alert.ConfirmClickEvent += () =>
+                closeBtn.MouseUpEventHandler += async (sender, e) =>
+                {
+                    var result = await UserCenter.DoorLock.DoorLockCommonInfo.DelNormallyOpenMode(Send.CurrentDoorLock);
+                    if (result)
                     {
-                        Send.DelLogic(logic.LogicId);
+                        if (logic != null)
+                        {
+                            ///鏈夊彲鑳藉彧鏈夊父寮�妯″紡锛屾病鏈夋椂鏁堟�ц嚜鍔ㄥ寲
+                            ///娌℃湁鍒ゆ柇鐨勮瘽锛岄�昏緫浼氫负绌猴紝鎶涘嚭寮傚父;
+                            Send.DelLogic(logic.LogicId);
+                        }
                         this.RemoveFromParent();
                         var soneLogicList = new SoneLogicList();
                         UserView.HomePage.Instance.AddChidren(soneLogicList);
                         UserView.HomePage.Instance.PageIndex += 1;
-                        soneLogicList.Show();
-                    };
+                        soneLogicList.Show(() => { }, false);
+                    }
+                    else
+                    {
+                        ///鎻愮ず澶辫触
+                    }
+
                 };
 
                 ///鏄剧ず澶辨晥璁剧疆鏃堕棿鏂囨湰鎺т欢
-                var timeTextBtn= new Button
+                var timeTextBtn = new Button
                 {
                     Y = Application.GetRealHeight(127 + 69),
                     X = Application.GetRealWidth(225),
@@ -111,19 +143,23 @@
                     TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                     Text = "鏃舵晥鎬у父寮�璁剧疆12:20",
                 };
-                openModeFl.AddChidren(timeTextBtn);
+                if (logic != null)
+                {
+                    ///鏈夋椂鏁堟�у父寮�鎵嶆樉绀烘椂闂存潯浠舵枃鏈�
+                    openModeFl.AddChidren(timeTextBtn);
+                }
                 ///鏃舵晥鎬у父寮�鍙湁涓�涓潯浠�;
                 try
                 {
                     var y = DateTime.Now.ToString("yy");//閭d竴骞�
                     var m = DateTime.Now.ToString("mm");//閭d竴鏈�
                     var d = DateTime.Now.ToString("dd");//閭d竴澶�
-                    var h =int.Parse(DateTime.Now.ToString("HH"));//褰撳墠绯荤粺鏃堕棿
+                    var h = int.Parse(DateTime.Now.ToString("HH"));//褰撳墠绯荤粺鏃堕棿
                     var me = DateTime.Now.ToLongDateString();
                     var timeInt = int.Parse(logic.Conditions[0]["DoorLockOpenDelayTime"]);
-                    int dayInt = (h + timeInt)/ 24;//绠楀嚭鍑犲ぉ鍚庢墽琛�
+                    int dayInt = (h + timeInt) / 24;//绠楀嚭鍑犲ぉ鍚庢墽琛�
                     int hour = (h + timeInt) % 24;//绠楀嚭鍑犲ぉ鍚庨偅涓椂闂存墽琛�
-                    timeTextBtn.Text = "鏃舵晥鎬у父寮�璁剧疆" + y + "骞�" + m + "鏈�" + d + dayInt + "鍙�" + timeInt + "鏃�"+ "鎵ц";
+                    timeTextBtn.Text = "鏃舵晥鎬у父寮�璁剧疆" + y + "骞�" + m + "鏈�" + d + dayInt + "鍙�" + timeInt + "鏃�" + "鎵ц";
                 }
                 catch { }
 
@@ -155,7 +191,8 @@
                     TextSize = 15,
                     TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                     TextAlignment = TextAlignment.CenterLeft,
-                    Text = "鏃舵晥鎬у父寮�璁剧疆",
+                    // Text = "鏃舵晥鎬у父寮�璁剧疆",
+                    TextID = MyInternationalizationString.timeSetSone,
                 };
                 modeFl.AddChidren(modeTextBtn);
                 ///涓嬩竴绾ц彍鍗曞浘鏍囨帶浠�
@@ -168,6 +205,54 @@
                     UnSelectedImagePath = "ZigeeLogic/next.png",
                 };
                 modeFl.AddChidren(nextIconBtn);
+
+
+
+                nextIconBtn.MouseUpEventHandler += (sender, e) =>
+                 {
+                     LogicView.TipView.ShowConfrimTip(() =>
+                     {///鍐嶆纭
+                       LogicView.TipView.ShowInputTip(true, async (str) =>
+                         {///纭鍙戦�佸懡浠�
+                           try
+                             {
+                               ///xm
+                               var result = await UserCenter.DoorLock.DoorLockCommonInfo.SetNormallyOpenModeFuncAsync(Send.CurrentDoorLock);
+                                 if (!result)
+                                 {
+                                     Application.RunOnMainThread(() =>
+                                     {
+                                       ///鎻愮ず澶辫触
+                                   });
+                                     return;
+                                 }
+                                 else
+                                 {
+                                   ///鍥犱负鏈夊父寮�妯″紡涓嬫墠鍙互鍒涘缓澶辨晥閫昏緫锛�
+                                   SkipView.GetLogicAll();//鍒犻櫎涔嬪墠鎵�鏈夊け鏁堥�昏緫
+                                   var addResult = await SkipView.LockAddModifyLogic(int.Parse(str), Send.CurrentDoorLock);//娣诲姞涓�鏉″け鏁堥�昏緫
+                                   if (!addResult)
+                                     {
+                                       ///鎻愮ず澶辫触
+                                       return;
+                                     }
+                                     this.RemoveFromParent();
+                                     var soneLogicList = new SoneLogicList();
+                                     UserView.HomePage.Instance.AddChidren(soneLogicList);
+                                     UserView.HomePage.Instance.PageIndex += 1;
+                                     soneLogicList.Show(() => { }, true);
+
+                                 }
+                             }
+                             catch
+                             {
+
+                             }
+                         });
+
+                     });
+
+                 };
             }
 
             #endregion
@@ -202,7 +287,8 @@
                 TextSize = 24,
                 TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                 TextAlignment = TextAlignment.CenterLeft,
-                Text = "甯稿紑鑷姩鍖�",
+                //Text = "甯稿紑鑷姩鍖�",
+                TextID = MyInternationalizationString.openAutomationSone,
             };
             addLogicfL.AddChidren(addTextBtn);
             ///娣诲姞鑷姩鍖栧浘鏍囩殑鎺т欢
@@ -217,18 +303,7 @@
             addLogicfL.AddChidren(addIconBtn);
             addIconBtn.MouseUpEventHandler += (sender, e) =>
             {
-                ZigBee.Device.DoorLock doorLock = null;
-                if (doorLock == null)
-                {
-                    ///闃叉鎶涘紓甯�
-                    doorLock = new ZigBee.Device.DoorLock();
-                }
-                Send.CurrentDoorLock = doorLock;
-                Common.Logic.LogicDviceList.Clear();
-                if (Common.Logic.LogicDviceList.Count == 0)
-                {
-                    Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
-                }
+
                 //璇诲彇绯荤粺褰撳墠鏃堕棿锛氭椂-鍒�
                 //璇诲彇绯荤粺褰撳墠鏃堕棿锛氭椂-鍒�
                 var h = DateTime.Now.ToString("HH");
@@ -245,7 +320,7 @@
                 timeConditionsInfo.Add("StartMin", m);
                 Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
                 actionsInfo.Add("LinkType", 8);
-                actionsInfo.Add("DeviceAddr", doorLock.DeviceAddr);
+                actionsInfo.Add("DeviceAddr", Send.CurrentDoorLock.DeviceAddr);
                 actionsInfo.Add("Epoint", "200");
                 actionsInfo.Add("PassData", "055704010113");//榛樿闂ㄩ攣甯稿叧
                 //new涓�涓柊閫昏緫瀵硅薄锛�

--
Gitblit v1.8.0