黄学彪
2020-04-28 e22fdb94322e6cec38e5e4a9aec13d431a133fde
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
@@ -62,10 +62,6 @@
        /// </summary>
        List<Room> supportRoomList = new List<Room>();
        /// <summary>
        /// 当绑定表变化后的回调
        /// </summary>
        public Action<List<BindListResponseObj>> action;
        /// <summary>
        /// 保存完成按钮
        /// </summary>
        Button btnFinifh;
@@ -92,19 +88,19 @@
        /// <summary>
        /// 新风绑定目标回调
        /// </summary>
        Action actionFreshAirTarget = null;
        public Action<string> actionFreshAirTarget = null;
        /// <summary>
        /// 温度绑定目标回调
        /// </summary>
        Action actionTemperatureTarget = null;
        public Action<string> actionTemperatureTarget = null;
        /// <summary>
        /// 湿度绑定目标回调
        /// </summary>
        Action actionHumidityTarget = null;
        public Action<string> actionHumidityTarget = null;
        /// <summary>
        /// PM绑定目标回调
        /// </summary>
        Action actionPMTarget = null;
        public Action<string> actionPMTarget = null;
        #endregion
        #region UI设计 
@@ -135,7 +131,7 @@
            {
                RemoveFromParent();
            };
            this.btnTitle.Width = Application.GetRealWidth(1080 - 161 - 200 - 58);
            this.btnTitle.Width = Application.GetRealWidth(1080 - 161 - 300);
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
@@ -156,14 +152,13 @@
        {
            var btnAddFrameLayout = new FrameLayout
            {
                X = Application.GetRealWidth(830),
                X = Application.GetRealWidth(619),
            };
            this.titleFrameLayout.AddChidren(btnAddFrameLayout);
            btnFloorText = new Button
            {
                Width = Application.GetRealWidth(110),
                X = Application.GetRealWidth(15),
                Width = Application.GetRealWidth(300 - 69 - 58),
                Text = Language.StringByID(R.MyInternationalizationString.FirstFloor),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 14,
@@ -172,26 +167,35 @@
            };
            btnAddFrameLayout.AddChidren(btnFloorText);
            var btnBindDownFrameLayout = new FrameLayout
            {
                Width = Application.GetMinReal(69 + 58),
                X = Application.GetRealWidth(300 - 69 - 58),
            };
            btnAddFrameLayout.AddChidren(btnBindDownFrameLayout);
            var btnBindDown = new Button
            {
                Height = Application.GetMinReal(69),
                Width = Application.GetMinReal(69),
                X = Application.GetRealWidth(200 - 77),
                UnSelectedImagePath = "BindPic/BindDown.png",
                Gravity = Gravity.CenterVertical,
            };
            btnAddFrameLayout.AddChidren(btnBindDown);
            btnBindDown.MouseDownEventHandler += (sender, e) =>
            btnBindDownFrameLayout.AddChidren(btnBindDown);
            EventHandler<MouseEventArgs> eHandlerBindDown = (sender, e) =>
            {
                SideslipFramelayout();
            };
            btnBindDown.MouseDownEventHandler += eHandlerBindDown;
            btnBindDownFrameLayout.MouseDownEventHandler += eHandlerBindDown;
            if (Common.Config.Instance.Home.FloorDics.Count == 0)
            {
                btnAddFrameLayout.Width = 0;
            }
            else
            {
                btnAddFrameLayout.Width = Application.GetRealWidth(200);
                btnAddFrameLayout.Width = Application.GetRealWidth(300);
            }
        }
@@ -220,6 +224,11 @@
                Height = Application.GetRealHeight(1145),
            };
            this.midFrameLayout.AddChidren(midVerticalScrolViewLayout);
            midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
            {
                midVerticalScrolViewLayout.BeginHeaderRefreshing();
                InitData();
            };
            //底部保存栏
            var bottomFrameLayout = new FrameLayout()
