xm
2020-05-13 99da2604f81af29afc6b3c6f4f128b4e5a8a5649
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
@@ -103,6 +103,10 @@
        /// PM绑定目标回调
        /// </summary>
        public Action<string> actionPMTarget = null;
        /// <summary>
        /// 是否能点击保存按钮
        /// </summary>
        private bool canSave = true;
        #endregion
        #region UI设计 
@@ -358,7 +362,6 @@
                        curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                    }
                    curRoom = room;
                    curControlDev.RoomId = room.Id;
                    //新风面板保存使能
                    btnFinifh.Enable = true;
@@ -865,6 +868,7 @@
        /// <param name="curControlDev"></param>
        void SaveTarget()
        {
            btnFinifh.Enable = false;
            if (targetList.Count == 0)
            {
                //空目标
@@ -979,6 +983,11 @@
                    catch (Exception ex)
                    {
                        var mess = ex.Message;
                        Application.RunOnMainThread(() =>
                        {
                            CommonPage.Loading.Hide();
                        });
                        btnFinifh.Enable = true;
                    }
                });
            }
@@ -1012,31 +1021,32 @@
                        {
                            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)
                                var delDevice = DelBindDevice(bd);
                                var delResult = new DelDeviceBindResponseAllData();
                                delResult = await curControlDev.DelDeviceBindAsync(delDevice);
                                if (delResult != null && delResult.removeBindResultResponseData != null)
                                {
                                    case 1:
                                        removeDevice.BindCluster = 514;
                                        break;
                                    case 2:
                                        removeDevice.BindCluster = 1026;
                                        break;
                                    case 3:
                                        removeDevice.BindCluster = 1029;
                                        break;
                                    case 4:
                                        //PM2.5
                                        break;
                                    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;
                                    }
                                }
                                removeDevice.BindMacAddr = bd.DeviceAddr;
                                removeDevice.BindEpoint = bd.DeviceEpoint;
                                delDevice.RemoveBindList.Add(removeDevice);
                            }
                        }
                        else
                        {
                            //检测已经绑定的目标是否不在本地或者没有分配到任何房间中
                            //此时需要删除已经被绑定到目标,才能继续绑定新目标
                            if (curBindDevice != null)
                            {
                                var delDevice = DelBindDevice(curBindDevice);
                                var delResult = new DelDeviceBindResponseAllData();
                                delResult = await curControlDev.DelDeviceBindAsync(delDevice);
                                if (delResult != null && delResult.removeBindResultResponseData != null)
@@ -1180,6 +1190,11 @@
                    }
                    catch (Exception ex)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            CommonPage.Loading.Hide();
                        });
                        btnFinifh.Enable = true;
                        var mess = ex.Message;
                    }
                });
@@ -1235,6 +1250,39 @@
        }
        /// <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 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);
            return delDevice;
        }
        /// <summary>
        /// 能显示的房间列表
        /// </summary>
        private List<Room> GetSupportRoomList()
@@ -1265,6 +1313,7 @@
                            foreach (var de in room.ListDevice)
                            {
                                var device = LocalDevice.Current.GetDevice(de);
                                if (device != null)
                                {
                                    //获取设备类型的
@@ -1335,6 +1384,11 @@
            foreach (var de in room.ListDevice)
            {
                var device = LocalDevice.Current.GetDevice(de);
                //电池设备不支持绑定
                if (device.ZigbeeType != 1)
                {
                    continue;
                }
                if (device != null)
                {
                    if (device.Type == DeviceType.TemperatureSensor)
@@ -1360,6 +1414,11 @@
            foreach (var de in room.ListDevice)
            {
                var device = LocalDevice.Current.GetDevice(de);
                //电池设备不支持绑定
                if (device.ZigbeeType != 1)
                {
                    continue;
                }
                if (device != null)
                {
                    if (device.Type == DeviceType.TemperatureSensor)