From dce6c3481a37216292724013ff9d2b75ceb82f86 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 10 六月 2020 15:47:28 +0800
Subject: [PATCH] 添加小度的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs |  476 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 245 insertions(+), 231 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
index 730ce66..31e7fb7 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
@@ -115,241 +115,255 @@
 
             #region 鏁版嵁澶勭悊
             KeyModeList();
-            btnFinifh.MouseUpEventHandler += async (sender, e) =>
-            {
-                oldTargetList.Clear();
-                bool isFinish = false;
-                btnFinifh.Enable = false;
-                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
-                try
-                {
-                    CommonPage.Loading.Start("");
-                    //1銆佹竻绌烘墍鏈夌洰鏍�
-                    if (currentKey.bindList != null)
-                    {
-                        var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey);
-                        if (bindResult != null && bindResult.clearBindInfoResponseData != null)
-                        {
-                            if (bindResult.clearBindInfoResponseData.Result != 0)
-                            {
-                                Application.RunOnMainThread(() =>
-                                {
-                                    CommonPage.Loading.Hide();
-                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
-                                });
-                                btnFinifh.Enable = true;
-                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                                return;
-                            }
-                            else
-                            {
-                                currentKey.bindList.Clear();
-                            }
-                        }
-                        else
-                        {
-                            Application.RunOnMainThread(() =>
-                            {
-                                CommonPage.Loading.Hide();
-                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
-                            });
-                            btnFinifh.Enable = true;
-                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                            return;
-                        }
-                    }
+            btnFinifh.MouseUpEventHandler += (sender, e) =>
+           {
+               oldTargetList.Clear();
+               btnFinifh.Enable = false;
+               btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+               System.Threading.Tasks.Task.Run(() =>
+               {
+                   try
+                   {
+                       Application.RunOnMainThread(() =>
+                       {
+                           CommonPage.Loading.Start("");
+                       });
+                       //1銆佹竻绌烘墍鏈夌洰鏍�
+                       if (currentKey.bindList != null)
+                       {
+                           var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey);
+                           if (bindResult != null && bindResult.clearBindInfoResponseData != null)
+                           {
+                               if (bindResult.clearBindInfoResponseData.Result != 0)
+                               {
+                                   Application.RunOnMainThread(() =>
+                                   {
+                                       btnFinifh.Enable = true;
+                                       btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                       CommonPage.Loading.Hide();
+                                       new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                                   });
+                                   return;
+                               }
+                               else
+                               {
+                                   currentKey.bindList.Clear();
+                               }
+                           }
+                           else
+                           {
+                               Application.RunOnMainThread(() =>
+                               {
+                                   btnFinifh.Enable = true;
+                                   btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                   CommonPage.Loading.Hide();
+                                   new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                               });
+                               return;
+                           }
+                       }
 
-                    //2銆侀厤缃ā寮�
-                    Panel.SetWritableValueResponAllData temp = null;
-                    switch (currentModeID)
-                    {
-                        case 100:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_On);
-                            break;
-                        case 101:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_oFF);
-                            break;
-                        case 102:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_OnOff);
-                            break;
-                        case 200:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Up);
-                            break;
-                        case 201:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Down);
-                            break;
-                        case 203:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up);
-                            break;
-                        case 204:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Down);
-                            break;
-                        case 205:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up_Down);
-                            break;
-                        case 300:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up);
-                            break;
-                        case 301:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down);
-                            break;
-                        case 302:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Stop);
-                            break;
-                        case 303:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up_Stop);
-                            break;
-                        case 304:
-                            temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down_Stop);
-                            break;
-                    }
-                    if (temp != null && temp.setWritableValueResponData != null)
-                    {
-                        if (temp.setWritableValueResponData.Status == 0)
-                        {
-                            //3銆佺粦瀹氭柊鐨勬暟鎹�
-                            var addBindeDev = new AddBindData();
-                            addBindeDev.DeviceAddr = currentKey.DeviceAddr;
-                            addBindeDev.Epoint = currentKey.DeviceEpoint;
+                       //2銆侀厤缃ā寮�
+                       Panel.SetWritableValueResponAllData temp = null;
+                       switch (currentModeID)
+                       {
+                           case 100:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_On);
+                               break;
+                           case 101:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_oFF);
+                               break;
+                           case 102:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_OnOff);
+                               break;
+                           case 200:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Up);
+                               break;
+                           case 201:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Down);
+                               break;
+                           case 203:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up);
+                               break;
+                           case 204:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Down);
+                               break;
+                           case 205:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up_Down);
+                               break;
+                           case 300:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up);
+                               break;
+                           case 301:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down);
+                               break;
+                           case 302:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Stop);
+                               break;
+                           case 303:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up_Stop);
+                               break;
+                           case 304:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down_Stop);
+                               break;
+                       }
+                       if (temp != null && temp.setWritableValueResponData != null)
+                       {
+                           if (temp.setWritableValueResponData.Status == 0)
+                           {
+                               //3銆佺粦瀹氭柊鐨勬暟鎹�
+                               var addBindeDev = new AddBindData();
+                               addBindeDev.DeviceAddr = currentKey.DeviceAddr;
+                               addBindeDev.Epoint = currentKey.DeviceEpoint;
 
-                            foreach (var de in targetList)
-                            {
-                                if (de.DeviceAddr != null)
-                                {
-                                    var addBindInfo = new AddBindListObj();
-                                    addBindInfo.BindType = 0;
-                                    addBindInfo.BindCluster = currentClusterID;
-                                    addBindInfo.BindMacAddr = de.DeviceAddr;
-                                    addBindInfo.BindEpoint = de.DeviceEpoint;
-                                    addBindeDev.BindList.Add(addBindInfo);
-                                }
-                            }
+                               foreach (var de in targetList)
+                               {
+                                   if (de.DeviceAddr != null)
+                                   {
+                                       var addBindInfo = new AddBindListObj();
+                                       addBindInfo.BindType = 0;
+                                       addBindInfo.BindCluster = currentClusterID;
+                                       addBindInfo.BindMacAddr = de.DeviceAddr;
+                                       addBindInfo.BindEpoint = de.DeviceEpoint;
+                                       addBindeDev.BindList.Add(addBindInfo);
+                                   }
+                               }
 
-                            //鏄寒搴﹀啀娆″彂6鍛戒护
-                            if (currentClusterID == 8)
-                            {
-                                foreach (var de in targetList)
-                                {
-                                    if (de.DeviceAddr != null)
-                                    {
-                                        var addBindInfo = new AddBindListObj();
-                                        addBindInfo.BindType = 0;
-                                        addBindInfo.BindCluster = 6;
-                                        addBindInfo.BindMacAddr = de.DeviceAddr;
-                                        addBindInfo.BindEpoint = de.DeviceEpoint;
-                                        addBindeDev.BindList.Add(addBindInfo);
-                                    }
-                                }
-                            }
+                               //鏄寒搴﹀啀娆″彂6鍛戒护
+                               if (currentClusterID == 8)
+                               {
+                                   foreach (var de in targetList)
+                                   {
+                                       if (de.DeviceAddr != null)
+                                       {
+                                           var addBindInfo = new AddBindListObj();
+                                           addBindInfo.BindType = 0;
+                                           addBindInfo.BindCluster = 6;
+                                           addBindInfo.BindMacAddr = de.DeviceAddr;
+                                           addBindInfo.BindEpoint = de.DeviceEpoint;
+                                           addBindeDev.BindList.Add(addBindInfo);
+                                       }
+                                   }
+                               }
 
-                            var dev = new AddedDeviceBindResponseAllData();
-                            dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev);
-                            if (dev != null && dev.addedDeviceBindResponseData != null)
-                            {
-                                if (dev.addedDeviceBindResponseData.Result == 0)
-                                {
-                                    if (currentClusterID == 8)
-                                    {
-                                        foreach (var de in dev.addedDeviceBindResponseData.BindList)
-                                        {
-                                            if (de.BindCluster == 8)
-                                            {
-                                                currentKey.bindList.Add(de);
-                                            }
-                                        }
-                                    }
-                                    else
-                                    {
-                                        currentKey.bindList = dev.addedDeviceBindResponseData.BindList;
-                                    }
-                                    if (action != null)
-                                    {
-                                        action(currentKey.bindList);
-                                    }
-                                    this.RemoveFromParent();
-                                    targetList.Clear();
-                                    CommonPage.Loading.Hide();
-                                    btnFinifh.Enable = true;
-                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                                }
-                                else if (dev.addedDeviceBindResponseData.Result == 1)
-                                {
-                                    Application.RunOnMainThread(() =>
-                                    {
-                                        CommonPage.Loading.Hide();
-                                        new Tip()
-                                        {
-                                            MaxWidth = 150,
-                                            Text = Language.StringByID(R.MyInternationalizationString.BindFailed),
-                                            Direction = AMPopTipDirection.Up,
-                                            CloseTime = 1
-                                        }.Show(btnFinifh);
-                                    });
-                                    btnFinifh.Enable = true;
-                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                                    return;
-                                }
-                                else
-                                {
-                                    Application.RunOnMainThread(() =>
-                                    {
-                                        CommonPage.Loading.Hide();
-                                        new Tip()
-                                        {
-                                            MaxWidth = 150,
-                                            Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError),
-                                            Direction = AMPopTipDirection.Up,
-                                            CloseTime = 1
-                                        }.Show(btnFinifh);
-                                    });
-                                    btnFinifh.Enable = true;
-                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                                    return;
-                                }
-                            }
-                            else
-                            {
-                                Application.RunOnMainThread(() =>
-                                {
-                                    CommonPage.Loading.Hide();
-                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
-                                });
-                                btnFinifh.Enable = true;
-                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                                return;
-                            }
-                        }
-                        else
-                        {
-                            Application.RunOnMainThread(() =>
-                            {
-                                CommonPage.Loading.Hide();
-                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
-                            });
-                            btnFinifh.Enable = true;
-                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                            return;
-                        }
-                    }
-                    else
-                    {
-                        Application.RunOnMainThread(() =>
-                        {
-                            CommonPage.Loading.Hide();
-                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
-                        });
-                        btnFinifh.Enable = true;
-                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                        return;
-                    }
-                }
-                catch
-                {
-                    CommonPage.Loading.Hide();
-                    btnFinifh.Enable = true;
-                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                }
-            };
+                               var dev = new AddedDeviceBindResponseAllData();
+                               dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev);
+                               if (dev != null && dev.addedDeviceBindResponseData != null)
+                               {
+                                   if (dev.addedDeviceBindResponseData.Result == 0)
+                                   {
+                                       if (currentClusterID == 8)
+                                       {
+                                           foreach (var de in dev.addedDeviceBindResponseData.BindList)
+                                           {
+                                               if (de.BindCluster == 8)
+                                               {
+                                                   currentKey.bindList.Add(de);
+                                               }
+                                           }
+                                       }
+                                       else
+                                       {
+                                           currentKey.bindList = dev.addedDeviceBindResponseData.BindList;
+                                       }
+
+                                       Application.RunOnMainThread(() =>
+                                       {
+                                           if (action != null)
+                                           {
+                                               action(currentKey.bindList);
+                                           }
+                                           targetList.Clear();
+                                           this.RemoveFromParent();
+                                           btnFinifh.Enable = true;
+                                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                           CommonPage.Loading.Hide();
+                                       });
+
+                                   }
+                                   else if (dev.addedDeviceBindResponseData.Result == 1)
+                                   {
+                                       Application.RunOnMainThread(() =>
+                                       {
+                                           btnFinifh.Enable = true;
+                                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                           CommonPage.Loading.Hide();
+                                           new Tip()
+                                           {
+                                               MaxWidth = 150,
+                                               Text = Language.StringByID(R.MyInternationalizationString.BindFailed),
+                                               Direction = AMPopTipDirection.Up,
+                                               CloseTime = 1
+                                           }.Show(btnFinifh);
+                                       });
+                                       return;
+                                   }
+                                   else
+                                   {
+                                       Application.RunOnMainThread(() =>
+                                       {
+                                           btnFinifh.Enable = true;
+                                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                           CommonPage.Loading.Hide();
+                                           new Tip()
+                                           {
+                                               MaxWidth = 150,
+                                               Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError),
+                                               Direction = AMPopTipDirection.Up,
+                                               CloseTime = 1
+                                           }.Show(btnFinifh);
+                                       });
+
+                                       return;
+                                   }
+                               }
+                               else
+                               {
+                                   Application.RunOnMainThread(() =>
+                                   {
+                                       btnFinifh.Enable = true;
+                                       btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                       CommonPage.Loading.Hide();
+                                       new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                                   });
+                                   return;
+                               }
+                           }
+                           else
+                           {
+                               Application.RunOnMainThread(() =>
+                               {
+                                   btnFinifh.Enable = true;
+                                   btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                   CommonPage.Loading.Hide();
+                                   new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
+                               });
+                               return;
+                           }
+                       }
+                       else
+                       {
+                           Application.RunOnMainThread(() =>
+                           {
+                               btnFinifh.Enable = true;
+                               btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                               CommonPage.Loading.Hide();
+                               new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
+                           });
+                           return;
+                       }
+                   }
+                   catch
+                   {
+                       Application.RunOnMainThread(() =>
+                       {
+                           btnFinifh.Enable = true;
+                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                           CommonPage.Loading.Hide();
+                       });
+                   }
+               });
+           };
             #endregion 
         }
 

--
Gitblit v1.8.0