From 1c2b6fa69a7002315d4b3ecb883c255c65eceafa Mon Sep 17 00:00:00 2001
From: lss <316519258@qq.com>
Date: 星期三, 03 六月 2020 10:58:18 +0800
Subject: [PATCH] 2020.06.03

---
 ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs |   96 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 93 insertions(+), 3 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs
index dc3d1db..19fbe70 100644
--- a/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs
+++ b/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();
                 };

--
Gitblit v1.8.0