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/FunctionPage.cs |  272 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 206 insertions(+), 66 deletions(-)

diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
index 96da5d9..cf4713b 100644
--- a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
+++ b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
@@ -1,5 +1,6 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.Linq;
 using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
 using Shared;
@@ -13,14 +14,25 @@
         /// </summary>
         static FrameLayout bodyView;
         /// <summary>
+        /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣
+        /// </summary>
+        Button btnFloorDownIcon;
+        /// <summary>
+        /// 妤煎眰鏄剧ず
+        /// </summary>
+        Button btnFloor;
+        /// <summary>
         /// 鍔熻兘鍒楄〃闆嗗悎鏄剧ず鍖哄煙
         /// </summary>
         static VerticalScrolViewLayout functionListView;
         #endregion
 
+        List<Function> functionList;
+
         public FunctionPage()
         {
             bodyView = this;
+            functionList = new List<Function>();
         }
 
         public void LoadPage(int titleId)
@@ -38,10 +50,7 @@
             };
             bodyView.AddChidren(roomFloorChangeView);
             #region 鎴块棿椤堕儴鍒囨崲鏄剧ず鍖哄煙
-            /// <summary>
-            /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣
-            /// </summary>
-            var btnFoorDownIcon = new Button()
+            btnFloorDownIcon = new Button()
             {
                 Width = Application.GetMinRealAverage(16),
                 Height = Application.GetMinRealAverage(16),
@@ -49,22 +58,20 @@
                 Y = Application.GetRealHeight(18),
                 UnSelectedImagePath = "Public/DownIcon.png",
             };
-            roomFloorChangeView.AddChidren(btnFoorDownIcon);
-            /// <summary>
-            /// 妤煎眰鏄剧ず
-            /// </summary>
-            var btnFoor = new Button()
+            roomFloorChangeView.AddChidren(btnFloorDownIcon);
+           
+            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 = OnAppConfig.Instance.CurFoor,
+                Text = DB_ResidenceData.residenceData.CurFoor,
             };
-            roomFloorChangeView.AddChidren(btnFoor);
+            roomFloorChangeView.AddChidren(btnFloor);
             #endregion
 
             functionListView = new VerticalScrolViewLayout()
@@ -74,60 +81,46 @@
             };
             bodyView.AddChidren(functionListView);
 
-            foreach (var function in DB_ResidenceData.residenceData.functionList.functions)
+            if (titleId == StringId.Lights)
             {
-                if (titleId == StringId.Lights)
-                {
-                    if (function.functionCategory != FunctionCategory.Light)
-                    {
-                        continue;
-                    }
-                }
-                if (titleId == StringId.AC)
-                {
-                    if (function.functionType != FunctionType.AC)
-                    {
-                        continue;
-                    }
-                }
-                if (titleId == StringId.Curtain)
-                {
-                    if (function.functionCategory != FunctionCategory.Curtain)
-                    {
-                        continue;
-                    }
-                }
-                if(titleId == StringId.FloorHeating)
-                {
-                    if(function.functionType != FunctionType.FloorHeating )
-                    {
-                        continue;
-                    }
-                }
-                if(titleId == StringId.Electric)
-                {
-                    if(function.functionType != FunctionType.Socket &&
-                        function.functionType != FunctionType.TV &&
-                        function.functionType != FunctionType.Fan)
-                    {
-                        continue;
-                    }
-                }
-                if (titleId == StringId.EnvironmentalScience)
-                {
+                functionList.AddRange(DB_ResidenceData.functionList.lights);
+            }
+            else if (titleId == StringId.AC)
+            {
+                functionList.AddRange(DB_ResidenceData.functionList.aCs);
+            }
+            else if (titleId == StringId.Curtain)
+            {
+                functionList.AddRange(DB_ResidenceData.functionList.curtains);
+            }
+            else if (titleId == StringId.FloorHeating)
+            {
+                functionList.AddRange(DB_ResidenceData.functionList.floorHeatings);
+            }
+            else if (titleId == StringId.Electric)
+            {
+                functionList.AddRange(DB_ResidenceData.functionList.electricals);
+            }
+            else if (titleId == StringId.EnvironmentalScience)
+            {
+                functionList.AddRange(DB_ResidenceData.functionList.sensorsEnvironmentalScience);
+            }
+            functionList.OrderByDescending(o => o.usageCount).ToList();
 
-                    if (function.functionType != FunctionType.PM10 ||
-                    function.functionType != FunctionType.PM25 ||
-                    //function.functionType != FunctionType.Noise ||
-                    function.functionType != FunctionType.WindPower ||
-                    function.functionType != FunctionType.CO2 ||
-                    function.functionType != FunctionType.Temp ||
-                    function.functionType != FunctionType.TVOC ||
-                    function.functionType != FunctionType.Humidity)
-                    {
-                        continue;
-                    }
-                }
+            ShowFunctionRow(functionList);
+
+            LoadDialog_ChangeFloor();
+        }
+
+        /// <summary>
+        /// 鍔犺浇鍔熻兘row
+        /// </summary>
+        void ShowFunctionRow(List<Function> showList)
+        {
+            functionListView.RemoveAll();
+            foreach (var function in showList)
+            {
+
                 if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer)
                 {
                     var functionDiv = new FunctionControlZone(function)
@@ -139,7 +132,7 @@
                         BorderColor = 0x00FFFFFF,
                         BorderWidth = 1,
                         BackgroundColor = CSS_Color.MainBackgroundColor,
-                        Tag = function.functionCategory.ToString() + "-" + function.functionType
+                        Tag = function.sid
                     };
                     functionDiv.LoadFunctionDiv();
                     functionListView.AddChidren(functionDiv);
@@ -155,14 +148,161 @@
                         BorderColor = 0x00FFFFFF,
                         BorderWidth = 1,
                         BackgroundColor = CSS_Color.MainBackgroundColor,
-                        Tag = function.functionCategory.ToString() + "-" + function.functionType
+                        Tag = function.sid
                     };
                     functionDiv.LoadFunctionDiv();
                     functionListView.AddChidren(functionDiv);
                 }
                 functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) });
             }
+        }
 
+
+        /// <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.rooms.Count < 2)
+                {
+                }
+                else if (DB_ResidenceData.rooms.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.rooms.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<Room> roomList = new List<Room>();
+                roomList.Add(new Room() { sid = "", name = Language.StringByID(StringId.All) });
+                roomList.AddRange(DB_ResidenceData.rooms);
+                foreach (var tempRoom in roomList)
+                {
+                    var roomName = tempRoom.name;
+                    if (roomName != 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 = roomName,
+                        TextSize = CSS_FontSize.SubheadingFontSize,
+                        IsSelected = btnFloor.Text == roomName,
+                        IsMoreLines = true,
+                    };
+                    contentView.AddChidren(btnHomeName);
+
+                    btnHomeName.MouseUpEventHandler += (senderH, en) =>
+                    {
+                        dialog.Close();
+                        btnFloor.Text = roomName;
+                        if (roomName == Language.StringByID(StringId.All))
+                        {
+                            ShowFunctionRow(functionList);
+                        }
+                        else
+                        {
+                            var showList = new List<Function>();
+                            foreach (var sf in functionList)
+                            {
+                                if(sf.roomIdList.Contains(tempRoom.sid))
+                                {
+                                    showList.Add(sf);
+                                }
+                            }
+                            ShowFunctionRow(showList);
+                        }
+                    };
+                }
+
+                dialog.Show();
+            };
+
+            btnFloor.MouseUpEventHandler = eventHandler;
+            btnFloorDownIcon.MouseUpEventHandler = eventHandler;
         }
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0