HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-11-13 8b9ce384b26c414db32f98e94e088f5334869c2d
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Com.Amap.Api.Location;
using Shared.Common;
using ZigBee.Device;
using static ZigBee.Device.BindObj;
@@ -14,14 +13,8 @@
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        {
            //if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch)
            //{
            //    return;
            //}
            Shared.Application.RunOnMainThread(() =>
            {
                //var dev = common as Panel;
            });
        }
@@ -154,44 +147,6 @@
                            return;
                        }
                    }
                    //if (oldModeID != 65535 && oldModeID != currentModeID)
                    //{
                    //var bindResult = await currentKey.ClearBindInfoAsync();
                    //if (bindResult.clearBindInfoResponseData != null)
                    //{
                    //    if (bindResult.clearBindInfoResponseData.Result != 0)
                    //    {
                    //        Application.RunOnMainThread(() =>
                    //        {
                    //            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
                    //        });
                    //        CommonPage.Loading.Hide();
                    //        this.RemoveFromParent();
                    //        btnFinifh.Enable = true;
                    //        return;
                    //    }
                    //    else
                    //    {
                    //        currentKey.bindList.Clear();
                    //    }
                    //}
                    //}
                    //else
                    //{
                    //    foreach (var bindedDev in currentKey.bindList)
                    //    {
                    //        for (int i = 0; i < targetList.Count; i++)
                    //        {
                    //            var de = targetList[i];
                    //            if (de.DeviceAddr == bindedDev.BindMacAddr && de.DeviceEpoint == bindedDev.BindEpoint)
                    //            {
                    //                oldTargetList.Add(de);
                    //                targetList.RemoveAt(i);
                    //                i--;
                    //            }
                    //        }
                    //    }
                    //}
                    //2、配置模式
                    Panel.SetWritableValueResponAllData temp = null;
@@ -237,30 +192,10 @@
                            temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down_Stop);
                            break;
                    }
                    if (temp != null && temp.setWritableValueResponData != null && temp.setWritableValueResponData.Status == 0)
                    if (temp != null && temp.setWritableValueResponData != null)
                    {
                        ////删除被勾掉的数据
                        //foreach (var delDev in oldTargetList)
                        //{
                        //    var delDev1 = new BindObj.BindListResponseObj();
                        //    delDev1.BindType = 0;
                        //    delDev1.BindCluster = currentClusterID;
                        //    delDev1.BindMacAddr = delDev.DeviceAddr;
                        //    delDev1.BindEpoint = delDev.DeviceEpoint;
                        //    var result = await BindInfo.RemoveTargets(delDev1, currentKey);
                        //    if (result == 0)
                        //    {
                        //        var bindSc = currentKey.bindList.Find(obj =>
                        //        (obj.BindType == 0
                        //        && obj.BindCluster == currentClusterID
                        //        && obj.BindMacAddr == delDev.DeviceAddr
                        //        && obj.BindEpoint == delDev.DeviceEpoint
                        //        ));
                        //        currentKey.bindList.Remove(bindSc);
                        //    }
                        //}
                        if (temp.setWritableValueResponData.Status == 0)
                        {
                        //3、绑定新的数据
                        var addBindeDev = new AddBindData();
                        addBindeDev.DeviceAddr = currentKey.DeviceAddr;
@@ -314,7 +249,7 @@
                                                }
                                            }
                                        }
                                        isFinish = true;
                                            //isFinish = true;
                                        break;
                                    case 1:
                                        Application.RunOnMainThread(() =>
@@ -343,7 +278,7 @@
                                                        i--;
                                                    }
                                                }
                                                isFinish = true;
                                                    //isFinish = true;
                                                break;
                                            case 140:
                                                Application.RunOnMainThread(() =>
@@ -354,7 +289,7 @@
                                            default:
                                                Application.RunOnMainThread(() =>
                                                {
                                                    new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
                                                        new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
                                                });
                                                break;
                                        }
@@ -374,7 +309,7 @@
                                    default:
                                        Application.RunOnMainThread(() =>
                                        {
                                            new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
                                                new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
                                        });
                                        break;
                                }
@@ -392,22 +327,37 @@
                        return;
                    }
                }
                    else
                    {
                        Application.RunOnMainThread(() =>
                        {
                            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 { }
                finally
                {
                    if (isFinish)
                    {
                    //if (isFinish)
                    //{
                    //    if (action != null)
                    //    {
                    //        action(currentKey.bindList);
                    //    }
                    //    this.RemoveFromParent();
                    //}
                    //else
                    //{
                    //    this.RemoveFromParent();
                    //}
                        if (action != null)
                        {
                            action(currentKey.bindList);
                        }
                        this.RemoveFromParent();
                    }
                    else
                    {
                        this.RemoveFromParent();
                    }
                    CommonPage.Loading.Hide();
                    btnFinifh.Enable = true;
                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;