From a715181089be0d31cd737a5367ffd02690b9d77f Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 12 十一月 2020 13:36:01 +0800
Subject: [PATCH] 20201112

---
 HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs |  719 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 517 insertions(+), 202 deletions(-)

diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs
index e0eb990..4f332e2 100644
--- a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs
+++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs
@@ -11,7 +11,7 @@
     {
 
         #region 鎺т欢鍒楄〃
-        FrameLayout bodyView;
+        static ClassificationPage bodyView;
         #region 椤堕儴鎺т欢
         /// <summary>
         /// 鎴块棿鍒嗛〉
@@ -40,11 +40,11 @@
         /// <summary>
         /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣
         /// </summary>
-        Button btnFoorDownIcon;
+        Button btnFloorDownIcon;
         /// <summary>
         /// 妤煎眰鏄剧ず
         /// </summary>
-        Button btnFoor;
+        Button btnFloor;
         /// <summary>
         /// 鏄剧ず鏂瑰紡鍒囨崲鎸夐挳
         /// </summary>
@@ -54,10 +54,6 @@
         /// 鎴块棿鍒楄〃鍖哄煙
         /// </summary>
         VerticalScrolViewLayout roomListView;
-        /// <summary>
-        /// 鎴块棿鍖哄煙闆嗗悎
-        /// </summary>
-        List<FrameLayout> roomViewList;
         #endregion
 
         #region 鍔熻兘鍖哄煙
@@ -68,9 +64,14 @@
 
         #endregion
 
+
+        List<Room> roomsShowed;
+
         public ClassificationPage()
         {
             bodyView = this;
+            roomsShowed = new List<Room>();
+            roomsShowed.AddRange(DB_ResidenceData.rooms);
         }
 
         public void LoadPage()
@@ -116,7 +117,7 @@
             contentPageView = new PageLayout()
             {
                 Y = Application.GetRealHeight(64),
-                Height = Application.GetRealHeight(667 - 64-49+20),
+                Height = Application.GetRealHeight(667 - 64 - 49 + 30),
                 BackgroundColor = CSS_Color.MainBackgroundColor,
                 IsShowPoint = false
             };
@@ -143,7 +144,7 @@
                 Height = Application.GetRealHeight(52),
             };
             roomPageView.AddChidren(roomFloorChangeView);
-            #region 鎴块棿搴曢儴鍒囨崲鏄剧ず鍖哄煙
+            #region 鎴块棿椤堕儴鍒囨崲鏄剧ず鍖哄煙
             /// <summary>
             /// 鎴块棿鍖哄煙锛岄《閮ㄥ尯鍩�
             /// </summary>
@@ -155,7 +156,7 @@
             /// <summary>
             /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣
             /// </summary>
-            btnFoorDownIcon = new Button()
+            btnFloorDownIcon = new Button()
             {
                 Width = Application.GetMinRealAverage(16),
                 Height = Application.GetMinRealAverage(16),
@@ -163,37 +164,36 @@
                 Y = Application.GetRealHeight(18),
                 UnSelectedImagePath = "Public/DownIcon.png",
             };
-            roomFloorChangeView.AddChidren(btnFoorDownIcon);
+            roomFloorChangeView.AddChidren(btnFloorDownIcon);
             /// <summary>
             /// 妤煎眰鏄剧ず
             /// </summary>
-            btnFoor = new Button()
+            btnFloor = new Button()
             {
-                X = btnFoorDownIcon.Right,
+                X = btnFloorDownIcon.Right,
                 Y = Application.GetRealHeight(18),
                 Width = Application.GetRealWidth(200),
                 Height = Application.GetMinRealAverage(16),
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                 TextAlignment = TextAlignment.CenterLeft,
-                Text = UserConfig.Instance.CurFoor,
+                Text = DB_ResidenceData.residenceData.CurFoor,
             };
-            roomFloorChangeView.AddChidren(btnFoor);
+            roomFloorChangeView.AddChidren(btnFloor);
             /// <summary>
             /// 鏄剧ず鏂瑰紡鍒囨崲鎸夐挳
             /// </summary>
-            btnSwitchDipaly = new Button()
-            {
-                X = Application.GetRealWidth(335),
-                Y = Application.GetRealHeight(12),
-                Width = Application.GetMinRealAverage(28),
-                Height = Application.GetMinRealAverage(28),
-                UnSelectedImagePath = "Classification/ToggleDisplayThumbnail.png",//缂╃暐鍥�
-                SelectedImagePath = "Classification/ToggleDisplayLarge.png",
-            };
-            roomFloorChangeView.AddChidren(btnSwitchDipaly);
+            //btnSwitchDipaly = new Button()
+            //{
+            //    X = Application.GetRealWidth(335),
+            //    Y = Application.GetRealHeight(12),
+            //    Width = Application.GetMinRealAverage(28),
+            //    Height = Application.GetMinRealAverage(28),
+            //    UnSelectedImagePath = "Classification/ToggleDisplayThumbnail.png",//缂╃暐鍥�
+            //    SelectedImagePath = "Classification/ToggleDisplayLarge.png",
+            //};
+            //roomFloorChangeView.AddChidren(btnSwitchDipaly);
             #endregion