@@ -253,8 +262,9 @@
        /// </summary>
        /// <param name="gateway">Gateway.</param>
        /// <param name="key">Key.</param>
        void RefreshRoomList(Room curRoom, ref int index2)
        void RefreshRoomList()
        {
            Room curRoom = null;
            if (supportRoomList.Count == 0)
            {
                return;
@@ -263,7 +273,7 @@
            Button curentOldRoom = null;
            FrameLayout curentOldRoomFrameLayout = null;
            int index = 0;
            var roomTempList = GetSupportRoomList(curRoom);
            var roomTempList = GetSupportRoomList();
            for (int i = 0; i < roomTempList.Count; i++)
            {
                var room = roomTempList[i];
@@ -302,7 +312,6 @@
                }
                EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) =>
                {
                    //ChangeRoom(curRoom, room, btnRoom, curentOldRoom, btnRoomFrameLayout, curentOldRoomFrameLayout);
                    if (!btnRoom.IsSelected)
                    {
                        if (curentOldRoom != null)
@@ -327,26 +336,11 @@
                    }
                    curRoom = room;
                    curControlDev.RoomId = room.Id;
                    if (curRoom.ListSceneId.Count == 0)
                    {
                        btnFinifh.Enable = false;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                    }
                    else
                    {
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                    if (targetList.Count == 0)
                    {
                        btnFinifh.Enable = false;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                    }
                    else
                    {
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                    //新风面板保存使能
                    btnFinifh.Enable = true;
                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    RefreshDeviceList(curRoom);
                };
                btnRoom.MouseUpEventHandler += eHandlerRoom;
@@ -354,6 +348,17 @@
                index++;
            }
            BindInfo.FinishDisplay(roomTempList, btnFinifh);
            if (roomTempList.Count != 0)
            {
                curRoom = roomTempList[0];
            }
            else
            {
                curRoom = new Shared.Common.Room();
            }
            RefreshDeviceList(curRoom);
        }
        /// <summary>
@@ -425,7 +430,7 @@
                };
                rowLayout.AddChidren(line2);
                if (curIndex == currentPanelSupportBindDeviceList.Count - 1)
                if (curIndex == currentRoomSupportBindDeviceList.Count - 1)
                {
                    line2.Visible = false;
                }
@@ -435,23 +440,6 @@
                string mianKey = device.DeviceAddr + device.DeviceEpoint;
                if (targetList.Count != 0)
                {
                    //    if(curControlDev!=null)
                    //    {
                    //        foreach (var bindedSc in curControlDev.bindList)
                    //        {
                    //            if (bindedSc.BindMacAddr + bindedSc.BindEpoint == mianKey)
                    //            {
                    //                btnChoose.IsSelected = true;
                    //                btnChoose.Visible = true;
                    //                oldDevice = btnChoose;
                    //                targetList.Add(device);
                    //            }
                    //        }
                    //    }
                    //}
                    //else
                    //{
                    foreach (var bindedDev in targetList)
                    {
                        if (bindedDev.DeviceAddr + bindedDev.DeviceEpoint == mianKey)
@@ -465,17 +453,20 @@
                EventHandler<MouseEventArgs> hander = (sender, e) =>
               {
                   //ChangeTarget(device, btnChoose, oldDevice);
                   if (curControlDev.bindList.Count != 0)
                   {
                       if (btnChoose.IsSelected)
                       {
                           new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindExist), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                           return;
                       }
                   }
                   btnChoose.IsSelected = !btnChoose.IsSelected;
                   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)
                       {
@@ -488,33 +479,16 @@
                       targetList.Clear();
                       targetList.Add(device);
                   }
                   if (targetList.Count == 0)
                   {
                       btnFinifh.Enable = false;
                       btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                   }
                   else
                   {
                       btnFinifh.Enable = true;
                       btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                   }
                   //新风面板:由于目标没有提供删除接口,所以可以取消选中能保存
                   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)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
        }
