黄学彪
2020-07-13 23420922845c9e77019a55c3b3e3271eb1ec261e
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/PaneTargetsBaseForm.cs
@@ -93,7 +93,7 @@
        /// <summary>
        /// 楼层列表
        /// </summary>
        Dictionary<string, string> dicFloorList;
        Dictionary<string, string> dicFloorList = new Dictionary<string, string> { };
        /// <summary>
        /// 所有房间中支持被绑定的设备列表
        /// </summary>
@@ -130,7 +130,10 @@
        /// Ac绑定目标回调
        /// </summary>
        public Action<string> actionAcTarget = null;
        /// <summary>
        /// 是否能刷新
        /// </summary>
        private bool canFresh = false;
        #endregion
        #region UI设计
@@ -143,6 +146,7 @@
            //标题栏下的UI
            MidFrameLayoutContent();
            //初始化设备数据
            CommonPage.Loading.Start("");
            InitData();
        }
@@ -184,7 +188,7 @@
        /// <summary>
        /// 中部UI【标题栏下的UI】
        /// </summary>
        async void MidFrameLayoutContent()
        void MidFrameLayoutContent()
        {
            var btnMidTopLayout = new FrameLayout
            {
@@ -208,6 +212,7 @@
            this.midFrameLayout.AddChidren(midVerticalScrolViewLayout);
            midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
            {
                canFresh = true;
                midVerticalScrolViewLayout.BeginHeaderRefreshing();
                InitData();
            };
@@ -221,20 +226,24 @@
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout);
            var bottomTipPicFrameLayout = new FrameLayout()
            {
                Height = Application.GetMinReal(40 + 44 - 10),
            };
            bottomFrameLayout.AddChidren(bottomTipPicFrameLayout);
            var btnTipPicFrameLayout = new FrameLayout()
            {
                Width = Application.GetMinReal(40 + 23 + 37),
                Width = Application.GetMinReal(23 + 37),
                Height = Application.GetMinReal(40 + 44 - 10),
                X = Application.GetMinReal(383 - 37),
            };
            bottomFrameLayout.AddChidren(btnTipPicFrameLayout);
            bottomTipPicFrameLayout.AddChidren(btnTipPicFrameLayout);
            btnTipPic = new Button()
            {
                Width = Application.GetMinReal(40),
                Height = Application.GetMinReal(40),
                X = Application.GetMinReal(40),
                Y = Application.GetRealHeight(22),
                Y = Application.GetRealHeight(19),
                UnSelectedImagePath = "BindPic/EmptyTargets.png",
                SelectedImagePath = "BindPic/EmptyTargetsSelected.png",
            };
@@ -243,14 +252,16 @@
            btnTipText = new Button()
            {
                Height = Application.GetRealHeight(84 - 10),
                X = Application.GetMinReal(444),
                X = Application.GetMinReal(58),
                Width = Application.GetMinReal(1080 - 446),
                TextID = R.MyInternationalizationString.BindEmptyTargets,
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,//XMTopTitleText
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                TextSize = 12,
                TextAlignment = TextAlignment.CenterLeft,
            };
            bottomFrameLayout.AddChidren(btnTipText);
            bottomTipPicFrameLayout.AddChidren(btnTipText);
            bottomTipPicFrameLayout.Width = btnTipPicFrameLayout.Width + Application.GetMinReal(2) + btnTipText.GetTextWidth();
            bottomTipPicFrameLayout.Gravity = Gravity.CenterHorizontal;
            EventHandler<MouseEventArgs> eHandlerEmptyTargets = (sender, e) =>
            {
@@ -306,20 +317,19 @@
        void RefreshRoomList()
        {
            Room curRoom = null;
            if (supportRoomList.Count == 0)
            {
                return;
            }
            btnHorizontalScrolViewLayout.RemoveAll();
            Button curentOldRoom = null;
            FrameLayout curentOldRoomFrameLayout = null;
            int index = 0;
            var roomTempList = BindInfo.GetSupportRoomList(curControlDev, supportRoomList, curDeviceBindType);
            Room slectedRoom = null;
            var roomUn = new Room();
            roomUn.Name = Language.StringByID(R.MyInternationalizationString.Undistributed);
            roomUn.Id = "UndistributedId";
            List<Room> roomTempList = new List<Room> { };
            if (supportRoomList.Count != 0)
            {
                roomTempList = BindInfo.GetSupportRoomList(curControlDev, supportRoomList, curDeviceBindType);
            }
            if (undistruibuteDevList.Count != 0)
            {
                roomTempList.Add(roomUn);
@@ -445,6 +455,8 @@
                    var btn = (Button)frame.GetChildren(0);
                    frame.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                    btn.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
                    curentOldRoom = btn;
                    curentOldRoomFrameLayout = frame;
                }
                else
                {
@@ -464,7 +476,6 @@
            midVerticalScrolViewLayout.RemoveAll();
            Button oldDevice = null;
            int curIndex = 0;
            if (curRoom.Id == "UndistributedId")
            {
                currentRoomSupportBindDeviceList = BindInfo.GetUndistributeDeviceList(undistruibuteDevList, curDeviceBindType);
@@ -640,6 +651,26 @@
                btnChoose.MouseUpEventHandler += hander;
                curIndex++;
            }
            //首次是否能点击保存
            if (targetList.Count == 0)
            {
                if (targetListTemp.Count == 0)
                {
                    btnFinifh.Enable = false;
                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                }
                else
                {
                    btnFinifh.Enable = true;
                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                }
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
        }
        #endregion
@@ -648,23 +679,19 @@
        /// <summary>
        /// 初始化设备数据
        /// </summary>
        void InitData()
        void InitData(bool canUpdateBindName = false)
        {
            System.Threading.Tasks.Task.Run(async () =>
            {
                try
                {
                    Application.RunOnMainThread(() =>
                    {
                        CommonPage.Loading.Start("");
                    });
                    //获取被绑目标等信息
                    BindDevInfo(curBindDevice);
                    //获取楼层
                    //获取楼层
                    dicFloorList = HdlRoomLogic.Current.GetFloorSortList();
                    //获取楼层中房间列表
                    supportRoomList = BindInfo.GetFloorRoomList();
                    //获取房间列表
                    supportRoomList = BindInfo.GetSupportRoomList();
                    //获取所有房间中匹配的能绑的目标
                    currentPanelSupportBindDeviceList = BindInfo.GetAllRoomSupportDeviceList(currentPanelSupportBindDeviceList, supportRoomList, curDeviceBindType);
@@ -685,13 +712,27 @@
                    {
                        Application.RunOnMainThread(() =>
                        {
                            CommonPage.Loading.Hide();
                            canFresh = false;
                            midVerticalScrolViewLayout.EndHeaderRefreshing();
                            CommonPage.Loading.Hide();
                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                            this.midFrameLayout.RemoveAll();
                            ShowReLoadView();
                            ReLoadAction += () =>
                            {
                                this.midFrameLayout.RemoveAll();
                                //初始化设备数据
                                CommonPage.Loading.Start("");
                                MidFrameLayoutContent();
                                InitData(true);
                            };
                        });
                    }
                    targetList.Clear();
                    oldTargetList.Clear();
                    //选中目标列表 targetList
                    if (curControlDev.bindList.Count != 0)
                    {
@@ -700,7 +741,7 @@
                            var mainKey = bindDev.BindMacAddr + bindDev.BindEpoint;
                            //分配的目标列表
                            if (currentPanelSupportBindDeviceList.Count != 0)
                            if (Shared.Common.LocalDevice.Current.listAllDevice.Count != 0)
                            {
                                var dev = currentPanelSupportBindDeviceList.Find(obj => (obj != null) && (obj.DeviceAddr + obj.DeviceEpoint == mainKey));
                                if (dev != null)
@@ -738,31 +779,44 @@
                {
                    Application.RunOnMainThread(() =>
                    {
                        BindDownFrameLayout(this.midFrameLayout, curControlDev, dicFloorList, ref btnFloorText);
                        //楼层侧边栏绑定
                        if (!canFresh)
                        {
                            BindDownFrameLayout(this.midFrameLayout, curControlDev, dicFloorList, ref btnFloorText);
                        }
                        ChooseFloorAction += (floorId, btnMethodText) =>
                        {
                            btnFloorText.Text = string.Empty;
                            btnFloorText.Text = dicFloorList[floorId];
                            //获取楼层中房间列表
                            supportRoomList = BindInfo.GetFloorRoomList();
                            //获取房间列表
                            supportRoomList = BindInfo.GetSupportRoomList();
                            //获取本地未分配的支持当前类型的绑定设备列表
                            undistruibuteDevList = BindInfo.GetUndistributeDeviceList(undistruibuteDevList, curDeviceBindType);
                            RefreshRoomList();
                        };
                        //默认楼层显示
                        if (BindInfo.GetCurrentSelectFloorIdName() != null)
                        {
                            Application.RunOnMainThread(() =>
                            {
                                btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
                            });
                        }
                        //首次是否能点击保存
                        if (targetList.Count == 0)
                        {
                            curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
                            curControlDev.currentSelectRoomId = null;
                            if (BindInfo.GetCurrentSelectFloorIdName() != null)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
                                });
                            }
                            btnFinifh.Enable = false;
                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                            //更新外面目标名字:无
                            if (canUpdateBindName)
                            {
                                TargesBindName();
                            }
                        }
                        else
                        {
@@ -785,6 +839,28 @@
                                        curControlDev.currentSelectRoomId = "UndistributedId";
                                    }
                                }
                                if (canUpdateBindName)
                                {
                                    //更新外面目标名字:具体名字【刷新本地界面会导致外部目标变化】
                                    string bindName = Common.LocalDevice.Current.GetDeviceEpointName(dev);
                                    switch (curDeviceBindType)
                                    {
                                        case BindInfo.BindType.Temperature:
                                            if (dev.Type == DeviceType.PMSensor)
                                            {
                                                bindName += "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                                            }
                                            break;
                                        case BindInfo.BindType.Humidity:
                                            if (dev.Type == DeviceType.PMSensor)
                                            {
                                                bindName += "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                                            }
                                            break;
                                    }
                                    TargesBindName(bindName);
                                }
                            }
                            if (!string.IsNullOrEmpty(curControlDev.currentSelectFloorId))
                            {
@@ -798,15 +874,11 @@
                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        }
                        //获取楼层中房间列表
                        if (supportRoomList.Count != 0)
                        {
                            RefreshRoomList();
                        }
                        CommonPage.Loading.Hide();
                        RefreshRoomList();
                        canFresh = false;
                        midVerticalScrolViewLayout.EndHeaderRefreshing();
                        CommonPage.Loading.Hide();
                    });
                }
            });
@@ -827,75 +899,94 @@
                    try
                    {
                        Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
                        if (oldTargetList.Count != 0)
                        if (btnTipPic.IsSelected)
                        {
                            //删除取消的目标
                            foreach (var bd in oldTargetList)
                            //删除情况1:绑定空目标必须取消按键中已经存在的目标
                            if (oldTargetList.Count != 0)
                            {
                                var delDevice = new DelDeviceBindData();
                                delDevice.DeviceAddr = curControlDev.DeviceAddr;
                                delDevice.Epoint = curControlDev.DeviceEpoint;
                                //删除按键中已经绑定的目标个数【删除成功个数】
                                int sOldTargetListCount = 0;
                                var removeDevice = new RemoveBindListObj();
                                removeDevice.BindType = 0;
                                switch (curDeviceBindType)
                                foreach (var bd in oldTargetList)
                                {
                                    case BindInfo.BindType.FreshAir:
                                        removeDevice.BindCluster = 514;
                                        break;
                                    case BindInfo.BindType.Temperature:
                                        removeDevice.BindCluster = 1026;
                                        break;
                                    case BindInfo.BindType.Humidity:
                                        removeDevice.BindCluster = 1029;
                                        break;
                                    case BindInfo.BindType.PM:
                                        removeDevice.BindCluster = 1066;
                                        break;
                                    case BindInfo.BindType.AC:
                                        removeDevice.BindCluster = 513;//Ac需要绑定2个簇513和514
                                        break;
                                }
                                removeDevice.BindMacAddr = bd.DeviceAddr;
                                removeDevice.BindEpoint = bd.DeviceEpoint;
                                delDevice.RemoveBindList.Add(removeDevice);
                                    var delDevice = DelBindDevice(bd);
                                if (curDeviceBindType == BindInfo.BindType.AC)
                                {
                                    //要移除空调:需要移除513,514
                                    var removeDevice3 = new RemoveBindListObj();
                                    removeDevice3.BindCluster = 514;
                                    removeDevice3.BindType = 0;
                                    removeDevice3.BindMacAddr = bd.DeviceAddr;
                                    removeDevice3.BindEpoint = bd.DeviceEpoint;
                                    delDevice.RemoveBindList.Add(removeDevice3);
                                }
                                    //此次按键中需要移除的目标个数【同一个目标携带的多个功能删除成功的个数】
                                    int sRemoveBindListCount = 0;
                                var delResult = new DelDeviceBindResponseAllData();
                                delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
                                if (delResult == null)
                                {
                                    Application.RunOnMainThread(() =>
                                    var delResult = new DelDeviceBindResponseAllData();
                                    delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
                                    if (delResult == null)
                                    {
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                        btnFinifh.Enable = true;
                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        CommonPage.Loading.Hide();
                                    });
                                    return;
                                }
                                else
                                {
                                    if (delResult.removeBindResultResponseData == null)
                                    {
                                        if (delResult.delDeviceBindResponseData != null)
                                        Application.RunOnMainThread(() =>
                                        {
                                            foreach (var d in delResult.delDeviceBindResponseData.RemoveBindList)
                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                            CommonPage.Loading.Hide();
                                            ShowReLoadView();
                                            ReLoadAction += () =>
                                            {
                                                if (d.Result == 0 || d.Result == 1)
                                                this.midFrameLayout.RemoveAll();
                                                //初始化设备数据
                                                CommonPage.Loading.Start("");
                                                MidFrameLayoutContent();
                                                InitData(true);
                                            };
                                        });
                                        return;
                                    }
                                    else
                                    {
                                        if (delResult.removeBindResultResponseData == null)
                                        {
                                            if (delResult.delDeviceBindResponseData != null)
                                            {
                                                foreach (var d in delResult.delDeviceBindResponseData.RemoveBindList)
                                                {
                                                    EmptyTargesMess();
                                                    if (d.Result == 0 || d.Result == 1)
                                                    {
                                                        sRemoveBindListCount++;
                                                        if (sRemoveBindListCount == delDevice.RemoveBindList.Count)
                                                        {
                                                            sOldTargetListCount++;
                                                        }
                                                        //按键目标中的该类型个数都删除成功
                                                        if (sOldTargetListCount == oldTargetList.Count)
                                                        {
                                                            TargesBindName();
                                                            Application.RunOnMainThread(() =>
                                                            {
                                                                CommonPage.Loading.Hide();
                                                                btnFinifh.Enable = true;
                                                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                                this.RemoveFromParent();
                                                            });
                                                        }
                                                    }
                                                    else
                                                    {
                                                        Application.RunOnMainThread(() =>
                                                        {
                                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                            btnFinifh.Enable = true;
                                                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                            CommonPage.Loading.Hide();
                                                        });
                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (delResult.removeBindResultResponseData.Result == 0)
                                            {
                                                sOldTargetListCount++;
                                                //按键目标中的该类型个数都删除成功
                                                if (sOldTargetListCount == oldTargetList.Count)
                                                {
                                                    TargesBindName();
                                                    Application.RunOnMainThread(() =>
                                                    {
                                                        CommonPage.Loading.Hide();
@@ -904,54 +995,26 @@
                                                        this.RemoveFromParent();
                                                    });
                                                }
                                                else
                                                {
                                                    Application.RunOnMainThread(() =>
                                                    {
                                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                        btnFinifh.Enable = true;
                                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                        CommonPage.Loading.Hide();
                                                    });
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (delResult.removeBindResultResponseData.Result == 0)
                                        {
                                            EmptyTargesMess();
                                            Application.RunOnMainThread(() =>
                                            else
                                            {
                                                CommonPage.Loading.Hide();
                                                btnFinifh.Enable = true;
                                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                this.RemoveFromParent();
                                            });
                                        }
                                        else
                                        {
                                            Application.RunOnMainThread(() =>
                                            {
                                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                btnFinifh.Enable = true;
                                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                CommonPage.Loading.Hide();
                                            });
                                            return;
                                                Application.RunOnMainThread(() =>
                                                {
                                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                    btnFinifh.Enable = true;
                                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                    CommonPage.Loading.Hide();
                                                });
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (btnTipPic.IsSelected)
                            else
                            {
                                EmptyTargesMess();
                                //按键中没有目标直接绑定空目标
                                TargesBindName();
                                Application.RunOnMainThread(() =>
                                {
                                    CommonPage.Loading.Hide();
@@ -959,22 +1022,6 @@
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    this.RemoveFromParent();
                                });
                            }
                            else
                            {
                                //没有目标提示
                                Application.RunOnMainThread(() =>
                                {
                                    var myTip = new Tip();
                                    myTip.Direction = AMPopTipDirection.None;
                                    myTip.CloseTime = 2;
                                    myTip.Text = Language.StringByID(R.MyInternationalizationString.BindDeviceTargetIsEmpty);
                                    myTip.Show(Common.CommonPage.Instance);
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    CommonPage.Loading.Hide();
                                });
                                return;
                            }
                        }
                    }
@@ -986,6 +1033,8 @@
                            CommonPage.Loading.Hide();
                        });
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                });
            }
@@ -1014,11 +1063,17 @@
                    {
                        Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
                        //删除已经存在的目标
                        //删除情况2:按键之前已经存在的目标
                        if (oldTargetList.Count != 0)
                        {
                            //删除按键中已经绑定的目标个数【删除成功个数】
                            int sOldTargetListCount = 0;
                            foreach (var bd in oldTargetList)
                            {
                                //此次按键中需要移除的目标个数【同一个目标携带的多个功能删除成功的个数】
                                int sRemoveBindListCount = 0;
                                var delDevice = DelBindDevice(bd);
                                var delResult = new DelDeviceBindResponseAllData();
                                delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
@@ -1028,9 +1083,17 @@
                                    Application.RunOnMainThread(() =>
                                    {
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                        btnFinifh.Enable = true;
                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        CommonPage.Loading.Hide();
                                        ShowReLoadView();
                                        ReLoadAction += () =>
                                        {
                                            this.midFrameLayout.RemoveAll();
                                            //初始化设备数据
                                            CommonPage.Loading.Start("");
                                            MidFrameLayoutContent();
                                            InitData(true);
                                        };
                                    });
                                    return;
                                }
@@ -1053,84 +1116,43 @@
                                                    });
                                                    return;
                                                }
                                                sRemoveBindListCount++;
                                                if (sRemoveBindListCount == delDevice.RemoveBindList.Count)
                                                {
                                                    sOldTargetListCount++;
                                                }
                                            }
                                        }
                                    }
                                }
                                if (delResult != null && delResult.removeBindResultResponseData != null)
                                {
                                    if (delResult.removeBindResultResponseData.Result != 0)
                                    else
                                    {
                                        Application.RunOnMainThread(() =>
                                        if (delResult.removeBindResultResponseData.Result != 0)
                                        {
                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                            btnFinifh.Enable = true;
                                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                            CommonPage.Loading.Hide();
                                        });
                                        return;
                                            Application.RunOnMainThread(() =>
                                            {
                                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                btnFinifh.Enable = true;
                                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                CommonPage.Loading.Hide();
                                            });
                                            return;
                                        }
                                        sOldTargetListCount++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            //检测已经绑定的目标是否不在本地或者没有分配到任何房间中
                            //此时需要删除已经被绑定到目标,才能继续绑定新目标
                            if (curBindDevice != null)
                            {
                                var delDevice = DelBindDevice(curBindDevice);
                                var delResult = new DelDeviceBindResponseAllData();
                                delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
                                if (delResult == null)
                            if (sOldTargetListCount != oldTargetList.Count)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    Application.RunOnMainThread(() =>
                                    {
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                        btnFinifh.Enable = true;
                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        CommonPage.Loading.Hide();
                                    });
                                    return;
                                }
                                else
                                {
                                    if (delResult.removeBindResultResponseData == null)
                                    {
                                        if (delResult.delDeviceBindResponseData != null)
                                        {
                                            foreach (var d in delResult.delDeviceBindResponseData.RemoveBindList)
                                            {
                                                if (d.Result != 0 && d.Result != 1)
                                                {
                                                    Application.RunOnMainThread(() =>
                                                    {
                                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                        btnFinifh.Enable = true;
                                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                        CommonPage.Loading.Hide();
                                                    });
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                }
                                if (delResult != null && delResult.removeBindResultResponseData != null)
                                {
                                    if (delResult.removeBindResultResponseData.Result != 0)
                                    {
                                        Application.RunOnMainThread(() =>
                                        {
                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                            btnFinifh.Enable = true;
                                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                            CommonPage.Loading.Hide();
                                        });
                                        return;
                                    }
                                }
                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    CommonPage.Loading.Hide();
                                });
                                return;
                            }
                        }
@@ -1204,9 +1226,16 @@
                            {
                                CommonPage.Loading.Hide();
                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                btnFinifh.Enable = true;
                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                return;
                                ShowReLoadView();
                                ReLoadAction += () =>
                                {
                                    this.midFrameLayout.RemoveAll();
                                    //初始化设备数据
                                    CommonPage.Loading.Start("");
                                    MidFrameLayoutContent();
                                    InitData(true);
                                };
                            });
                        }
                        else
@@ -1215,39 +1244,8 @@
                            {
                                targetList.Clear();
                                targetListTemp.Clear();
                                switch (curDeviceBindType)
                                {
                                    case BindInfo.BindType.FreshAir:
                                        if (actionFreshAirTarget != null)
                                        {
                                            actionFreshAirTarget(addBindeDev.BindName);
                                        }
                                        break;
                                    case BindInfo.BindType.Temperature:
                                        if (actionTemperatureTarget != null)
                                        {
                                            actionTemperatureTarget(addBindeDev.BindName);
                                        }
                                        break;
                                    case BindInfo.BindType.Humidity:
                                        if (actionHumidityTarget != null)
                                        {
                                            actionHumidityTarget(addBindeDev.BindName);
                                        }
                                        break;
                                    case BindInfo.BindType.PM:
                                        if (actionPMTarget != null)
                                        {
                                            actionPMTarget(addBindeDev.BindName);
                                        }
                                        break;
                                    case BindInfo.BindType.AC:
                                        if (actionAcTarget != null)
                                        {
                                            actionAcTarget(addBindeDev.BindName);
                                        }
                                        break;
                                }
                                TargesBindName(addBindeDev.BindName);
                                Application.RunOnMainThread(() =>
                                {
@@ -1308,9 +1306,9 @@
        }
        /// <summary>
        /// 目标为空时的文本显示
        /// 目标为文本显示
        /// </summary>
        void EmptyTargesMess()
        void EmptyTargesMess1()
        {
            switch (curDeviceBindType)
            {
@@ -1346,6 +1344,45 @@
                    break;
            }
        }
        /// <summary>
        /// 目标为文本显示
        /// </summary>
        void TargesBindName(string name = "")
        {
            switch (curDeviceBindType)
            {
                case BindInfo.BindType.FreshAir:
                    if (actionFreshAirTarget != null)
                    {
                        actionFreshAirTarget(name);
                    }
                    break;
                case BindInfo.BindType.Temperature:
                    if (actionTemperatureTarget != null)
                    {
                        actionTemperatureTarget(name);
                    }
                    break;
                case BindInfo.BindType.Humidity:
                    if (actionHumidityTarget != null)
                    {
                        actionHumidityTarget(name);
                    }
                    break;
                case BindInfo.BindType.PM:
                    if (actionPMTarget != null)
                    {
                        actionPMTarget(name);
                    }
                    break;
                case BindInfo.BindType.AC:
                    if (actionAcTarget != null)
                    {
                        actionAcTarget(name);
                    }
                    break;
            }
        }
        /// <summary>
        /// 绑定目标列表
@@ -1364,7 +1401,6 @@
                    {
                        if (device.Type == DeviceType.FreshAir)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1375,7 +1411,6 @@
                        var bDev = device as TemperatureSensor;
                        if (bDev.SensorDiv == 1)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1383,7 +1418,6 @@
                    {
                        if (bindDev.BindCluster == 1026)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1394,20 +1428,17 @@
                        var bDev = device as TemperatureSensor;
                        if (bDev.SensorDiv == 2)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
                    if (device.Type == DeviceType.FreshAirHumiditySensor)
                    {
                        targetList.Add(device);
                        oldTargetList.Add(device);
                    }
                    if (device.Type == DeviceType.PMSensor)
                    {
                        if (bindDev.BindCluster == 1029)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1417,7 +1448,6 @@
                    {
                        if (bindDev.BindCluster == 1066)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1427,12 +1457,18 @@
                    {
                        if (bindDev.BindCluster == 513)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
                    break;
            }
            targetList.Clear();
            if (oldTargetList.Count != 0)
            {
                targetList.Add(oldTargetList[0]);
            }
            targetListTemp.Clear();
            foreach (var d in targetList)
            {
@@ -1492,14 +1528,26 @@
                    removeDevice.BindCluster = 1066;
                    break;
                case BindInfo.BindType.AC:
                    removeDevice.BindCluster = 513;
                    removeDevice.BindCluster = 513;//Ac需要绑定2个簇513和514
                    break;
            }
            removeDevice.BindMacAddr = bd.DeviceAddr;
            removeDevice.BindEpoint = bd.DeviceEpoint;
            delDevice.RemoveBindList.Add(removeDevice);
            if (curDeviceBindType == BindInfo.BindType.AC)
            {
                //要移除空调:需要移除513,514
                var removeDevice3 = new RemoveBindListObj();
                removeDevice3.BindCluster = 514;
                removeDevice3.BindType = 0;
                removeDevice3.BindMacAddr = bd.DeviceAddr;
                removeDevice3.BindEpoint = bd.DeviceEpoint;
                delDevice.RemoveBindList.Add(removeDevice3);
            }
            return delDevice;
        }
        #endregion
        #region 移除方法