xm
2020-05-07 c1de48884fa145a16a0f8bcee93274dcfaa0ff82
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Microsoft.AppCenter.Crashes;
using Shared.Common;
using Shared.Phone.UserCenter.Safety;
using ZigBee.Device;
@@ -275,9 +274,17 @@
            FrameLayout curentOldRoomFrameLayout = null;
            int index = 0;
            var roomTempList = GetSupportRoomList();
            Room slectedRoom = null;
            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
                {
@@ -304,7 +311,7 @@
                btnRoomFrameLayout.AddChidren(btnRoom);
                btnRoom.IsSelected = false;
                if (index == 0)
                if (canSelect)
                {
                    btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                    btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
@@ -350,13 +357,20 @@
            }
            BindInfo.FinishDisplay(roomTempList, btnFinifh);
            if (roomTempList.Count != 0)
            if (roomTempList.Count == 0)
            {
                curRoom = roomTempList[0];
                curRoom = new Shared.Common.Room();
            }
            else
            {
                curRoom = new Shared.Common.Room();
                if (slectedRoom == null)
                {
                    curRoom = roomTempList[0];
                }
                else
                {
                    curRoom = slectedRoom;
                }
            }
            RefreshDeviceList(curRoom);
@@ -453,38 +467,38 @@
                }
                EventHandler<MouseEventArgs> hander = (sender, e) =>
               {
                   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)
                       {
                           oldDevice.IsSelected = false;
                           oldDevice.Visible = false;
                       }
                       oldDevice = btnChoose;
                       oldDevice.IsSelected = true;
                       oldDevice.Visible = true;
                       targetList.Clear();
                       targetList.Add(device);
                   }
                {
                    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)
                        {
                            oldDevice.IsSelected = false;
                            oldDevice.Visible = false;
                        }
                        oldDevice = btnChoose;
                        oldDevice.IsSelected = true;
                        oldDevice.Visible = true;
                        targetList.Clear();
                        targetList.Add(device);
                    }
                   //新风面板:由于目标没有提供删除接口,所以可以取消选中能保存
                   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;
@@ -594,7 +608,7 @@
                    btnFloorText.Text = dicFloorList[floorId];
                    //获取楼层中房间列表 
                    supportRoomList = GetFloorRoomList();
                    supportRoomList = GetFloorRoomList(curFloorId);
                    if (!btnMethodText.IsSelected)
                    {
                        if (oldbutton != null)
@@ -654,21 +668,8 @@
                    //获取楼层
                    dicFloorList = HdlRoomLogic.Current.GetFloorSortList();
                    curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
                    if (BindInfo.GetCurrentSelectFloorIdName() != null)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
                        });
                    }
                    //获取楼层中房间列表
                    supportRoomList = GetFloorRoomList();
                    if (supportRoomList.Count == 0)
                    {
                        return;
                    }
                    supportRoomList = GetFloorRoomList(curControlDev.currentSelectFloorId);
                    //获取所有房间中匹配的能绑的目标
                    currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList();
@@ -753,21 +754,56 @@
                {
                    Application.RunOnMainThread(() =>
                    {
                        if (supportRoomList.Count != 0)
                        {
                            RefreshRoomList();
                        }
                        //首次是否能点击保存
                        if (targetList.Count == 0)
                        {
                            curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
                            if (BindInfo.GetCurrentSelectFloorIdName() != null)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
                                });
                            }
                            btnFinifh.Enable = false;
                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                        }
                        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;
                                    }
                                }
                            }
                            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;
                        }
                        //获取楼层中房间列表
                        if (supportRoomList.Count != 0)
                        {
                            RefreshRoomList();
                        }
                        CommonPage.Loading.Hide();
@@ -1231,7 +1267,7 @@
        /// 获取楼层对应的房间列表
        /// </summary>
        /// <returns></returns>
        private List<Room> GetFloorRoomList()
        private List<Room> GetFloorRoomList(string floorId)
        {
            supportRoomList.Clear();
            var supportRoomListTemp = new List<Room>();
@@ -1243,6 +1279,10 @@
                {
                    if (string.IsNullOrEmpty(room.FloorId))
                    {
                        if (room.FloorId != floorId)
                        {
                            continue;
                        }
                        if (room.IsLove)
                        {
                            continue;
@@ -1362,7 +1402,7 @@
                case 1:
                    foreach (var deviceKeys in curRoom.ListDevice)
                    {
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device != null)
                        {
                            //获取设备类型的
@@ -1382,7 +1422,7 @@
                case 2:
                    foreach (var deviceKeys in curRoom.ListDevice)
                    {
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device != null)
                        {
                            if (device.Type == DeviceType.TemperatureSensor)
@@ -1395,7 +1435,7 @@
                case 3:
                    foreach (var deviceKeys in curRoom.ListDevice)
                    {
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device != null)
                        {
                            if (device.Type == DeviceType.FreshAirHumiditySensor)