From 617a02739b82ae30772de25b4f9a8f6e9460f468 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 12 八月 2020 17:42:36 +0800
Subject: [PATCH] 请合并代码:新增多功能面板一对一绑定机制

---
 ZigbeeApp20200810/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs |   67 ++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/ZigbeeApp20200810/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs b/ZigbeeApp20200810/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs
index aaab4fc..307140e 100644
--- a/ZigbeeApp20200810/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs
+++ b/ZigbeeApp20200810/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs
@@ -546,7 +546,7 @@
                 var btnDel = rowLayout.AddDeleteControl();
                 btnDel.ButtonClickEvent += (sender, e) =>
                 {
-                    RemoveTargets(bindObj, btnDel);
+                    ClearTargets(bindObj);
                 };
                 #endregion
             }
@@ -706,7 +706,7 @@
         /// <param name="bindDevice"></param>
         /// <param name="btnDel"></param>
         /// <returns></returns>
-        private void RemoveTargets(BindListAllInfo bindDevice, Button btnDel)
+        private void RemoveTargets(BindListAllInfo bindDevice)
         {
             var delDevice = new DelDeviceBindData();
             delDevice.DeviceAddr = bindDevice.KeyMacAddr;
@@ -857,7 +857,68 @@
             });
         }
 
-
+        /// <summary>
+        /// 娓呴櫎澶氬姛鑳介潰鏉跨殑鐩爣
+        /// </summary>
+        /// <param name="bindDevice"></param>
+        /// <param name="btnDel"></param>
+        /// <returns></returns>
+        private void ClearTargets(BindListAllInfo bindDevice)
+        {
+            System.Threading.Tasks.Task.Run(() =>
+           {
+               try
+               {
+                   Application.RunOnMainThread(() =>
+                   {
+                       CommonPage.Loading.Start("");
+                   });
+                   var currentKey = new Panel();
+                   currentKey.DeviceAddr = bindDevice.KeyMacAddr;
+                   currentKey.DeviceEpoint = bindDevice.KeyEpoint;
+                   currentKey.CurrentGateWayId = curControlDev.CurrentGateWayId;
+                   var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey);
+                   if (bindResult != null && bindResult.clearBindInfoResponseData != null)
+                   {
+                       if (bindResult.clearBindInfoResponseData.Result != 0)
+                       {
+                           Application.RunOnMainThread(() =>
+                           {
+                               new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RemoveFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(CommonPage.Instance);
+                               CommonPage.Loading.Hide();
+                           });
+                       }
+                       else
+                       {
+                           if (MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList.ContainsKey(bindDevice.KeyMacAddr + bindDevice.KeyEpoint))
+                           {
+                               MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList.Remove(bindDevice.KeyMacAddr + bindDevice.KeyEpoint);
+                           }
+                           Application.RunOnMainThread(() =>
+                           {
+                               RefreshBindListUI();
+                               CommonPage.Loading.Hide();
+                           });
+                       }
+                   }
+                   else
+                   {
+                       Application.RunOnMainThread(() =>
+                       {
+                           new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5006" + ")", Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance);
+                       });
+                   }
+               }
+               catch { }
+               finally
+               {
+                   Application.RunOnMainThread(() =>
+                   {
+                       CommonPage.Loading.Hide();
+                   });
+               }
+           });
+        }
 
         /// <summary>
         /// 鍖归厤鐨勭被鍨嬪垪琛�

--
Gitblit v1.8.0