ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/PaneTargetsBaseForm.cs
New file
@@ -0,0 +1,1579 @@
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.UserCenter.DeviceBind;
using ZigBee.Device;
using static ZigBee.Device.BindObj;
using static ZigBee.Device.Panel;
namespace Shared.Phone.UserCenter.Device.Bind
{
    /// <summary>
    /// 特殊面板的绑定界面【只能绑定特定类型,每种类型只有一个目标】
    /// </summary>
    public class PaneTargetsBaseForm : BindCommonLayout
    {
        #region  构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="device"></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)
        {
            curControlDev = new Panel();
            curControlDev.DeviceAddr = device.DeviceAddr;
            curControlDev.DeviceEpoint = device.DeviceEpoint;
            curControlDev.CurrentGateWayId = device.CurrentGateWayId;
            curControlDev.Type = device.Type;
            this.curBindDevice = bindDev;
            this.curDeviceBindType = deviceBindType;
        }
        #endregion
        #region  变量申明
        /// <summary>
        /// 控制设备
        /// </summary>
        Panel curControlDev;
        /// <summary>
        /// 当前被绑设备
        /// </summary>
        CommonDevice curBindDevice;
        /// <summary>
        /// 显示被绑定设备或场景的view
        /// </summary>
        VerticalRefreshLayout midVerticalScrolViewLayout;
        /// <summary>
        /// 显示房间的view
        /// </summary>
        HorizontalScrolViewLayout btnHorizontalScrolViewLayout;
        /// <summary>
        /// 按键配置的目标列表
        /// </summary>
        List<CommonDevice> targetList = new List<CommonDevice>();
        /// <summary>
        /// 按键配置的目标临时列表
        /// </summary>
        List<CommonDevice> targetListTemp = new List<CommonDevice>();
        /// <summary>
        /// 临时房间
        /// </summary>
        Room tempRoom;
        /// <summary>
        /// 面板中已经存在的目标列表
        /// </summary>
        List<CommonDevice> oldTargetList = new List<CommonDevice>();
        /// <summary>
        /// 当前设备绑定类型
        /// 1:新风
        /// 2:温度传感器
        /// 3:湿度传感器
        /// 4:PM2.5传感器
        /// 5:空调目标
        /// 6:地暖目标【暂时没做,因为没有该设备,后期增加】
        /// </summary>
        DeviceBind.BindInfo.BindType curDeviceBindType = 0;
        /// <summary>
        /// 本地房间列表
        /// </summary>
        List<Room> supportRoomList = new List<Room>();
        /// <summary>
        /// 保存完成按钮
        /// </summary>
        Button btnFinifh;
        /// <summary>
        /// 楼层文本
        /// </summary>
        Button btnFloorText;
        /// <summary>
        /// 空目标按钮
        /// </summary>
        Button btnTipPic;
        /// <summary>
        /// 空目标文本
        /// </summary>
        Button btnTipText;
        /// <summary>
        /// 楼层列表
        /// </summary>
        Dictionary<string, string> dicFloorList = new Dictionary<string, string> { };
        /// <summary>
        /// 所有房间中支持被绑定的设备列表
        /// </summary>
        List<CommonDevice> currentPanelSupportBindDeviceList = new List<CommonDevice>();
        /// <summary>
        /// 未分配的设备列表
        /// </summary>
        List<CommonDevice> undistruibuteDevList = new List<CommonDevice>();
        /// <summary>
        /// 当前房间中支持被绑定的设备列表
        /// </summary>
        List<CommonDevice> currentRoomSupportBindDeviceList = new List<CommonDevice>();
        /// <summary>
        /// 面板中存在的键值
        /// </summary>
        List<String> panelBindListKey = null;
        /// <summary>
        /// 新风绑定目标回调
        /// </summary>
        public Action<string> actionFreshAirTarget = null;
        /// <summary>
        /// 温度绑定目标回调
        /// </summary>
        public Action<string> actionTemperatureTarget = null;
        /// <summary>
        /// 湿度绑定目标回调
        /// </summary>
        public Action<string> actionHumidityTarget = null;
        /// <summary>
        /// PM绑定目标回调
        /// </summary>
        public Action<string> actionPMTarget = null;
        /// <summary>
        /// Ac绑定目标回调
        /// </summary>
        public Action<string> actionAcTarget = null;
        /// <summary>
        /// Fh绑定目标回调
        /// </summary>
        public Action<string> actionFhTarget = null;
        /// <summary>
        /// 是否能刷新
        /// </summary>
        private bool canFresh = false;
        #endregion
        #region UI设计
        /// <summary>
        /// 目标页显示
        /// </summary>
        public void Show()
        {
            TitleUI();
            //标题栏下的UI
            MidFrameLayoutContent();
            //初始化设备数据
            CommonPage.Loading.Start("");
            InitData();
        }
        /// <summary>
        /// 标题栏
        /// </summary>
        void TitleUI()
        {
            string titleText = "";
            switch (curDeviceBindType)
            {
                case DeviceBind.BindInfo.BindType.FreshAir:
                    titleText = Language.StringByID(R.MyInternationalizationString.uNewWindTarget);
                    break;
                case DeviceBind.BindInfo.BindType.Temperature:
                    titleText = Language.StringByID(R.MyInternationalizationString.TemperatureSource);
                    break;
                case DeviceBind.BindInfo.BindType.Humidity:
                    titleText = Language.StringByID(R.MyInternationalizationString.HumiditySource);
                    break;
                case DeviceBind.BindInfo.BindType.PM:
                    titleText = Language.StringByID(R.MyInternationalizationString.PM25Source);
                    break;
                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) =>
            {
                RemoveFromParent();
            };
            this.btnTitle.Width = Application.GetRealWidth(1080 - 161 - 300);
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
        }
        /// <summary>
        /// 中部UI【标题栏下的UI】
        /// </summary>
        void MidFrameLayoutContent()
        {
            var btnMidTopLayout = new FrameLayout
            {
                Height = Application.GetRealHeight(389 - 184),
            };
            this.midFrameLayout.AddChidren(btnMidTopLayout);
            //房间栏
            btnHorizontalScrolViewLayout = new HorizontalScrolViewLayout
            {
                X = Application.GetRealWidth(58),
            };
            btnMidTopLayout.AddChidren(btnHorizontalScrolViewLayout);
            //设备栏
            midVerticalScrolViewLayout = new VerticalRefreshLayout()
            {
                Y = btnMidTopLayout.Bottom,
                Height = Application.GetRealHeight(1145),
            };
            this.midFrameLayout.AddChidren(midVerticalScrolViewLayout);
            midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
            {
                canFresh = true;
                midVerticalScrolViewLayout.BeginHeaderRefreshing();
                InitData();
            };
            //底部保存栏
            var bottomFrameLayout = new FrameLayout()
            {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight(84 * 2 + 127),
                Y = Application.GetRealHeight(1388),
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout);
            var bottomTipPicFrameLayout = new FrameLayout()
            {
                Height = Application.GetMinReal(40 + 44 - 10),
            };
            bottomFrameLayout.AddChidren(bottomTipPicFrameLayout);
            var btnTipPicFrameLayout = new FrameLayout()
            {
                Width = Application.GetMinReal(23 + 37),
                Height = Application.GetMinReal(40 + 44 - 10),
            };
            bottomTipPicFrameLayout.AddChidren(btnTipPicFrameLayout);
            btnTipPic = new Button()
            {
                Width = Application.GetMinReal(40),
                Height = Application.GetMinReal(40),
                Y = Application.GetRealHeight(19),
                UnSelectedImagePath = "BindPic/EmptyTargets.png",
                SelectedImagePath = "BindPic/EmptyTargetsSelected.png",
            };
            btnTipPicFrameLayout.AddChidren(btnTipPic);
            btnTipText = new Button()
            {
                Height = Application.GetRealHeight(84 - 10),
                X = Application.GetMinReal(58),
                Width = Application.GetMinReal(1080 - 446),
                TextID = R.MyInternationalizationString.BindEmptyTargets,
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                TextSize = 12,
                TextAlignment = TextAlignment.CenterLeft,
            };
            bottomTipPicFrameLayout.AddChidren(btnTipText);
            bottomTipPicFrameLayout.Width = btnTipPicFrameLayout.Width + Application.GetMinReal(12) + btnTipText.GetTextWidth();
            bottomTipPicFrameLayout.Gravity = Gravity.CenterHorizontal;
            EventHandler<MouseEventArgs> eHandlerEmptyTargets = (sender, e) =>
            {
                if (!btnFinifh.Enable)
                {
                    return;
                }
                if (btnTipPic.IsSelected)
                {
                    btnTipPic.IsSelected = false;
                    foreach (var d in targetListTemp)
                    {
                        targetList.Add(d);
                    }
                    btnTipText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                }
                else
                {
                    btnTipPic.IsSelected = true;
                    targetList.Clear();
                    btnTipText.TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText;
                }
                RefreshDeviceList(tempRoom);
            };
            btnTipPicFrameLayout.MouseDownEventHandler += eHandlerEmptyTargets;
            btnTipPic.MouseDownEventHandler += eHandlerEmptyTargets;
            btnFinifh = new Button()
            {
                Width = Application.GetRealWidth(907),
                Height = Application.GetRealHeight(127),
                Y = Application.GetRealHeight(49 + 35),
                Gravity = Gravity.CenterHorizontal,
                Radius = (uint)Application.GetRealHeight(127) / 2,
                TextID = R.MyInternationalizationString.Save,
                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                IsBold = true,
                TextSize = 16,
            };
            bottomFrameLayout.AddChidren(btnFinifh);
            btnFinifh.MouseUpEventHandler += (sender, e) =>
            {
                SaveTarget();
            };
        }
        /// <summary>
        /// 面板绑定目标表显示
        /// </summary>
        /// <param name="gateway">Gateway.</param>
        /// <param name="key">Key.</param>
        void RefreshRoomList()
        {
            Room curRoom = null;
            btnHorizontalScrolViewLayout.RemoveAll();
            Button curentOldRoom = null;
            FrameLayout curentOldRoomFrameLayout = null;
            int index = 0;
            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);
            }
            for (int i = 0; i < roomTempList.Count; i++)
            {
                var room = roomTempList[i];
                bool canSelect = false;
                if (curControlDev.currentSelectRoomId == room.Id)
                {
                    slectedRoom = room;
                    canSelect = true;
                }
                //房间
                var btnRoomFrameLayout = new FrameLayout
                {
                    Height = Application.GetMinReal(159),
                    Width = Application.GetMinReal(255 + 20),
                    Y = Application.GetRealHeight(23),
                    X = Application.GetRealWidth(5),
                    BackgroundImagePath = "Item/RoomIconBackground.png",
                    BorderWidth = 1,
                };
                btnHorizontalScrolViewLayout.AddChidren(btnRoomFrameLayout);
                var btnRoom = new Button
                {
                    Height = Application.GetRealHeight(66),
                    Width = Application.GetRealWidth(187),
                    Y = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(14),
                    Text = room.Name,
                    TextSize = 12,
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    Gravity = Gravity.Center,
                };
                btnRoomFrameLayout.AddChidren(btnRoom);
                btnRoom.IsSelected = false;
                if (canSelect)
                {
                    btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                    btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
                    curentOldRoom = btnRoom;
                    curentOldRoomFrameLayout = btnRoomFrameLayout;
                }
                //被绑定的目标还未分配区域,默认是最后一个,未分配房间
                if (string.IsNullOrEmpty(curControlDev.currentSelectRoomId))
                {
                    if (index == roomTempList.Count - 1)
                    {
                        btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                        btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
                        curentOldRoom = btnRoom;
                        curentOldRoomFrameLayout = btnRoomFrameLayout;
                    }
                }
                if (index == roomTempList.Count - 1 && index > 2)
                {
                    var btnRoomFrameLayoutEmpty = new FrameLayout
                    {
                        Height = Application.GetMinReal(159),
                        Width = Application.GetMinReal(50),
                        Y = Application.GetRealHeight(23),
                        X = Application.GetRealWidth(5),
                        BorderWidth = 1,
                    };
                    btnHorizontalScrolViewLayout.AddChidren(btnRoomFrameLayoutEmpty);
                }
                EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) =>
                {
                    if (!btnRoom.IsSelected)
                    {
                        if (curentOldRoom != null)
                        {
                            curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                        }
                        curentOldRoom = btnRoom;
                        curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
                    }
                    if (btnRoomFrameLayout.BorderWidth == 1)
                    {
                        if (curentOldRoomFrameLayout != null)
                        {
                            curentOldRoomFrameLayout.BorderWidth = 1;
                            curentOldRoomFrameLayout.BorderColor = Shared.Common.ZigbeeColor.Current.XMOrange;
                            curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackground.png";
                        }
                        curentOldRoomFrameLayout = btnRoomFrameLayout;
                        curentOldRoomFrameLayout.BorderWidth = 0;
                        curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                    }
                    curRoom = room;
                    //新风面板保存使能
                    btnFinifh.Enable = true;
                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    tempRoom = curRoom;
                    RefreshDeviceList(curRoom);
                };
                btnRoom.MouseUpEventHandler += eHandlerRoom;
                btnRoomFrameLayout.MouseUpEventHandler += eHandlerRoom;
                index++;
            }
            BindInfo.FinishDisplay(roomTempList, btnFinifh);
            if (roomTempList.Count == 0)
            {
                curRoom = new Shared.Common.Room();
            }
            else
            {
                if (slectedRoom == null)
                {
                    //未选中默认最后一个“未分配选中”
                    curRoom = roomTempList[index - 1];
                    var view = btnHorizontalScrolViewLayout.GetChildren(index - 1);
                    var frame = (FrameLayout)view;
                    var btn = (Button)frame.GetChildren(0);
                    frame.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                    btn.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
                    curentOldRoom = btn;
                    curentOldRoomFrameLayout = frame;
                }
                else
                {
                    curRoom = slectedRoom;
                }
            }
            tempRoom = curRoom;
            RefreshDeviceList(curRoom);
        }
        /// <summary>
        /// 按键绑目标表显示
        /// </summary>
        /// <param name="curRoom"></param>
        void RefreshDeviceList(Room curRoom)
        {
            midVerticalScrolViewLayout.RemoveAll();
            Button oldDevice = null;
            int curIndex = 0;
            if (curRoom.Id == "UndistributedId")
            {
                currentRoomSupportBindDeviceList = BindInfo.GetUndistributeDeviceList(undistruibuteDevList, curDeviceBindType);
            }
            else
            {
                currentRoomSupportBindDeviceList = BindInfo.GetCurRoomSupportDeviceList(currentRoomSupportBindDeviceList, curRoom, curDeviceBindType);
            }
            if (currentRoomSupportBindDeviceList.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                return;
            }
            foreach (var device in currentRoomSupportBindDeviceList)
            {
                #region 绑定表UI显(无数据处理)
                var rowLayout = new FrameLayout()
                {
                    Height = Application.GetRealHeight(23 + 127),
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                };
                midVerticalScrolViewLayout.AddChidren(rowLayout);
                var devicePic = new Button()
                {
                    X = Application.GetMinRealAverage(58),
                    Y = Application.GetMinRealAverage(46),
                    Width = Application.GetMinRealAverage(81),
                    Height = Application.GetMinRealAverage(81),
                    UnSelectedImagePath = device.IconPath,
                };
                rowLayout.AddChidren(devicePic);
                var btnBindName = new Button()
                {
                    Width = Application.GetRealWidth(790),
                    X = devicePic.Right + Application.GetRealWidth(20),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextSize = 15,
                    Text = Common.LocalDevice.Current.GetDeviceEpointName(device),
                };
                rowLayout.AddChidren(btnBindName);
                var btnChoose = new Button()
                {
                    Width = Application.GetMinReal(60),
                    Height = Application.GetMinReal(60),
                    X = Application.GetRealWidth(861 + 81),
                    Y = Application.GetRealHeight(35),
                    SelectedImagePath = "DoorLock/SelectedIcon.png",
                    Visible = false,
                };
                rowLayout.AddChidren(btnChoose);
                var line2 = new Button()
                {
                    Y = rowLayout.Height - 1,
                    X = devicePic.Right + Application.GetRealWidth(20),
                    Width = Application.GetRealWidth(965 - 116),
                    Height = 1,
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                };
                rowLayout.AddChidren(line2);
                if (curIndex == currentRoomSupportBindDeviceList.Count - 1)
                {
                    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;
                }
                switch (curDeviceBindType)
                {
                    case DeviceBind.BindInfo.BindType.FreshAir:
                        devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png";
                        break;
                    case DeviceBind.BindInfo.BindType.Temperature:
                        devicePic.UnSelectedImagePath = "Device/SensorTemperature.png";
                        if (device.Type == DeviceType.PMSensor)
                        {
                            btnBindName.Text = Common.LocalDevice.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);
                        }
                        break;
                    case DeviceBind.BindInfo.BindType.PM:
                        devicePic.UnSelectedImagePath = "Device/AirQualitySensorEpoint.png";
                        break;
                    case DeviceBind.BindInfo.BindType.AC:
                        devicePic.UnSelectedImagePath = "Device/AirConditionerEpoint.png";
                        break;
                }
                #endregion
                string mianKey = device.DeviceAddr + device.DeviceEpoint;
                if (targetList.Count != 0)
                {
                    foreach (var bindedDev in targetList)
                    {
                        if (bindedDev.DeviceAddr + bindedDev.DeviceEpoint == mianKey)
                        {
                            btnChoose.IsSelected = true;
                            btnChoose.Visible = true;
                            oldDevice = btnChoose;
                        }
                    }
                }
                EventHandler<MouseEventArgs> hander = (sender, e) =>
                {
                    if (btnChoose.IsSelected)
                    {
                        return;
                    }
                    if (btnTipPic.IsSelected)
                    {
                        btnTipPic.IsSelected = false;
                        foreach (var d in targetListTemp)
                        {
                            targetList.Add(d);
                        }
                        btnTipText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                    }
                    btnChoose.IsSelected = true;
                    if (!btnChoose.IsSelected)
                    {
                        if (oldDevice != null)
                        {
                            oldDevice.IsSelected = false;
                            oldDevice.Visible = false;
                        }
                        oldDevice = btnChoose;
                        oldDevice.IsSelected = false;
                        oldDevice.Visible = false;
                        targetList.Clear();
                    }
                    else
                    {
                        if (oldDevice != null)
                        {
                            oldDevice.IsSelected = false;
                            oldDevice.Visible = false;
                        }
                        oldDevice = btnChoose;
                        oldDevice.IsSelected = true;
                        oldDevice.Visible = true;
                        targetList.Clear();
                        targetList.Add(device);
                    }
                    targetListTemp.Clear();
                    foreach (var d in targetList)
                    {
                        targetListTemp.Add(d);
                    }
                    btnFinifh.Enable = true;
                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                };
                rowLayout.MouseUpEventHandler += hander;
                devicePic.MouseUpEventHandler += hander;
                btnBindName.MouseUpEventHandler += hander;
                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
        #region 数据处理
        /// <summary>
        /// 初始化设备数据
        /// </summary>
        void InitData(bool canUpdateBindName = false)
        {
            System.Threading.Tasks.Task.Run(async () =>
            {
                try
                {
                    //获取被绑目标等信息
                    BindDevInfo(curBindDevice);
                    //获取楼层
                    dicFloorList = HdlRoomLogic.Current.GetFloorSortList();
                    //获取房间列表
                    supportRoomList = BindInfo.GetSupportRoomList();
                    //获取所有房间中匹配的能绑的目标
                    currentPanelSupportBindDeviceList = BindInfo.GetAllRoomSupportDeviceList(currentPanelSupportBindDeviceList, supportRoomList, curDeviceBindType);
                    //获取本地未分配的支持当前类型的绑定设备列表
                    undistruibuteDevList = BindInfo.GetUndistributeDeviceList(undistruibuteDevList, curDeviceBindType);
                    //获取面板中存在的绑定目标
                    var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev);
                    if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null)
                    {
                        curControlDev.bindList.Clear();
                        foreach (var bDev in panelBindListRes.getAllBindResponseData.BindList)
                        {
                            curControlDev.bindList.Add(bDev);
                        }
                    }
                    else
                    {
                        Application.RunOnMainThread(() =>
                        {
                            canFresh = false;
                            midVerticalScrolViewLayout.EndHeaderRefreshing();
                            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);
                            };
                        });
                    }
                    oldTargetList.Clear();
                    //选中目标列表 targetList
                    if (curControlDev.bindList.Count != 0)
                    {
                        foreach (var bindDev in curControlDev.bindList)
                        {
                            var mainKey = bindDev.BindMacAddr + bindDev.BindEpoint;
                            //分配的目标列表
                            if (Shared.Common.LocalDevice.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);
                                    if (device != null)
                                    {
                                        BindTypeTargetsList(device, bindDev);
                                    }
                                }
                            }
                            //未分配的目标列表
                            if (undistruibuteDevList.Count != 0)
                            {
                                var dev = undistruibuteDevList.Find(obj => (obj != null) && (obj.DeviceAddr + obj.DeviceEpoint == mainKey));
                                if (dev != null)
                                {
                                    var device = LocalDevice.Current.GetDevice(dev.DeviceAddr, dev.DeviceEpoint);
                                    if (device != null)
                                    {
                                        BindTypeTargetsList(device, bindDev);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    var mess = ex.Message;
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        //楼层侧边栏绑定
                        if (!canFresh)
                        {
                            BindDownFrameLayout(this.midFrameLayout, curControlDev, dicFloorList, ref btnFloorText);
                        }
                        ChooseFloorAction += (floorId, btnMethodText) =>
                        {
                            btnFloorText.Text = string.Empty;
                            btnFloorText.Text = dicFloorList[floorId];
                            //获取房间列表
                            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;
                            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 tempDev = localDeviceList.Find(obj => obj.DeviceAddr == dev.DeviceAddr && obj.DeviceEpoint == dev.DeviceEpoint);
                                if (tempDev != null)
                                {
                                    //获取设备所属房间
                                    var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev);
                                    if (tempDevRoom != null)
                                    {
                                        curControlDev.currentSelectRoomId = tempDevRoom.Id;
                                        curControlDev.currentSelectFloorId = tempDevRoom.FloorId;
                                    }
                                    else
                                    {
                                        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))
                            {
                                if (BindInfo.GetBindTargetsFloorIdName(curControlDev.currentSelectFloorId) != null)
                                {
                                    btnFloorText.Text = BindInfo.GetBindTargetsFloorIdName(curControlDev.currentSelectFloorId);
                                }
                            }
                            btnFinifh.Enable = true;
                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        }
                        //获取楼层中房间列表
                        RefreshRoomList();
                        canFresh = false;
                        midVerticalScrolViewLayout.EndHeaderRefreshing();
                        CommonPage.Loading.Hide();
                    });
                }
            });
        }
        /// <summary>
        /// 保存目标
        /// </summary>
        /// <param name="curControlDev"></param>
        void SaveTarget()
        {
            btnFinifh.Enable = false;
            if (targetList.Count == 0)
            {
                //空目标
                System.Threading.Tasks.Task.Run(async () =>
                {
                    try
                    {
                        Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
                        if (btnTipPic.IsSelected)
                        {
                            //当绑定空目标,要删除已经存在按键的目标
                            if (oldTargetList.Count != 0)
                            {
                                //删除按键中已经绑定的目标个数【删除成功个数】
                                int sOldTargetListCount = 0;
                                foreach (var bd in oldTargetList)
                                {
                                    var delDevice = DelBindDevice(bd);
                                    //此次按键中需要移除的目标个数【同一个目标携带的多个功能删除成功的个数】
                                    int sRemoveBindListCount = 0;
                                    var delResult = new DelDeviceBindResponseAllData();
                                    delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
                                    if (delResult == null)
                                    {
                                        Application.RunOnMainThread(() =>
                                        {
                                            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 += () =>
                                            {
                                                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)
                                                {
                                                    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();
                                                        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_2" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                                    btnFinifh.Enable = true;
                                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                                    CommonPage.Loading.Hide();
                                                });
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //按键中没有目标直接绑定空目标
                                TargesBindName();
                                Application.RunOnMainThread(() =>
                                {
                                    CommonPage.Loading.Hide();
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    this.RemoveFromParent();
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        var mess = ex.Message;
                        Application.RunOnMainThread(() =>
                        {
                            CommonPage.Loading.Hide();
                        });
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                });
            }
            else
            {
                //选中目标
                //1、已经绑定过的目标
                if (BindInfo.checkExistDevice(targetList, oldTargetList))
                {
                    Application.RunOnMainThread(() =>
                    {
                        var myTip = new Tip();
                        myTip.Direction = AMPopTipDirection.None;
                        myTip.CloseTime = 2;
                        myTip.Text = Language.StringByID(R.MyInternationalizationString.BindExist);
                        myTip.Show(Common.CommonPage.Instance);
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    });
                    return;
                }
                System.Threading.Tasks.Task.Run(async () =>
                {
                    try
                    {
                        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);
                                if (delResult == null)
                                {
                                    Application.RunOnMainThread(() =>
                                    {
                                        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;
                                }
                                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) + "(" + "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++;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (delResult.removeBindResultResponseData.Result != 0)
                                        {
                                            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++;
                                    }
                                }
                            }
                            if (sOldTargetListCount != oldTargetList.Count)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    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;
                            }
                        }
                        //2、添加新的目标
                        string bindName = "";
                        var addBindeDev = new AddBindData();
                        addBindeDev.DeviceAddr = curControlDev.DeviceAddr;
                        addBindeDev.Epoint = curControlDev.DeviceEpoint;
                        foreach (var de in targetList)
                        {
                            var addBindInfo = new AddBindListObj();
                            switch (curDeviceBindType)
                            {
                                case BindInfo.BindType.FreshAir:
                                    addBindInfo.BindCluster = 514;
                                    break;
                                case BindInfo.BindType.Temperature:
                                    addBindInfo.BindCluster = 1026;
                                    break;
                                case BindInfo.BindType.Humidity:
                                    addBindInfo.BindCluster = 1029;
                                    break;
                                case BindInfo.BindType.PM:
                                    addBindInfo.BindCluster = 1066;
                                    break;
                                case BindInfo.BindType.AC:
                                    addBindInfo.BindCluster = 513;
                                    break;
                            }
                            addBindInfo.BindType = 0;
                            addBindInfo.BindMacAddr = de.DeviceAddr;
                            addBindInfo.BindEpoint = de.DeviceEpoint;
                            addBindeDev.BindName = Common.LocalDevice.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);
                                    }
                                    break;
                                case BindInfo.BindType.Humidity:
                                    if (de.Type == DeviceType.PMSensor)
                                    {
                                        addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                                    }
                                    break;
                            }
                            //部分目标需要二次绑定第二种功能
                            var addBindInfo2 = new AddBindListObj();
                            addBindInfo2.BindType = 0;
                            addBindInfo2.BindMacAddr = de.DeviceAddr;
                            addBindInfo2.BindEpoint = de.DeviceEpoint;
                            switch (curDeviceBindType)
                            {
                                case BindInfo.BindType.AC:
                                    //要绑定空调:需要绑定513,514
                                    addBindInfo2.BindCluster = 514;
                                    addBindeDev.BindList.Add(addBindInfo2);
                                    break;
                            }
                            addBindeDev.BindList.Add(addBindInfo);
                        }
                        var dev = new AddedDeviceBindResponseAllData();
                        dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev);
                        if (dev == null || dev.addedDeviceBindResponseData == null)
                        {
                            Application.RunOnMainThread(() =>
                            {
                                CommonPage.Loading.Hide();
                                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
                        {
                            if (dev.addedDeviceBindResponseData.Result == 0)
                            {
                                targetList.Clear();
                                targetListTemp.Clear();
                                TargesBindName(addBindeDev.BindName);
                                Application.RunOnMainThread(() =>
                                {
                                    CommonPage.Loading.Hide();
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    this.RemoveFromParent();
                                });
                            }
                            else if (dev.addedDeviceBindResponseData.Result == 1)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    CommonPage.Loading.Hide();
                                    new Tip()
                                    {
                                        MaxWidth = 150,
                                        Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5001_1" + ")",
                                        Direction = AMPopTipDirection.None,
                                        CloseTime = 1
                                    }.Show(CommonPage.Instance);
                                });
                                return;
                            }
                            else
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    CommonPage.Loading.Hide();
                                    new Tip()
                                    {
                                        MaxWidth = 150,
                                        Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError) + "(" + "5001_2" + ")",
                                        Direction = AMPopTipDirection.None,
                                        CloseTime = 1
                                    }.Show(CommonPage.Instance);
                                });
                                btnFinifh.Enable = true;
                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            CommonPage.Loading.Hide();
                        });
                        btnFinifh.Enable = true;
                        var mess = ex.Message;
                    }
                });
            }
        }
        /// <summary>
        /// 目标为文本显示
        /// </summary>
        void EmptyTargesMess1()
        {
            switch (curDeviceBindType)
            {
                case BindInfo.BindType.FreshAir:
                    if (actionFreshAirTarget != null)
                    {
                        actionFreshAirTarget("");
                    }
                    break;
                case BindInfo.BindType.Temperature:
                    if (actionTemperatureTarget != null)
                    {
                        actionTemperatureTarget("");
                    }
                    break;
                case BindInfo.BindType.Humidity:
                    if (actionHumidityTarget != null)
                    {
                        actionHumidityTarget("");
                    }
                    break;
                case BindInfo.BindType.PM:
                    if (actionPMTarget != null)
                    {
                        actionPMTarget("");
                    }
                    break;
                case BindInfo.BindType.AC:
                    if (actionAcTarget != null)
                    {
                        actionAcTarget("");
                    }
                    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>
        /// 绑定目标列表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="bindDev"></param>
        void BindTypeTargetsList(CommonDevice device, BindListResponseObj bindDev)
        {
            switch (curDeviceBindType)
            {
                case BindInfo.BindType.FreshAir:
                    //获取设备类型的
                    var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                    //新风面板的新风设备,则不显示
                    if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                    {
                        if (device.Type == DeviceType.FreshAir)
                        {
                            oldTargetList.Add(device);
                        }
                    }
                    break;
                case BindInfo.BindType.Temperature:
                    if (device.Type == DeviceType.TemperatureSensor)
                    {
                        var bDev = device as TemperatureSensor;
                        if (bDev.SensorDiv == 1)
                        {
                            oldTargetList.Add(device);
                        }
                    }
                    if (device.Type == DeviceType.PMSensor)
                    {
                        if (bindDev.BindCluster == 1026)
                        {
                            oldTargetList.Add(device);
                        }
                    }
                    break;
                case BindInfo.BindType.Humidity:
                    if (device.Type == DeviceType.TemperatureSensor)
                    {
                        var bDev = device as TemperatureSensor;
                        if (bDev.SensorDiv == 2)
                        {
                            oldTargetList.Add(device);
                        }
                    }
                    if (device.Type == DeviceType.FreshAirHumiditySensor)
                    {
                        oldTargetList.Add(device);
                    }
                    if (device.Type == DeviceType.PMSensor)
                    {
                        if (bindDev.BindCluster == 1029)
                        {
                            oldTargetList.Add(device);
                        }
                    }
                    break;
                case BindInfo.BindType.PM:
                    if (device.Type == DeviceType.PMSensor)
                    {
                        if (bindDev.BindCluster == 1066)
                        {
                            oldTargetList.Add(device);
                        }
                    }
                    break;
                case BindInfo.BindType.AC:
                    if (device.Type == DeviceType.Thermostat)
                    {
                        if (bindDev.BindCluster == 513)
                        {
                            oldTargetList.Add(device);
                        }
                    }
                    break;
            }
            targetList.Clear();
            if (oldTargetList.Count != 0)
            {
                targetList.Add(oldTargetList[0]);
            }
            targetListTemp.Clear();
            foreach (var d in targetList)
            {
                targetListTemp.Add(d);
            }
        }
        /// <summary>
        /// 当前被绑定设备所属楼层和房间
        /// </summary>
        /// <param name="bindDev"></param>
        void BindDevInfo(CommonDevice bindDev)
        {
            if (bindDev == null)
            {
                return;
            }
            //获取本地设备列表
            var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice;
            var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == bindDev.DeviceAddr && obj.DeviceEpoint == bindDev.DeviceEpoint);
            if (tempDev != null)
            {
                //获取设备所属房间
                var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev);
                if (tempDevRoom != null)
                {
                    curControlDev.currentSelectRoomId = tempDevRoom.Id;
                    curControlDev.currentSelectFloorId = tempDevRoom.FloorId;
                }
            }
        }
        /// <summary>
        /// 检测已经绑定的目标是否不在本地或者没有分配到任何房间中
        /// </summary>
        /// <returns></returns>
        private DelDeviceBindData DelBindDevice(CommonDevice bd)
        {
            var delDevice = new DelDeviceBindData();
            delDevice.DeviceAddr = curControlDev.DeviceAddr;
            delDevice.Epoint = curControlDev.DeviceEpoint;
            var removeDevice = new RemoveBindListObj();
            removeDevice.BindType = 0;
            switch (curDeviceBindType)
            {
                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);
            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 移除方法
        /// <summary>
        /// 重写移除方法
        /// </summary>
        public override void RemoveFromParent()
        {
            actionFreshAirTarget = null;
            actionTemperatureTarget = null;
            actionHumidityTarget = null;
            actionPMTarget = null;
            FloorAction = null;
            base.RemoveFromParent();
        }
        #endregion
    }
}