-
 
             /// <summary>
             /// 鎴块棿鍒楄〃鍖哄煙
@@ -202,35 +202,46 @@
             {
                 Y = roomFloorChangeView.Bottom,
                 Height = Application.GetRealHeight(497 + 10 + 30),
-                BackgroundColor = CSS_Color.MainBackgroundColor,
+                //BackgroundColor = CSS_Color.MainBackgroundColor,
             };
             roomPageView.AddChidren(roomListView);
-            /// <summary>
-            /// 鎴块棿鍖哄煙闆嗗悎
-            /// </summary>
-            roomViewList = new List<FrameLayout>();
+            LoadRoomRows();
+            roomListView.AddChidren(new Button() { Height = Application.GetRealHeight(20) });//澶珮瑙嗗浘锛屽皢瀵艰埅浜嗛伄鎸$殑閮ㄥ垎瀹屾暣鏄剧ず
+            #endregion
 
-            foreach (var room in DB_ResidenceData.residenceData.rooms)
+            LoadDialog_ChangeFloor();
+        }
+
+        /// <summary>
+        /// 鍔犺浇鎴块棿鍒楄〃鍖哄煙
+        /// </summary>
+        void LoadRoomRows()
+        {
+            roomListView.RemoveAll();
+            foreach (var room in roomsShowed)
             {
                 var roomView = new FrameLayout()
                 {
                     Gravity = Gravity.CenterHorizontal,
                     Width = Application.GetRealWidth(343),
                     Height = Application.GetRealHeight(184),
-                    Radius = (uint)Application.GetRealHeight(12),
-                    BorderColor = 0x00000000,
-                    BorderWidth = 1,
+                    Radius = (uint)Application.GetRealWidth(12),
+                    Tag = room.sid,
                 };
                 roomListView.AddChidren(roomView);
 
-                var roomViewbg = new Button()
+                var roomViewbg = new ImageView()
                 {
-                    UnSelectedImagePath = room.backgroundImage,
+                    Width = Application.GetRealWidth(343),
+                    Height = Application.GetRealHeight(184),
+                    ImagePath = room.backgroundImage,
+                    Radius = (uint)Application.GetRealWidth(12),
                 };
                 roomView.AddChidren(roomViewbg);
 
                 var roomViewbgColor = new Button()
                 {
+                    Radius = (uint)Application.GetRealWidth(12),
                     BackgroundColor = 0x19333333,
                 };
                 roomView.AddChidren(roomViewbgColor);
@@ -241,107 +252,104 @@
                     Y = Application.GetRealHeight(12 - 2),
                     Width = Application.GetRealWidth(266),
                     Height = Application.GetRealHeight(22 + 2 + 2),
-                    Text = room.floor + "  " + room.name,
+                    Text = room.floorName + room.name,
                     TextAlignment = TextAlignment.CenterLeft,
                     TextColor = CSS_Color.MainBackgroundColor,
                     TextSize = CSS_FontSize.SubheadingFontSize,
                 };
                 roomView.AddChidren(btnFloorAndRoomName);
 
-
                 #region 鐜鏁版嵁
                 var environmentalView = new FrameLayout()
-                {
-                    Y = Application.GetRealHeight(2) + btnFloorAndRoomName.Bottom,
-                    Height = Application.GetRealHeight(32),
-                    Tag = "EnvironmentalView",
-                };
-                roomView.AddChidren(environmentalView);
+                                {
+                                    Y = Application.GetRealHeight(2) + btnFloorAndRoomName.Bottom,
+                                    Height = Application.GetRealHeight(32),
+                                    Tag = "EnvironmentalView",
+                                };
+                                roomView.AddChidren(environmentalView);
 
-                Button btnTempIcon = new Button()
-                {
-                    X = Application.GetRealWidth(12),
-                    Gravity = Gravity.CenterVertical,
-                    Width = Application.GetMinRealAverage(16),
-                    Height = Application.GetMinRealAverage(16),
-                    UnSelectedImagePath = "Public/InfoIcon/TempIcon.png",
-                };
-                environmentalView.AddChidren(btnTempIcon);
+                                Button btnTempIcon = new Button()
+                                {
+                                    X = Application.GetRealWidth(12),
+                                    Gravity = Gravity.CenterVertical,
+                                    Width = Application.GetMinRealAverage(16),
+                                    Height = Application.GetMinRealAverage(16),
+                                    UnSelectedImagePath = "Public/DeviceInfoIcon/TempIcon.png",
+                                };
+                                environmentalView.AddChidren(btnTempIcon);
 
-                var btnTempValues = new Button()
-                {
-                    X = btnTempIcon.Right + Application.GetRealWidth(4),
-                    Width = Application.GetRealWidth(30),
-                    Gravity = Gravity.CenterVertical,
-                    TextColor = CSS.CSS_Color.MainBackgroundColor,
-                    TextSize = CSS.CSS_FontSize.PromptFontSize_FirstLevel,
-                    Text = "--掳",
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Tag = "TempValues"
-                };
-                environmentalView.AddChidren(btnTempValues);
+                                var btnTempValues = new Button()
+                                {
+                                    X = btnTempIcon.Right + Application.GetRealWidth(4),
+                                    Width = Application.GetRealWidth(30),
+                                    Gravity = Gravity.CenterVertical,
+                                    TextColor = CSS_Color.MainBackgroundColor,
+                                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                                    Text = "--掳",
+                                    TextAlignment = TextAlignment.CenterLeft,
+                                    Tag = "TempValues"
+                                };
+                                environmentalView.AddChidren(btnTempValues);
 
-                Button btnHumidityIcon = new Button()
-                {
-                    X = btnTempValues.Right + Application.GetRealWidth(2),
-                    Gravity = Gravity.CenterVertical,
-                    Width = Application.GetMinRealAverage(16),
-                    Height = Application.GetMinRealAverage(16),
-                    UnSelectedImagePath = "Public/InfoIcon/HumidityIcon.png",
-                };
-                environmentalView.AddChidren(btnHumidityIcon);
+                                Button btnHumidityIcon = new Button()
+                                {
+                                    X = btnTempValues.Right + Application.GetRealWidth(2),
+                                    Gravity = Gravity.CenterVertical,
+                                    Width = Application.GetMinRealAverage(16),
+                                    Height = Application.GetMinRealAverage(16),
+                                    UnSelectedImagePath = "Public/DeviceInfoIcon/HumidityIcon.png",
+                                };
+                                environmentalView.AddChidren(btnHumidityIcon);
 
-                var btnHumidityValues = new Button()
-                {
-                    X = btnHumidityIcon.Right + Application.GetRealWidth(4),
-                    Width = Application.GetRealWidth(30),
-                    Gravity = Gravity.CenterVertical,
-                    TextColor = CSS.CSS_Color.MainBackgroundColor,
-                    TextSize = CSS.CSS_FontSize.PromptFontSize_FirstLevel,
-                    Text = "--%",
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Tag = "HumidityValues"
-                };
-                environmentalView.AddChidren(btnHumidityValues);
+                                var btnHumidityValues = new Button()
+                                {
+                                    X = btnHumidityIcon.Right + Application.GetRealWidth(4),
+                                    Width = Application.GetRealWidth(30),
+                                    Gravity = Gravity.CenterVertical,
+                                    TextColor = CSS_Color.MainBackgroundColor,
+                                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                                    Text = "--%",
+                                    TextAlignment = TextAlignment.CenterLeft,
+                                    Tag = "HumidityValues"
+                                };
+                                environmentalView.AddChidren(btnHumidityValues);
 
-                Button btnPm25Icon = new Button()
-                {
-                    X = btnHumidityValues.Right + Application.GetRealWidth(2),
-                    Gravity = Gravity.CenterVertical,
-                    Width = Application.GetMinRealAverage(16),
-                    Height = Application.GetMinRealAverage(16),
-                    UnSelectedImagePath = "Public/InfoIcon/Pm25Icon.png",
-                };
-                environmentalView.AddChidren(btnPm25Icon);
+                                Button btnPm25Icon = new Button()
+                                {
+                                    X = btnHumidityValues.Right + Application.GetRealWidth(2),
+                                    Gravity = Gravity.CenterVertical,
+                                    Width = Application.GetMinRealAverage(16),
+                                    Height = Application.GetMinRealAverage(16),
+                                    UnSelectedImagePath = "Public/DeviceInfoIcon/Pm25Icon.png",
+                                };
+                                environmentalView.AddChidren(btnPm25Icon);
 
-                var btnPm25Values = new Button()
-                {
-                    X = btnPm25Icon.Right + Application.GetRealWidth(4),
-                    Width = Application.GetRealWidth(30),
-                    Gravity = Gravity.CenterVertical,
-                    TextColor = CSS.CSS_Color.MainBackgroundColor,
-                    TextSize = CSS.CSS_FontSize.PromptFontSize_FirstLevel,
-                    Text = "--",
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Tag = "Pm25Values"
-                };
-                environmentalView.AddChidren(btnPm25Values);
-                roomView.AddChidren(environmentalView);
+                                var btnPm25Values = new Button()
+                                {
+                                    X = btnPm25Icon.Right + Application.GetRealWidth(4),
+                                    Width = Application.GetRealWidth(30),
+                                    Gravity = Gravity.CenterVertical,
+                                    TextColor = CSS_Color.MainBackgroundColor,
+                                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                                    Text = "--",
+                                    TextAlignment = TextAlignment.CenterLeft,
+                                    Tag = "Pm25Values"
+                                };
+                                environmentalView.AddChidren(btnPm25Values);
+                                roomView.AddChidren(environmentalView);
                 #endregion
-
                 var btnAllClose = new Button()
                 {
                     X = Application.GetRealWidth(282),
                     Y = Application.GetRealHeight(126),
                     Width = Application.GetMinRealAverage(58),
                     Height = Application.GetMinRealAverage(58),
-                    UnSelectedImagePath = "",
-                    SelectedImagePath = "Classification/Room/AllCloseIcon.png",
+                    UnSelectedImagePath = "Classification/Room/AllCloseIcon.png",
+                    Tag = "AllClose",
+                    Visible = false
                 };
                 roomView.AddChidren(btnAllClose);
-#if DEBUG
-                btnAllClose.IsSelected = true;
-#endif
+                LoadEvent_CloseAllFunction(btnAllClose, room);
 
                 var btn = new Button()
                 {
@@ -349,21 +357,19 @@
                 };
                 roomListView.AddChidren(btn);
 
+                roomViewbgColor.MouseUpEventHandler += (sender, e) =>
+                {
+                    Action<Room > ReloadRoomName = (obj) => {
+                        btnFloorAndRoomName.Text = obj.floorName + obj.name;
+                    };
 
-                roomViewList.Add(roomView);
-
-                roomViewbgColor.MouseUpEventHandler += (sender, e) => {
-                    var view = new RoomPage(room);
+                    var view = new RoomPage(room, ReloadRoomName);
                     MainPage.BasePageView.AddChidren(view);
                     view.LoadPage();
                     MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                 };
 
             }
-
-            roomListView.AddChidren(new Button() { Height = Application.GetRealHeight(20) });//澶珮瑙嗗浘锛屽皢瀵艰埅浜嗛伄鎸$殑閮ㄥ垎瀹屾暣鏄剧ず
-            #endregion
-
         }
 
         /// <summary>
