黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/PaneTargetsBaseForm.cs
@@ -7,6 +7,9 @@
using static ZigBee.Device.Panel;
namespace Shared.Phone.UserCenter.Device.Bind
{
    /// <summary>
    /// 特殊面板的绑定界面【只能绑定特定类型,每种类型只有一个目标】
    /// </summary>
    public class PaneTargetsBaseForm : BindCommonLayout
    {
        #region  构造函数
@@ -14,7 +17,7 @@
        /// 构造函数
        /// </summary>
        /// <param name="device"></param>
        /// <param name="deviceBindType">1:新风;2:温度传感器;3:湿度传感器;4:PM2.5传感器;5:空调目标</param>
        /// <param name="deviceBindType">1:新风;2:温度传感器;3:湿度传感器;4:PM2.5传感器;5:空调目标,6:地暖目标【暂时没做,因为没有该设备,后期增加】</param>
        /// <param name="bindDev">绑定目标 </param>
        public PaneTargetsBaseForm(CommonDevice device, CommonDevice bindDev, DeviceBind.BindInfo.BindType deviceBindType)
        {
@@ -68,6 +71,7 @@
        /// 3:湿度传感器
        /// 4:PM2.5传感器
        /// 5:空调目标
        /// 6:地暖目标【暂时没做,因为没有该设备,后期增加】
        /// </summary>
        DeviceBind.BindInfo.BindType curDeviceBindType = 0;
        /// <summary>
@@ -93,7 +97,7 @@
        /// <summary>
        /// 楼层列表
        /// </summary>
        Dictionary<string, string> dicFloorList;
        Dictionary<string, string> dicFloorList = new Dictionary<string, string> { };
        /// <summary>
        /// 所有房间中支持被绑定的设备列表
        /// </summary>
@@ -130,7 +134,14 @@
        /// Ac绑定目标回调
        /// </summary>
        public Action<string> actionAcTarget = null;
        /// <summary>
        /// Fh绑定目标回调
        /// </summary>
        public Action<string> actionFhTarget = null;
        /// <summary>
        /// 是否能刷新
        /// </summary>
        private bool canFresh = false;
        #endregion
        #region UI设计
@@ -143,6 +154,7 @@
            //标题栏下的UI
            MidFrameLayoutContent();
            //初始化设备数据
            CommonPage.Loading.Start("");
            InitData();
        }
@@ -169,6 +181,9 @@
                case DeviceBind.BindInfo.BindType.AC:
                    titleText = Language.StringByID(R.MyInternationalizationString.AcTargets);
                    break;
                case DeviceBind.BindInfo.BindType.Fh:
                    titleText = Language.StringByID(R.MyInternationalizationString.uFloorHeatingTarget);
                    break;
            }
            this.TopFrameLayout(this, titleText);
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
@@ -184,7 +199,7 @@
        /// <summary>
        /// 中部UI【标题栏下的UI】
        /// </summary>
        async void MidFrameLayoutContent()
        void MidFrameLayoutContent()
        {
            var btnMidTopLayout = new FrameLayout
            {
@@ -208,6 +223,7 @@
            this.midFrameLayout.AddChidren(midVerticalScrolViewLayout);
            midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
            {
                canFresh = true;
                midVerticalScrolViewLayout.BeginHeaderRefreshing();
                InitData();
            };
@@ -221,20 +237,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 +263,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(12) + btnTipText.GetTextWidth();
            bottomTipPicFrameLayout.Gravity = Gravity.CenterHorizontal;
            EventHandler<MouseEventArgs> eHandlerEmptyTargets = (sender, e) =>
            {
@@ -280,8 +302,8 @@
            btnFinifh = new Button()
            {
                Width = Application.GetRealWidth(907),
                Height = Application.GetRealHeight(127),
                Width = Application.GetRealWidth(907),
                Height = Application.GetRealHeight(127),
                Y = Application.GetRealHeight(49 + 35),
                Gravity = Gravity.CenterHorizontal,
                Radius = (uint)Application.GetRealHeight(127) / 2,
@@ -306,20 +328,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);
@@ -379,7 +400,7 @@
                    }
                }
                if (index == roomTempList.Count - 1 && index > 3)
                if (index == roomTempList.Count - 1 && index > 2)
                {
                    var btnRoomFrameLayoutEmpty = new FrameLayout
                    {
@@ -445,6 +466,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 +487,6 @@
            midVerticalScrolViewLayout.RemoveAll();
            Button oldDevice = null;
            int curIndex = 0;
            if (curRoom.Id == "UndistributedId")
            {
                currentRoomSupportBindDeviceList = BindInfo.GetUndistributeDeviceList(undistruibuteDevList, curDeviceBindType);
@@ -505,7 +527,7 @@
                    X = devicePic.Right + Application.GetRealWidth(20),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextSize = 15,
                    Text = Common.LocalDevice.Current.GetDeviceEpointName(device),
                    Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device),
                };
                rowLayout.AddChidren(btnBindName);
@@ -534,13 +556,13 @@
                {
                    line2.Visible = false;
                }
                if (Common.LocalDevice.Current.CheckDeviceIsOnline(device) == true)
                {
                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.TextBlack;
                }
                else
                {
                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                if (HdlDeviceCommonLogic.Current.CheckDeviceIsOnline(device) == true)
                {
                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.TextBlack;
                }
                else
                {
                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                }
                switch (curDeviceBindType)
                {
@@ -551,14 +573,14 @@
                        devicePic.UnSelectedImagePath = "Device/SensorTemperature.png";
                        if (device.Type == DeviceType.PMSensor)
                        {
                            btnBindName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                            btnBindName.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                        }
                        break;
                    case DeviceBind.BindInfo.BindType.Humidity:
                        devicePic.UnSelectedImagePath = "Device/SensorHumidity.png";
                        if (device.Type == DeviceType.PMSensor)
                        {
                            btnBindName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                            btnBindName.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                        }
                        break;
                    case DeviceBind.BindInfo.BindType.PM:
@@ -640,6 +662,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 +690,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 +723,27 @@
                    {
                        Application.RunOnMainThread(() =>
                        {
                            CommonPage.Loading.Hide();
                            canFresh = false;
                            midVerticalScrolViewLayout.EndHeaderRefreshing();
                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                            CommonPage.Loading.Hide();
                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5007" + ")", 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,12 +752,12 @@
                            var mainKey = bindDev.BindMacAddr + bindDev.BindEpoint;
                            //分配的目标列表
                            if (currentPanelSupportBindDeviceList.Count != 0)
                            if (HdlDeviceCommonLogic.Current.listAllDevice.Count != 0)
                            {
                                var dev = currentPanelSupportBindDeviceList.Find(obj => (obj != null) && (obj.DeviceAddr + obj.DeviceEpoint == mainKey));
                                if (dev != null)
                                {
                                    var device = LocalDevice.Current.GetDevice(dev.DeviceAddr, dev.DeviceEpoint);
                                    var device = HdlDeviceCommonLogic.Current.GetDevice(dev.DeviceAddr, dev.DeviceEpoint);
                                    if (device != null)
                                    {
                                        BindTypeTargetsList(device, bindDev);
@@ -719,7 +771,7 @@
                                var dev = undistruibuteDevList.Find(obj => (obj != null) && (obj.DeviceAddr + obj.DeviceEpoint == mainKey));
                                if (dev != null)
                                {
                                    var device = LocalDevice.Current.GetDevice(dev.DeviceAddr, dev.DeviceEpoint);
                                    var device = HdlDeviceCommonLogic.Current.GetDevice(dev.DeviceAddr, dev.DeviceEpoint);
                                    if (device != null)
                                    {
                                        BindTypeTargetsList(device, bindDev);
@@ -738,38 +790,51 @@
                {
                    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
                        {
                            foreach (var dev in targetList)
                            {
                                //获取本地设备列表
                                var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice;
                                var localDeviceList = HdlDeviceCommonLogic.Current.listAllDevice;
                                var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == dev.DeviceAddr && obj.DeviceEpoint == dev.DeviceEpoint);
                                if (tempDev != null)
                                {
@@ -779,11 +844,33 @@
                                    {
                                        curControlDev.currentSelectRoomId = tempDevRoom.Id;
                                        curControlDev.currentSelectFloorId = tempDevRoom.FloorId;
                                    }
                                    else
                                    {
                                        curControlDev.currentSelectRoomId = "UndistributedId";
                                    }
                                    else
                                    {
                                        curControlDev.currentSelectRoomId = "UndistributedId";
                                    }
                                }
                                if (canUpdateBindName)
                                {
                                    //更新外面目标名字:具体名字【刷新本地界面会导致外部目标变化】
                                    string bindName = HdlDeviceCommonLogic.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 +885,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 +910,94 @@
                    try
                    {
                        Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
                        if (oldTargetList.Count != 0)
                        if (btnTipPic.IsSelected)
                        {
                            //删除取消的目标
                            foreach (var bd in oldTargetList)
                            //当绑定空目标,要删除已经存在按键的目标
                            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) + "(" + "5003_1" + ")", 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) + "(" + "5003_3" + ")", 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 +1006,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) + "(" + "5003_2" + ")", 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 +1033,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 +1044,8 @@
                            CommonPage.Loading.Hide();
                        });
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                });
            }
@@ -1014,11 +1074,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);
@@ -1027,10 +1093,18 @@
                                {
                                    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;
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5003_4" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                        CommonPage.Loading.Hide();
                                        ShowReLoadView();
                                        ReLoadAction += () =>
                                        {
                                            this.midFrameLayout.RemoveAll();
                                            //初始化设备数据
                                            CommonPage.Loading.Start("");
                                            MidFrameLayoutContent();
                                            InitData(true);
                                        };
                                    });
                                    return;
                                }
@@ -1046,91 +1120,50 @@
                                                {
                                                    Application.RunOnMainThread(() =>
                                                    {
                                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5003_6" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                        btnFinifh.Enable = true;
                                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                        CommonPage.Loading.Hide();
                                                    });
                                                    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) + "(" + "5003_5" + ")", 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) + "(" + "5003_7" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    CommonPage.Loading.Hide();
                                });
                                return;
                            }
                        }
@@ -1163,19 +1196,19 @@
                            addBindInfo.BindType = 0;
                            addBindInfo.BindMacAddr = de.DeviceAddr;
                            addBindInfo.BindEpoint = de.DeviceEpoint;
                            addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de);
                            addBindeDev.BindName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(de);
                            switch (curDeviceBindType)
                            {
                                case BindInfo.BindType.Temperature:
                                    if (de.Type == DeviceType.PMSensor)
                                    {
                                        addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                                        addBindeDev.BindName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                                    }
                                    break;
                                case BindInfo.BindType.Humidity:
                                    if (de.Type == DeviceType.PMSensor)
                                    {
                                        addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                                        addBindeDev.BindName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                                    }
                                    break;
                            }