@@ -537,7 +511,6 @@
            var sidelipFrameLayout = new FrameLayout()
            {
                Height = Application.GetMinReal(783),
                Width = Application.GetMinReal(449),
                Y = Application.GetRealHeight(161),
                X = Application.GetRealWidth(596),
@@ -561,18 +534,19 @@
            var sidelipVerticalScrolViewLayout = new VerticalScrolViewLayout()
            {
                Y = btnSelectFloor.Bottom + Application.GetRealHeight(45),
                Height = Application.GetRealHeight(600),
                Y = btnSelectFloor.Bottom,
            };
            sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout);
            Button oldbutton = null;
            Button oldbuttonText = null;
            int count = 0;
            foreach (var floorId in dicFloorList.Keys)
            {
                var rowFrameLayout = new RowLayout()
                {
                    Height = Application.GetRealHeight(150),
                    Height = Application.GetRealHeight(152),
                    LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                    X = Application.GetRealWidth(81),
                };
@@ -582,9 +556,9 @@
                {
                    Width = Application.GetMinReal(81),
                    Height = Application.GetMinReal(81),
                    Y = Application.GetRealHeight(55),
                    UnSelectedImagePath = "Floor/Floor.png",
                    SelectedImagePath = "Floor/FloorSelected.png",
                    Gravity = Gravity.CenterVertical,
                };
                rowFrameLayout.AddChidren(btnAllMethod);
@@ -593,7 +567,7 @@
                    Width = Application.GetRealWidth(311),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(92),
                    Y = Application.GetRealHeight(69),
                    Gravity = Gravity.CenterVertical,
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    TextSize = 14,
                    TextAlignment = TextAlignment.CenterLeft,
@@ -608,36 +582,18 @@
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                }
                string curFloorId = floorId;
                EventHandler<MouseEventArgs> hander = (sender, e) =>
                {
                    //ChangeFloor(dialog, floorId, btnMethodText, oldbuttonText, oldbutton);
                    var curFloorId = floorId;
                    curControlDev.currentSelectFloorId = curFloorId;
                    btnFloorText.Text = dicFloorList[curFloorId];
                    if (curControlDev.currentSelectFloorId == curFloorId)
                    {
                        return;
                    }
                    curControlDev.currentSelectFloorId = curFloorId;
                    btnFloorText.Text = dicFloorList[curFloorId];
                    btnFloorText.Text = dicFloorList[floorId];
                    //获取楼层中房间列表 
                    supportRoomList = GetFloorRoomList();
                    if (supportRoomList.Count == 0)
                    {
                        return;
                    }
                    var curRoom = new Room();
                    if (supportRoomList.Count != 0)
                    {
                        curRoom = supportRoomList[0];
                    }
                    else
                    {
                        curRoom = new Shared.Common.Room();
                        supportRoomList.Add(curRoom);
                    }
                    if (!btnMethodText.IsSelected)
                    {
                        if (oldbutton != null)
@@ -656,23 +612,26 @@
                    }
                    int index = 0;
                    RefreshRoomList(curRoom, ref index);
                    if (targetList.Count == 0)
                    {
                        btnFinifh.Enable = false;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                    }
                    else
                    {
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                    RefreshRoomList();
                    dialog.Close();
                };
                btnAllMethod.MouseUpEventHandler += hander;
                rowFrameLayout.MouseUpEventHandler += hander;
                btnMethodText.MouseUpEventHandler += hander;
                count++;
            }
            if (count == 0)
            {
                sidelipFrameLayout.Height = 0;
            }
            else if (count <= 4 && count > 0)
            {
                sidelipFrameLayout.Height = Application.GetRealHeight(180) + count * Application.GetRealHeight(150);
            }
            else
            {
                sidelipFrameLayout.Height = Application.GetMinReal(780);
            }
        }
        #endregion
@@ -697,8 +656,10 @@
                    curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
                    if (BindInfo.GetCurrentSelectFloorIdName() != null)
                    {
                        btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
                        Application.RunOnMainThread(() =>
                        {
                            btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
                        });
                    }
                    //获取楼层中房间列表