@@ -385,12 +391,8 @@
                 Y = Application.GetRealHeight(16),
                 Height = Application.GetRealHeight(667 - 64 - 49 + 20),
             };
-
-            if (DB_ResidenceData.residenceData.functionTypeList.Count > 4)
-            {
-                functionContentView.Height += Application.GetRealHeight((220  * (DB_ResidenceData.residenceData.functionTypeList.Count - 4 - 2) / 2) + 20);
-            }
             functionsPageView.AddChidren(functionContentView);
+
 
             int index = 0;
             List<int> specialList = new List<int>() { 1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22 };
@@ -412,13 +414,82 @@
             var lastY1 = Application.GetRealWidth(16);
             var lastY2 = Application.GetRealWidth(16);
 
+            var functionCategoryCount = 0;
+
             foreach (var item in DB_ResidenceData.residenceData.functionTypeList)
             {
+                int functionCount = 0;
+                int functionOnCount = 0;
+                switch (item)
+                {
+                    case ShowFunction.Light:
+                        #region Light
+                        functionCount = DB_ResidenceData.functionList.lights.Count;
+                        functionOnCount = DB_ResidenceData.functionList.lights.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        #endregion
+                        break;
+                    case ShowFunction.AC:
+                        #region AC
+                        functionCount = DB_ResidenceData.functionList.aCs.Count;
+                        functionOnCount = DB_ResidenceData.functionList.aCs.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        #endregion
+                        break;
+                    case ShowFunction.Curtain:
+                        #region Curtain
+                        functionCount = DB_ResidenceData.functionList.curtains.Count;
+                        functionOnCount = DB_ResidenceData.functionList.curtains.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        #endregion
+                        break;
+                    case ShowFunction.FloorHeating:
+                        #region 鍦扮儹
+                        functionCount = DB_ResidenceData.functionList.floorHeatings.Count;
+                        functionOnCount = DB_ResidenceData.functionList.floorHeatings.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        #endregion
+                        break;
+                    case ShowFunction.DoorLock:
+                        break;
+                    case ShowFunction.Electric:
+                        #region 鐢靛櫒
+                        functionCount = DB_ResidenceData.functionList.electricals.Count;
+                        functionOnCount = DB_ResidenceData.functionList.electricals.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        #endregion
+                        break;
+                    case ShowFunction.EnergyMonitoring:
+                        break;
+                    case ShowFunction.Environmental:
+                        #region 鐜鏁版嵁
+                        functionCount = DB_ResidenceData.functionList.sensorsEnvironmentalScience.Count;
+                        #endregion
+                        break;
+                    case ShowFunction.FreshAir:
+                        break;
+                    case ShowFunction.Music:
+                        functionCount = Music.A31MusicModel.A31MusicModelList.Count;
+                        functionOnCount = Music.A31MusicModel.A31MusicModelList.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        break;
+                    case ShowFunction.Panel:
+                        break;
+                    case ShowFunction.SecurityMonitoring:
+                        break;
+                    case ShowFunction.Sensor:
+                        break;
+                    case ShowFunction.VideoIntercom:
+                        break;
+
+                }
+
+                if (functionCount == 0 && item != ShowFunction.Music)
+                {
+                    //continue;
+                }
+                functionCategoryCount++;
+
                 FrameLayout functionView = new FrameLayout()
                 {
                     Height = Application.GetRealWidth(161),
-                    Radius = (uint)Application.GetRealHeight(6),
+                    Radius = (uint)Application.GetRealWidth(6),
                     BackgroundColor = CSS_Color.MainBackgroundColor,
+                    Tag = item + "_View",
                     Y = index % 2 == 1 ? lastY2 : lastY1
                 };
                 //楂樺害绋嶉珮鐨剉iew
@@ -444,13 +515,6 @@
                     s2View.AddChidren(functionView);
                 }
 