@@ -1203,10 +1236,17 @@
                            Application.RunOnMainThread(() =>
                            {
                                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;
                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5001" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                ShowReLoadView();
                                ReLoadAction += () =>
                                {
                                    this.midFrameLayout.RemoveAll();
                                    //初始化设备数据
                                    CommonPage.Loading.Start("");
                                    MidFrameLayoutContent();
                                    InitData(true);
                                };
                            });
                        }
                        else
@@ -1215,39 +1255,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(() =>
                                {
@@ -1267,7 +1276,7 @@
                                    new Tip()
                                    {
                                        MaxWidth = 150,
                                        Text = Language.StringByID(R.MyInternationalizationString.BindFailed),
                                        Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5001_1" + ")",
                                        Direction = AMPopTipDirection.None,
                                        CloseTime = 1
                                    }.Show(CommonPage.Instance);
@@ -1283,7 +1292,7 @@
                                    new Tip()
                                    {
                                        MaxWidth = 150,
                                        Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError),
                                        Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError) + "(" + "5001_2" + ")",
                                        Direction = AMPopTipDirection.None,
                                        CloseTime = 1
                                    }.Show(CommonPage.Instance);
@@ -1308,9 +1317,9 @@
        }
        /// <summary>
        /// 目标为空时的文本显示
        /// 目标为文本显示
        /// </summary>
        void EmptyTargesMess()
        void EmptyTargesMess1()
        {
            switch (curDeviceBindType)
            {
@@ -1346,6 +1355,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>
        /// 绑定目标列表
@@ -1358,13 +1406,12 @@
            {
                case BindInfo.BindType.FreshAir:
                    //获取设备类型的
                    var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                    var deviceEnumInfo = HdlDeviceCommonLogic.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                    //新风面板的新风设备,则不显示
                    if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                    if (deviceEnumInfo.ConcreteType != DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                    {
                        if (device.Type == DeviceType.FreshAir)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1375,7 +1422,6 @@
                        var bDev = device as TemperatureSensor;
                        if (bDev.SensorDiv == 1)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1383,7 +1429,6 @@
                    {
                        if (bindDev.BindCluster == 1026)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1394,20 +1439,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 +1459,6 @@
                    {
                        if (bindDev.BindCluster == 1066)
                        {
                            targetList.Add(device);
                            oldTargetList.Add(device);
                        }
                    }
@@ -1427,12 +1468,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)
            {
@@ -1451,7 +1498,7 @@
                return;
            }
            //获取本地设备列表
            var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice;
            var localDeviceList = HdlDeviceCommonLogic.Current.listAllDevice;
            var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == bindDev.DeviceAddr && obj.DeviceEpoint == bindDev.DeviceEpoint);
            if (tempDev != null)
            {
@@ -1492,14 +1539,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 移除方法