@@ -743,215 +704,76 @@
                                var device = LocalDevice.Current.GetDevice(bindDev.DeviceAddr, bindDev.DeviceEpoint);
                                if (device != null)
                                {
                                    //获取设备类型的
                                    var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                                    //新风面板的新风设备,则不显示
                                    if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                                    switch (curDeviceBindType)
                                    {
                                        continue;
                                        case 1:
                                            //获取设备类型的
                                            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                                            //新风面板的新风设备,则不显示
                                            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                                            {
                                                continue;
                                            }
                                            if (device.Type == DeviceType.FreshAir)
                                            {
                                                targetList.Add(device);
                                                oldTargetList.Add(device);
                                            }
                                            break;
                                        case 2:
                                            if (device.Type == DeviceType.TemperatureSensor)
                                            {
                                                targetList.Add(device);
                                                oldTargetList.Add(device);
                                            }
                                            break;
                                        case 3:
                                            if (device.Type == DeviceType.FreshAirHumiditySensor)
                                            {
                                                targetList.Add(device);
                                                oldTargetList.Add(device);
                                            }
                                            break;
                                        case 4:
                                            //PM2.5
                                            break;
                                    }
                                    if (device.Type == DeviceType.FreshAir)
                                    {
                                        targetList.Add(device);
                                        oldTargetList.Add(device);
                                    }
                                }
                                }
                            }
                        }
                    }
                }
                catch { }
                catch (Exception ex)
                {
                    var mess = ex.Message;
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        if (supportRoomList.Count != 0)
                        {
                            Shared.Common.Room curRoom = supportRoomList[0];
                            int index = 0;
                            RefreshRoomList(curRoom, ref index);
                            RefreshDeviceList(curRoom);
                            if (curRoom.ListDevice.Count == 0 || targetList.Count == 0)
                            {
                                btnFinifh.Enable = false;
                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                            }
                            else
                            {
                                btnFinifh.Enable = true;
                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                            }
                            RefreshRoomList();
                        }
                        //首次是否能点击保存
                        if (targetList.Count == 0)
                        {
                            btnFinifh.Enable = false;
                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                        }
                        else
                        {
                            btnFinifh.Enable = true;
                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        }
                        CommonPage.Loading.Hide();
                        midVerticalScrolViewLayout.EndHeaderRefreshing();
                    });
                }
            });
        }
        /// <summary>
        /// 切换楼层
        /// </summary>
        /// <param name="dialog"></param>
        /// <param name="curFloorId"></param>
        /// <param name="btnMethodText"></param>
        /// <param name="oldbuttonText"></param>
        /// <param name="oldbutton"></param>
        void ChangeFloor(Dialog dialog, string curFloorId, Button btnMethodText, Button oldbuttonText, Button oldbutton)
        {
            if (curControlDev.currentSelectFloorId == curFloorId)
            {
                return;
            }
            curControlDev.currentSelectFloorId = curFloorId;
            btnFloorText.Text = dicFloorList[curFloorId];
            //获取楼层中房间列表
            supportRoomList = GetFloorRoomList();
            if (supportRoomList.Count == 0)
            {
                return;
            }
            var curRoom = new Room();
            if (supportRoomList.Count != 0)
            {
                curRoom = supportRoomList[0];
            }
            else
            {
                curRoom = new Shared.Common.Room();
                supportRoomList.Add(curRoom);
            }
            if (!btnMethodText.IsSelected)
            {
                if (oldbutton != null)
                {
                    oldbutton.IsSelected = false;
                }
                if (oldbuttonText != null)
                {
                    oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                }
                oldbutton = btnMethodText;
                oldbuttonText = btnMethodText;
                btnMethodText.IsSelected = true;
                oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                oldbuttonText.IsBold = true;
            }
            int index = 0;
            RefreshRoomList(curRoom, ref index);
            if (targetList.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
            dialog.Close();
        }
        /// <summary>
        /// 切换房间
        /// </summary>
        /// <param name="curRoom"></param>
        /// <param name="room"></param>
        /// <param name="btnRoom"></param>
        /// <param name="curentOldRoom"></param>
        /// <param name="btnRoomFrameLayout"></param>
        /// <param name="curentOldRoomFrameLayout"></param>
        void ChangeRoom(Room curRoom, Room room, Button btnRoom, Button curentOldRoom, FrameLayout btnRoomFrameLayout, FrameLayout curentOldRoomFrameLayout)
        {
            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;
            curControlDev.RoomId = room.Id;
            if (curRoom.ListSceneId.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
            if (targetList.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
            RefreshDeviceList(curRoom);
        }
        /// <summary>
        /// 切换绑定目标
        /// </summary>
        void ChangeTarget(CommonDevice device, Button btnChoose, Button oldDevice)
        {
            if (curControlDev.bindList.Count != 0)
            {
                if (btnChoose.IsSelected)
                {
                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindExist), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                    return;
                }
            }
            if (!btnChoose.IsSelected)
            {
                if (oldDevice != null)
                {
                    oldDevice.IsSelected = false;
                    oldDevice.Visible = false;
                }
                oldDevice = btnChoose;
                oldDevice.IsSelected = true;
                oldDevice.Visible = true;
                targetList.Clear();
                targetList.Add(device);
            }
            if (targetList.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
        }
        /// <summary>
@@ -960,24 +782,127 @@
        /// <param name="curControlDev"></param>
        void SaveTarget()
        {
            bool isFinish = false;
            //空目标
            if (targetList.Count == 0)
            {
                Application.RunOnMainThread(() =>
                //空目标
                System.Threading.Tasks.Task.Run(async () =>
                {
                    var myTip = new Tip();
                    myTip.Direction = AMPopTipDirection.None;
                    myTip.CloseTime = 2;
                    myTip.Text = Language.StringByID(R.MyInternationalizationString.BindDeviceTargetIsEmpty);
                    myTip.Show(Common.CommonPage.Instance);
                    try
                    {
                        Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
                        if (oldTargetList.Count != 0)
                        {
                            //删除取消的目标
                            foreach (var bd in oldTargetList)
                            {
                                var delDevice = new DelDeviceBindData();
                                delDevice.DeviceAddr = curControlDev.DeviceAddr;
                                delDevice.Epoint = curControlDev.DeviceEpoint;
                                var removeDevice = new RemoveBindListObj();
                                removeDevice.BindType = 0;
                                switch (curDeviceBindType)
                                {
                                    case 1:
                                        removeDevice.BindCluster = 514;
                                        break;
                                    case 2:
                                        removeDevice.BindCluster = 1026;
                                        break;
                                    case 3:
                                        removeDevice.BindCluster = 1029;
                                        break;
                                    case 4:
                                        //PM2.5
                                        break;
                                }
                                removeDevice.BindMacAddr = bd.DeviceAddr;
                                removeDevice.BindEpoint = bd.DeviceEpoint;
                                delDevice.RemoveBindList.Add(removeDevice);
                                var delResult = new DelDeviceBindResponseAllData();
                                delResult = await curControlDev.DelDeviceBindAsync(delDevice);
                                if (delResult != null && delResult.removeBindResultResponseData != null)
                                {
                                    if (delResult.removeBindResultResponseData.Result == 0)
                                    {
                                        switch (curDeviceBindType)
                                        {
                                            case 1:
                                                if (actionFreshAirTarget != null)
                                                {
                                                    actionFreshAirTarget("");
                                                }
                                                break;
                                            case 2:
                                                if (actionTemperatureTarget != null)
                                                {
                                                    actionTemperatureTarget("");
                                                }
                                                break;
                                            case 3:
                                                if (actionHumidityTarget != null)
                                                {
                                                    actionHumidityTarget("");
                                                }
                                                break;
                                            case 4:
                                                if (actionPMTarget != null)
                                                {
                                                    actionPMTarget("");
                                                }
                                                break;
                                        }
                                        Application.RunOnMainThread(() =>
                                        {
                                            CommonPage.Loading.Hide();
                                            btnFinifh.Enable = true;
                                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                            this.RemoveFromParent();
                                        });
                                    }
                                    else
                                    {
                                        Application.RunOnMainThread(() =>
                                        {
                                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance);
                                            btnFinifh.Enable = true;
                                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                            CommonPage.Loading.Hide();
                                        });
                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                            //没有目标提示
                            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;
                        }
                    }
                    catch (Exception ex)
                    {
                        var mess = ex.Message;
                    }
                });
                return;
            }
            else
            {
                //已经绑定过的目标
                //选中目标
                //1、已经绑定过的目标
                if (checkExistDevice())
                {
                    Application.RunOnMainThread(() =>
@@ -987,6 +912,8 @@
                        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;
                }
@@ -1002,23 +929,52 @@
                        {
                            foreach (var bd in oldTargetList)
                            {
                                var res = await RemoveTargets(bd);
                                if (res != 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;
                                    });
                                }
                                var delDevice = new DelDeviceBindData();
                                delDevice.DeviceAddr = curControlDev.DeviceAddr;
                                delDevice.Epoint = curControlDev.DeviceEpoint;
                                var removeDevice = new RemoveBindListObj();
                                removeDevice.BindType = 0;
                                switch (curDeviceBindType)
                                {
                                    case 1:
                                        removeDevice.BindCluster = 514;
                                        break;
                                    case 2:
                                        removeDevice.BindCluster = 1026;
                                        break;
                                    case 3:
                                        removeDevice.BindCluster = 1029;
                                        break;
                                    case 4:
                                        //PM2.5
                                        break;
                                }
                                removeDevice.BindMacAddr = bd.DeviceAddr;
                                removeDevice.BindEpoint = bd.DeviceEpoint;
                                delDevice.RemoveBindList.Add(removeDevice);
                                var delResult = new DelDeviceBindResponseAllData();
                                delResult = await curControlDev.DelDeviceBindAsync(delDevice);
                                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;
                                    }
                                }
                            }
                        }
                        //添加新的目标
                        //2、添加新的目标
                        string bindName = "";
                        var addBindeDev = new AddBindData();
                        addBindeDev.DeviceAddr = curControlDev.DeviceAddr;
                        addBindeDev.Epoint = curControlDev.DeviceEpoint;
@@ -1036,25 +992,29 @@
                                case 3:
                                    addBindInfo.BindCluster = 1029;
                                    break;
                                case 4:
                                    //PM2.5
                                    break;
                            }
                            addBindInfo.BindType = 0;
                            addBindInfo.BindMacAddr = de.DeviceAddr;
                            addBindInfo.BindEpoint = de.DeviceEpoint;
                            addBindeDev.BindList.Add(addBindInfo);
                            bindName = de.DeviceEpointName;
                        }
                        var dev = new AddedDeviceBindResponseAllData();
                        dev = await curControlDev.AddDeviceBindAsync(addBindeDev);
                        if (dev != null || dev.addedDeviceBindResponseData == null)
                        if (dev == null || dev.addedDeviceBindResponseData == null)
                        {
                            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;
                            });
                            btnFinifh.Enable = true;
                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                            return;
                        }
                        else
                        {
@@ -1062,24 +1022,41 @@
                            {
                                curControlDev.bindList = dev.addedDeviceBindResponseData.BindList;
                                targetList.Clear();
                                isFinish = true;
                                if (isFinish)
                                switch (curDeviceBindType)
                                {
                                    if (action != null)
                                    {
                                        action(curControlDev.bindList);
                                    }
                                    this.RemoveFromParent();
                                    case 1:
                                        if (actionFreshAirTarget != null)
                                        {
                                            actionFreshAirTarget(bindName);
                                        }
                                        break;
                                    case 2:
                                        if (actionTemperatureTarget != null)
                                        {
                                            actionTemperatureTarget(bindName);
                                        }
                                        break;
                                    case 3:
                                        if (actionHumidityTarget != null)
                                        {
                                            actionHumidityTarget(bindName);
                                        }
                                        break;
                                    case 4:
                                        if (actionPMTarget != null)
                                        {
                                            actionPMTarget(bindName);
                                        }
                                        break;
                                }
                                else
                                {
                                    this.RemoveFromParent();
                                }
                                Application.RunOnMainThread(() =>
                                {
                                    CommonPage.Loading.Hide();
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    this.RemoveFromParent();
                                });
                            }
                            else if (dev.addedDeviceBindResponseData.Result == 1)
@@ -1118,68 +1095,12 @@
                            }
                        }
                    }
                    catch
                    catch (Exception ex)
                    {
                        var mess = ex.Message;
                    }
                });
            }
        }
        /// <summary>
        /// 删除存在的目标
        /// </summary>
        /// <param name="bindDevice"></param>
        /// <param name="btnDel"></param>
        /// <returns></returns>
        private async System.Threading.Tasks.Task<int> RemoveTargets(CommonDevice delDev)
        {
            var delDevice = new DelDeviceBindData();
            delDevice.DeviceAddr = curControlDev.DeviceAddr;
            delDevice.Epoint = curControlDev.DeviceEpoint;
            var removeDevice = new RemoveBindListObj();
            removeDevice.BindType = 0;
            switch (curDeviceBindType)
            {
                case 1:
                    removeDevice.BindCluster = 514;
                    break;
                case 2:
                    removeDevice.BindCluster = 1026;
                    break;
                case 3:
                    removeDevice.BindCluster = 1029;
                    break;
            }
            removeDevice.BindMacAddr = delDev.DeviceAddr;
            removeDevice.BindEpoint = delDev.DeviceEpoint;
            delDevice.RemoveBindList.Add(removeDevice);
            try
            {
                CommonPage.Loading.Start("");
                var delResult = new DelDeviceBindResponseAllData();
                delResult = await curControlDev.DelDeviceBindAsync(delDevice);
                if (delResult != null && delResult.delDeviceBindResponseData != null)
                {
                    if (delResult.delDeviceBindResponseData?.RemoveBindList != null)
                    {
                        foreach (var re in delResult.delDeviceBindResponseData.RemoveBindList)
                        {
                            if (re.Result == 0)
                            {
                                return 0;
                            }
                            {
                                return -1;
                            }
                        }
                    }
                }
            }
            catch { }
            return -1;
        }
        /// <summary>