-                Button btnFunctionViewBg;
-                btnFunctionViewBg = new Button()
-                {
-                    Height = Application.GetRealWidth(161),
-                    UnSelectedImagePath = "FunctionIcon/FunctionBg/" + item + "FunctionBg.png",
-                };
-                functionView.AddChidren(btnFunctionViewBg);
 
                 Button btnName = new Button()
                 {
@@ -465,13 +529,22 @@
                 functionView.AddChidren(btnName);
 
 
-                int functionCount = 0;
+                Button btnFunctionViewBg;
+                btnFunctionViewBg = new Button()
+                {
+                    Height = Application.GetRealWidth(161),
+                    UnSelectedImagePath = "FunctionIcon/FunctionBg/" + item + "FunctionBg.png",
+                };
+                functionView.AddChidren(btnFunctionViewBg);
+
+                int functionPageTitleId = 0;
                 switch (item)
                 {
-                    case "Light":
+                    case ShowFunction.Light:
                         #region Light
                         btnName.TextID = StringId.Lights;
-                        functionCount = DB_ResidenceData.residenceData.functionList.lights.Count;
+                        functionCount = DB_ResidenceData.functionList.lights.Count;
+                        functionOnCount = DB_ResidenceData.functionList.lights.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
                         Button btnLightPower = new Button()
                         {
                             X = Application.GetRealWidth(120),
@@ -480,23 +553,24 @@
                             Height = Application.GetRealWidth(32),
                             SelectedImagePath = "Public/PowerOpen.png",
                             UnSelectedImagePath = "Public/PowerClose.png",
+                            IsSelected = functionOnCount > 0,
+                            Tag = item + "_AllControl",
                         };
                         functionView.AddChidren(btnLightPower);
-                        btnLightPower.MouseUpEventHandler = (sender, e) => {
-                            LoadEvent_LightsPower(btnLightPower);
+
+                        btnLightPower.MouseUpEventHandler = (sender, e) =>
+                        {
+                            LoadEvent_SwitchFunction(btnLightPower, item);
                         };
-                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) => {
-                            var skipView = new FunctionPage();
-                            MainPage.BasePageView.AddChidren(skipView);
-                            skipView.LoadPage(StringId.Lights);
-                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-                        };
+                        functionPageTitleId = StringId.Lights;
+                      
                         #endregion
                         break;
-                    case "AC":
+                    case ShowFunction.AC:
                         #region AC
                         btnName.TextID = StringId.AC;
-                        functionCount = DB_ResidenceData.residenceData.functionList.aCs.Count;
+                        functionCount = DB_ResidenceData.functionList.aCs.Count;
+                        functionOnCount = DB_ResidenceData.functionList.aCs.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
                         Button btnAcPower = new Button()
                         {
                             X = Application.GetRealWidth(120),
@@ -505,24 +579,22 @@
                             Height = Application.GetRealWidth(32),
                             SelectedImagePath = "Public/PowerOpen.png",
                             UnSelectedImagePath = "Public/PowerClose.png",
+                            Tag = item + "_AllControl",
+                            IsSelected = functionOnCount > 0,
                         };
                         functionView.AddChidren(btnAcPower);
-                        btnAcPower.MouseUpEventHandler = (sender, e) => {
-                            LoadEvent_LightsPower(btnAcPower);
+                        btnAcPower.MouseUpEventHandler = (sender, e) =>
+                        {
+                            LoadEvent_SwitchFunction(btnAcPower, item);
                         };
-                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) => {
-                            var skipView = new FunctionPage();
-                            MainPage.BasePageView.AddChidren(skipView);
-                            skipView.LoadPage(StringId.AC);
-                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-                        };
+                        functionPageTitleId = StringId.AC;
                         #endregion
                         break;
-                    case "Curtain":
+                    case ShowFunction.Curtain:
                         #region Curtain
                         btnName.TextID = StringId.Curtain;
-                        functionCount = DB_ResidenceData.residenceData.functionList.curtains.Count;
-
+                        functionCount = DB_ResidenceData.functionList.curtains.Count;
+                        functionOnCount = DB_ResidenceData.functionList.curtains.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
                         Button btnClose;
                         btnClose = new Button()
                         {
@@ -532,6 +604,8 @@
                             Height = Application.GetRealWidth(32),
                             UnSelectedImagePath = "FunctionIcon/Curtain/CurtainCloseIcon.png",
                             SelectedImagePath = "FunctionIcon/Curtain/CurtainCloseOnIcon.png",
+                            //Tag = item + "_AllControl",
+                            IsSelected = false
                         };
                         functionView.AddChidren(btnClose);
 
@@ -544,77 +618,318 @@
                             Height = Application.GetRealWidth(32),
                             UnSelectedImagePath = "FunctionIcon/Curtain/CurtainOpenIcon.png",
                             SelectedImagePath = "FunctionIcon/Curtain/CurtainOpenOnIcon.png",
+                            IsSelected = true,
                         };
                         functionView.AddChidren(btnOpen);
                         LoadEvent_CurtainSwitch(btnClose, btnOpen);
 
-                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) => {
-                            var skipView = new FunctionPage();
+                        functionPageTitleId = StringId.Curtain;
+                        #endregion
+                        break;
+                    case ShowFunction.FloorHeating:
+                        #region 鍦扮儹
+                        btnName.TextID = StringId.FloorHeating;
+                        functionCount = DB_ResidenceData.functionList.floorHeatings.Count;
+                        functionOnCount = DB_ResidenceData.functionList.floorHeatings.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        Button btnFhPower = new Button()
+                        {
+                            X = Application.GetRealWidth(120),
+                            Y = specialList.Contains(index) ? Application.GetRealWidth(160) : Application.GetRealWidth(117),
+                            Width = Application.GetRealWidth(32),
+                            Height = Application.GetRealWidth(32),
+                            SelectedImagePath = "Public/PowerOpen.png",
+                            UnSelectedImagePath = "Public/PowerClose.png",
+                            Tag = item + "_AllControl",
+                            IsSelected = functionOnCount > 0
+                        };
+                        functionView.AddChidren(btnFhPower);
+                        btnFhPower.MouseUpEventHandler = (sender, e) =>
+                        {
+                            LoadEvent_SwitchFunction(btnFhPower, item);
+                        };
+                        functionPageTitleId = StringId.FloorHeating;
+                        #endregion
+                        break;
+                    case ShowFunction.DoorLock:
+                        btnName.TextID = StringId.DoorLock;
+                        break;
+                    case ShowFunction.Electric:
+                        #region 鐢靛櫒
+                        btnName.TextID = StringId.Electric;
+                        functionCount = DB_ResidenceData.functionList.electricals.Count;
+                        functionOnCount = DB_ResidenceData.functionList.electricals.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        Button btnElectricPower = new Button()
+                        {
+                            X = Application.GetRealWidth(120),
+                            Y = specialList.Contains(index) ? Application.GetRealWidth(160) : Application.GetRealWidth(117),
+                            Width = Application.GetRealWidth(32),
+                            Height = Application.GetRealWidth(32),
+                            SelectedImagePath = "Public/PowerOpen.png",
+                            UnSelectedImagePath = "Public/PowerClose.png",
+                            Tag = item + "_AllControl",
+                            IsSelected = functionOnCount > 0,
+                        };
+                        functionView.AddChidren(btnElectricPower);
+                        btnElectricPower.MouseUpEventHandler = (sender, e) =>
+                        {
+                            LoadEvent_SwitchFunction(btnElectricPower, item);
+                        };
+                        functionPageTitleId = StringId.Electric;
+                        #endregion
+                        break;
+                    case ShowFunction.EnergyMonitoring:
+                        btnName.TextID = StringId.EnergyMonitoring;
+                        break;
+                    case ShowFunction.Environmental:
+                        #region 鐜鏁版嵁
+                        btnName.TextID = StringId.EnvironmentalData;
+                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) =>
+                        {
+                            var skipView = new EnvironmentalSciencePage();
                             MainPage.BasePageView.AddChidren(skipView);
-                            skipView.LoadPage(StringId.Curtain);
+                            skipView.LoadPage();
                             MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                         };
                         #endregion
                         break;
