lss
2020-06-03 1c2b6fa69a7002315d4b3ecb883c255c65eceafa
ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs
@@ -66,7 +66,7 @@
                    SmartSound.CurretnData = new List<SmartSound.Layer>();
                SmartSound.CurretnData.Clear();
                SmartSound.CurretnData = TempDatas;
                SmartSound.CurretnData = CollateData();
                this.CloseForm();
            };
@@ -107,6 +107,7 @@
        }
        #endregion
        /// <summary>
        /// 将数据转换为智能音箱使用的数据
        /// </summary>
@@ -304,6 +305,8 @@
            SmartSound.Layer tempLayer = SmartSound.LocaData[CurrentIndex];
            if (tempLayer == null) return;
            #region 添加楼层
            bool floor_exists = false;
@@ -347,6 +350,7 @@
                if (!room_exists)
                {
                    TempDatas[i].RoomList.Add(room);
                    CheckedAll(room);//添加房间成功,默认选中所有设备
                    break;
                }
            }
@@ -372,6 +376,89 @@
                }
            }
            catch { }
        }
        /// <summary>
        /// 默认选择所有设备
        /// </summary>
        /// <param name="room"></param>
        private void CheckedAll(SmartSound.Room room)
        {
            // 标记所有场景
            for (int n = 0; n < room.SceneList.Count; n++)
            {
                SmartSound.Scene _scene = room.SceneList[n];
                _scene.Checked = true;
            }
            //标记所有设备
            for (int k = 0; k < room.DeviceList.Count; k++)
            {
                SmartSound.Device _device = room.DeviceList[k];
                _device.Checked = true;
            }
        }
        /// <summary>
        /// 重新整理数据,把没有选中的数据都剔除掉
        /// </summary>
        private List<SmartSound.Layer> CollateData()
        {
            try
            {
                //移出未选中的设备、场景
                for (int i = 0; i < TempDatas.Count; i++)
                {
                    SmartSound.Layer _layer = TempDatas[i];
                    for (int j = 0; j < _layer.RoomList.Count; j++)
                    {
                        SmartSound.Room _room = _layer.RoomList[j];
                        if (_room.Checked)
                        {
                            #region 清除未选中的设备
                            for (int k = 0; k < _room.DeviceList.Count; k++)
                            {
                                SmartSound.Device _device = _room.DeviceList[k];
                                if (!_device.Checked)
                                {
                                    _room.DeviceList.Remove(_device);
                                }
                            }
                            #endregion
                            #region 清除未选中的场景
                            for (int n = 0; n < _room.SceneList.Count; n++)
                            {
                                SmartSound.Scene _scene = _room.SceneList[n];
                                if (!_scene.Checked)
                                {
                                    _room.SceneList.Remove(_scene);
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            _layer.RoomList.Remove(_room);
                        }
                    }
                }
                //移出没有设备的房间
                for (int j = 0; j < TempDatas.Count; j++)
                {
                    SmartSound.Layer _layer = TempDatas[j];
                    if (_layer.RoomList.Count < 1)
                    {
                        TempDatas.Remove(_layer);
                    }
                }
            }
            catch { }
            return TempDatas;
        }
        #region ■ 自定义楼层选择控件_____________________
@@ -458,6 +545,7 @@
        private class RoomRowLayout : FrameRowControl
        {
            private SmartSoundControlContentForm smartSoundControlContentForm = null;
            private SmartSound.Room mRoom = null;
            /// <summary>
            /// 房间名称
@@ -477,14 +565,14 @@
                this.BackgroundColor = UserCenterColor.Current.White;
                this.Height = Application.GetRealHeight(170);
            }
            /// <summary>
            /// 初始化控件
            /// </summary>
            public void InitControl()
            {
                //显示文本
                btnName = this.AddLeftCaption(string.Empty, 700);
                btnName = this.AddLeftCaption(string.Empty, 2000);
                btnName.Height = Application.GetRealHeight(60);
                btnName.TextSize = 17;
                btnName.Y = Application.GetRealHeight(57);
@@ -497,6 +585,8 @@
                btnName.ButtonClickEvent += (sender, e) =>
                {
                    mRoom.Checked = true;
                    RefreshRightIconState(mRoom.Checked);
                    SmartSoundContentForDevice deviceForm = new SmartSoundContentForDevice(mRoom);
                    deviceForm.AddForm();
                };