@@ -1208,7 +1129,7 @@
        /// <summary>
        /// 能显示的房间列表
        /// </summary>
        private List<Room> GetSupportRoomList(Room curRoom)
        private List<Room> GetSupportRoomList()
        {
            var roomTempList = new List<Room>();
            for (int i = 0; i < supportRoomList.Count; i++)
@@ -1225,11 +1146,81 @@
                {
                    continue;
                }
                roomTempList.Add(room);
                if (roomTempList.Count != 0)
                else
                {
                    curRoom = roomTempList[0];
                    List<CommonDevice> roomIncludeMatchDevice = new List<CommonDevice>();
                    //房间中没有对应的支持绑定的目标
                    switch (curDeviceBindType)
                    {
                        case 1:
                            foreach (var de in room.ListDevice)
                            {
                                var device = LocalDevice.Current.GetDevice(de);
                                if (device != null)
                                {
                                    //获取设备类型的
                                    var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                                    //新风面板的新风设备,则不显示
                                    if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                                    {
                                        continue;
                                    }
                                    if (device.Type == DeviceType.FreshAir)
                                    {
                                        roomIncludeMatchDevice.Add(device);
                                    }
                                }
                            }
                            break;
                        case 2:
                            foreach (var de in room.ListDevice)
                            {
                                var device = LocalDevice.Current.GetDevice(de);
                                if (device != null)
                                {
                                    if (device.Type == DeviceType.TemperatureSensor)
                                    {
                                        roomIncludeMatchDevice.Add(device);
                                    }
                                }
                            }
                            break;
                        case 3:
                            foreach (var de in room.ListDevice)
                            {
                                var device = LocalDevice.Current.GetDevice(de);
                                if (device != null)
                                {
                                    if (device.Type == DeviceType.FreshAirHumiditySensor)
                                    {
                                        roomIncludeMatchDevice.Add(device);
                                    }
                                }
                            }
                            break;
                        case 4:
                            break;
                    }
                    if (roomIncludeMatchDevice.Count == 0)
                    {
                        continue;
                    }
                }
                if (!string.IsNullOrEmpty(room.FloorId))
                {
                    //有楼层
                    if (room.FloorId == curControlDev.currentSelectFloorId)
                    {
                        roomTempList.Add(room);
                    }
                }
                else
                {
                    //没有楼层
                    roomTempList.Add(room);
                }
            }
            return roomTempList;