-                    case "FloorHeating":
-                        btnName.TextID = StringId.FloorHeating;
-                        break;
-                    case "DoorLock":
-                        btnName.TextID = StringId.DoorLock;
-                        break;
-                    case "Electric":
-                        btnName.TextID = StringId.Electric;
-                        break;
-                    case "EnergyMonitoring":
-                        btnName.TextID = StringId.EnergyMonitoring;
-                        break;
-                    case "Environmental":
-                        btnName.TextID = StringId.Environmental;
-                        break;
-                    case "FreshAir":
+                    case ShowFunction.FreshAir:
                         btnName.TextID = StringId.FreshAir;
                         break;
-                    case "Music":
+                    case ShowFunction.Music:
                         btnName.TextID = StringId.Music;
+                        functionCount = Music.A31MusicModel.A31MusicModelList.Count;
+                        functionOnCount = Music.A31MusicModel.A31MusicModelList.FindAll((obj) => obj.trait_on_off.value.ToString() == "on").Count;
+                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) =>
+                        {
+                            var musicMain = new Music.MusicMain();
+                            MainPage.BasePageView.AddChidren(musicMain);
+                            musicMain.Show();
+                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        };
                         break;
-                    case "Panel":
+                    case ShowFunction.Panel:
                         btnName.TextID = StringId.Panel;
                         break;