@@ -1261,24 +1252,21 @@
            }
            else
            {
                // 获取楼层对应对房间
                // 获取支持的房间
                foreach (var room in listAllRoom)
                {
                    if (room.FloorId == curControlDev.currentSelectFloorId)
                    if (room.IsLove)
                    {
                        if (room.IsLove)
                        {
                            continue;
                        }
                        supportRoomListTemp.Add(room);
                        continue;
                    }
                    supportRoomListTemp.Add(room);
                }
            }
            return supportRoomListTemp;
        }
        /// <summary>
        /// 房间中匹配的支持绑定的所有目标列表
        /// 所有房间中匹配的支持绑定的所有目标列表
        /// </summary>
        /// <returns></returns>
        List<CommonDevice> GetAllRoomSupportDeviceList()
@@ -1299,13 +1287,13 @@
                            var device = LocalDevice.Current.GetDevice(deviceKeys);
                            if (device != null)
                            {
                                ////获取设备类型的
                                //var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                                ////新风面板的新风设备,则不显示
                                //if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                                //{
                                //    continue;
                                //}
                                //获取设备类型的
                                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                                //新风面板的新风设备,则不显示
                                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                                {
                                    continue;
                                }
                                if (device.Type == DeviceType.FreshAir)
                                {
                                    currentPanelBindSupportDeviceListTemp.Add(device);
@@ -1315,8 +1303,44 @@
                    }
                    break;
                case 2:
                    foreach (var r in supportRoomList)
                    {
                        if (r.ListDevice.Count == 0)
                        {
                            continue;
                        }
                        foreach (var deviceKeys in r.ListDevice)
                        {
                            var device = LocalDevice.Current.GetDevice(deviceKeys);
                            if (device != null)
                            {
                                if (device.Type == DeviceType.TemperatureSensor)
                                {
                                    currentPanelBindSupportDeviceListTemp.Add(device);
                                }
                            }
                        }
                    }
                    break;
                case 3:
                    foreach (var r in supportRoomList)
                    {
                        if (r.ListDevice.Count == 0)
                        {
                            continue;
                        }
                        foreach (var deviceKeys in r.ListDevice)
                        {
                            var device = LocalDevice.Current.GetDevice(deviceKeys);
                            if (device != null)
                            {
                                if (device.Type == DeviceType.FreshAirHumiditySensor)
                                {
                                    currentPanelBindSupportDeviceListTemp.Add(device);
                                }
                            }
                        }
                    }
                    break;
                case 4:
                    break;
@@ -1337,16 +1361,16 @@
                case 1:
                    foreach (var deviceKeys in curRoom.ListDevice)
                    {
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device != null)
                        {
                            ////获取设备类型的
                            //var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                            ////新风面板的新风设备,则不显示
                            //if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                            //{
                            //    continue;
                            //}
                            //获取设备类型的
                            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                            //新风面板的新风设备,则不显示
                            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                            {
                                continue;
                            }
                            if (device.Type == DeviceType.FreshAir)
                            {
                                curRoomDeviceListTemp.Add(device);
@@ -1355,14 +1379,50 @@
                    }
                    break;
                case 2:
                    foreach (var deviceKeys in curRoom.ListDevice)
                    {
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device != null)
                        {
                            if (device.Type == DeviceType.TemperatureSensor)
                            {
                                curRoomDeviceListTemp.Add(device);
                            }
                        }
                    }
                    break;
                case 3:
                    foreach (var deviceKeys in curRoom.ListDevice)
                    {
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device != null)
                        {
                            if (device.Type == DeviceType.FreshAirHumiditySensor)
                            {
                                curRoomDeviceListTemp.Add(device);
                            }
                        }
                    }
                    break;
                case 4:
                    break;
            }
            return curRoomDeviceListTemp;
        }
        #endregion
        #endregion
        #region 移除方法
        /// <summary>
        /// 重写移除方法
        /// </summary>
        public override void RemoveFromParent()
        {
            actionFreshAirTarget = null;
            actionTemperatureTarget = null;
            actionHumidityTarget = null;
            actionPMTarget = null;
            base.RemoveFromParent();
        }
        #endregion
    }
}