-                    case "SecurityMonitoring":
+                    case ShowFunction.SecurityMonitoring:
                         btnName.TextID = StringId.SecurityMonitoring;
                         break;
-                    case "Sensor":
+                    case ShowFunction.Sensor:
                         btnName.TextID = StringId.Sensor;
+
                         break;
-                    case "VideoIntercom":
+                    case ShowFunction.VideoIntercom:
                         btnName.TextID = StringId.VideoIntercom;
                         break;
 
                 }
-
-                Button btnFunctionCount = new Button()
+                //鐣岄潰璺宠浆--闊充箰璺宠浆鑷繁鐨勭晫闈�--鐜璺宠浆鑷繁鐨勭晫闈�
+                if (item != ShowFunction.Music && item != ShowFunction.Environmental)
                 {
-                    X = Application.GetRealWidth(16),
-                    Y = btnName.Bottom,
-                    Width = Application.GetRealWidth(120),
-                    Height = Application.GetRealHeight(24),
-                    TextColor = CSS_Color.FirstLevelTitleColor,
-                    TextSize = CSS_FontSize.TextFontSize,
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Text = "0/" + functionCount.ToString()
-                };
-                functionView.AddChidren(btnFunctionCount);
-
-
-
-
+                    btnFunctionViewBg.MouseUpEventHandler = (sender, e) =>
+                    {
+                        var skipView = new FunctionPage();
+                        MainPage.BasePageView.AddChidren(skipView);
+                        skipView.LoadPage(functionPageTitleId);
+                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                    };
+                }
+                if (item != ShowFunction.Environmental && functionCount != 0)
+                {
+                    Button btnFunctionCount = new Button()
+                    {
+                        X = Application.GetRealWidth(16) + Application.GetRealWidth(7 * functionCount.ToString().Length),
+                        Y = btnName.Bottom,
+                        Width = Application.GetRealWidth(120),
+                        Height = Application.GetRealHeight(24),
+                        TextColor = CSS_Color.PromptingColor1,
+                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                        TextAlignment = TextAlignment.CenterLeft,
+                        Text = "/" + functionCount,
+                    };
+                    functionView.AddChidren(btnFunctionCount);
+                    Button btnOpenCount = new Button()
+                    {
+                        X = Application.GetRealWidth(16),
+                        Y = btnName.Bottom,
+                        Width = Application.GetRealWidth(12 * functionCount.ToString().Length),
+                        Height = Application.GetRealHeight(24),
+                        TextColor = CSS_Color.MainColor,
+                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                        TextAlignment = TextAlignment.CenterLeft,
+                        Text = functionOnCount.ToString(),
+                        Tag = item + "_onCount",
+                        BorderWidth = 0,
+                    };
+                    functionView.AddChidren(btnOpenCount);
+                }
                 index++;
             }
 
-
+            if (functionCategoryCount > 4)
+            {
+                functionContentView.Height = Application.GetRealHeight((220 * functionCategoryCount / 2) + 20);
+                s1View.Height = s2View.Height = functionContentView.Height;
+            }
 
             #endregion
+        }
+
+        #region 鍒囨崲妤煎眰
+        /// <summary>
+        /// 妤煎眰鏄剧ず鍒囨崲
+        /// </summary>
+        void LoadDialog_ChangeFloor()
+        {
+            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
+            {
+                var dialog = new Dialog();
+                var dialogBody = new FrameLayout();
+                dialog.AddChidren(dialogBody);
+                dialogBody.MouseUpEventHandler += (sender1, e1) =>
+                {
+                    dialog.Close();
+                };
+
+                var dispalyView = new FrameLayout()
+                {
+                    X = Application.GetRealWidth(10),
+                    Y = Application.GetRealHeight(100),
+                    Width = Application.GetRealWidth(160),
+                    Height = Application.GetRealHeight(110),
+                    BackgroundImagePath = "PersonalCenter/HomeList1bg.png",
+                };
+                dialogBody.AddChidren(dispalyView);
+
+                var contentView = new VerticalScrolViewLayout()
+                {
+                    X = Application.GetRealWidth(8),
+                    Y = Application.GetRealHeight(15),
+                    Width = Application.GetRealWidth(150),
+                    Height = Application.GetRealHeight(45 * 2),
+                    ScrollEnabled = false
+                };
+                dispalyView.AddChidren(contentView);
+
+                if (DB_ResidenceData.residenceData.floors.Count < 2)
+                {
+                }
+                else if (DB_ResidenceData.residenceData.floors.Count < 3)
+                {
+                    dispalyView = new FrameLayout()
+                    {
+                        X = Application.GetRealWidth(10),
+                        Y = Application.GetRealHeight(100),
+                        Width = Application.GetRealWidth(160),
+                        Height = Application.GetRealHeight(155),
+                        BackgroundImagePath = "PersonalCenter/HomeList2bg.png",
+                    };
+                    dialogBody.AddChidren(dispalyView);
+
+                    contentView.Height = Application.GetRealHeight(45 * 3);
+                    dispalyView.AddChidren(contentView);
+                }
+                else if (DB_ResidenceData.residenceData.floors.Count < 4)
+                {
+                    dispalyView = new FrameLayout()
+                    {
+                        X = Application.GetRealWidth(10),
+                        Y = Application.GetRealHeight(100),
+                        Width = Application.GetRealWidth(160),
+                        Height = Application.GetRealHeight(200),
+                        BackgroundImagePath = "PersonalCenter/HomeList3bg.png",
+                    };
+                    dialogBody.AddChidren(dispalyView);
+
+                    contentView.Height = Application.GetRealHeight(45 * 4);
+                    dispalyView.AddChidren(contentView);
+                }
+                else
+                {
+                    dispalyView = new FrameLayout()
+                    {
+                        X = Application.GetRealWidth(10),
+                        Y = Application.GetRealHeight(100),
+                        Width = Application.GetRealWidth(160),
+                        Height = Application.GetRealHeight(245),
+                        BackgroundImagePath = "PersonalCenter/HomeList4bg.png",
+                    };
+                    dialogBody.AddChidren(dispalyView);
+
+                    contentView.Height = Application.GetRealHeight(45 * 5);
+                    contentView.ScrollEnabled = true;
+                    dispalyView.AddChidren(contentView);
+                }
+
+
+                List<string> chooseList = new List<string>();
+                chooseList.Add(Language.StringByID(StringId.All));
+                foreach (var f in DB_ResidenceData.residenceData.floors)
+                {
+                    chooseList.Add(f.name);
+                }
+
+                foreach (var floor in chooseList)
+                {
+                    if (floor != Language.StringByID(StringId.All))
+                    {
+                        contentView.AddChidren(new Button()
+                        {
+                            Gravity = Gravity.CenterHorizontal,
+                            Width = Application.GetRealWidth(112),
+                            Height = Application.GetRealHeight(1),
+                            BackgroundColor = CSS_Color.BackgroundColor
+                        });
+                    }
+                    var btnHomeName = new Button()
+                    {
+                        Gravity = Gravity.CenterHorizontal,
+                        Width = Application.GetRealWidth(112),
+                        Height = Application.GetRealHeight(44),
+                        TextAlignment = TextAlignment.CenterLeft,
+                        TextColor = CSS_Color.FirstLevelTitleColor,
+                        SelectedTextColor = CSS_Color.MainColor,
+                        Text = floor,
+                        TextSize = CSS_FontSize.SubheadingFontSize,
+                        IsSelected = btnFloor.Text == floor,
+                        IsMoreLines = true,
+                        Tag = floor
+                    };
+                    contentView.AddChidren(btnHomeName);
+
+                    btnHomeName.MouseUpEventHandler += (senderH, en) =>
+                    {
+                        dialog.Close();
+                        btnFloor.Text = floor;
+                        roomsShowed.Clear();
+                        if (floor == Language.StringByID(StringId.All))
+                        {
+                            roomsShowed.AddRange(DB_ResidenceData.rooms);
+                        }
+                        else
+                        {
+                            foreach (var room in DB_ResidenceData.rooms)
+                            {
+                                if (room.floorName == floor)
+                                {
+                                    roomsShowed.Add(room);
+                                }
+                            }
+                        }
+                        LoadRoomRows();
+                    };
+                }
+
+                dialog.Show();
+            };
+
+            btnFloor.MouseUpEventHandler = eventHandler;
+            btnFloorDownIcon.MouseUpEventHandler = eventHandler;
+        }
+
+        void LoadEvent_ChangeFloorDisplay()
+        {
 
         }
+        #endregion
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.8.0