From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:25:59 +0800
Subject: [PATCH] 2024年07月25日17:24:45

---
 HDL_ON/UI/UI2/2-Classification/FunctionPage.cs |  187 ++++++++++++++++++++++++++--------------------
 1 files changed, 104 insertions(+), 83 deletions(-)

diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
index dee3d46..c1e7d38 100644
--- a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
+++ b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
@@ -12,7 +12,7 @@
         /// <summary>
         /// 褰撳墠绐椾綋
         /// </summary>
-        static FrameLayout bodyView;
+        public static FunctionPage bodyView;
         /// <summary>
         /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣
         /// </summary>
@@ -28,15 +28,39 @@
         #endregion
 
         List<Function> functionList;
+        int titleId;
 
+        public Action DelAction;
         public FunctionPage()
         {
             bodyView = this;
             functionList = new List<Function>();
+
         }
 
-        public void LoadPage(int titleId)
+        /// <summary>
+        /// 閲嶈浇鐣岄潰
+        /// </summary>
+        public void ReLoadPage()
         {
+            if (bodyView != null)
+            {
+                try
+                {
+                    bodyView.RemoveAll();
+                    LoadPage(this.titleId);
+                    functionList = new List<Function>();
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"FunctionPage ReloadPage error :\r\n {ex.Message}");
+                }
+            }
+        }
+
+        public void LoadPage(int titleId_out)
+        {
+            this.titleId = titleId_out;
 
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
             if (titleId == StringId.Lights && !DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl)
@@ -60,50 +84,24 @@
                     skipView.LoadPage();
                     MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                 };
-                new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView_LightFunction(action);
+                var topView = new TopViewDiv(bodyView, Language.StringByID(titleId));
+                topView.maginY = 10;
+                topView.LoadTopView_LightFunction(action);
             }
             else
             {
-                new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView();
+                var topView = new TopViewDiv(bodyView, Language.StringByID(titleId));
+                topView.maginY = 10;
+                topView.LoadTopView();
             }
 
-
-
-#if DEBUG
-            //Button testBtn = new Button()
-            //{
-            //    X = Application.GetRealWidth(80),
-            //    Height = Application.GetRealHeight(64),
-            //    BackgroundColor = 0xFFFF0000
-            //};
-            //bodyView.AddChidren(testBtn);
-            //int ddd = 0;
-            //testBtn.MouseUpEventHandler = (sender, e) => {
-            //    ddd++;
-            
-            //        Function function_online = FunctionList.List.GetLightList().Find((obj) => obj.sid == "0001017DB92D2602020100010101");
-            //    if (ddd % 2 == 0)
-            //    {
-            //        function_online.online = true;
-            //    }
-            //    else
-            //    {
-            //        function_online.online = false;
-            //    }
-            //    HomePage.LoadEvent_RefreshDevcieOnline(function_online);
-            //    FunctionPage.UpdataOnline(function_online);
-            //    RoomPage.UpdataOnline(function_online);
-
-
-            //};
-#endif
 
             /// <summary>
             /// 鎴块棿鍐呭鏄剧ず鍖哄煙
             /// </summary>
             var roomFloorChangeView = new FrameLayout()
             {
-                Y = Application.GetRealHeight(64),
+                Y = Application.GetRealHeight(64+10),
                 Height = Application.GetRealHeight(52),
             };
             bodyView.AddChidren(roomFloorChangeView);
@@ -134,28 +132,19 @@
 
             functionListView = new VerticalScrolViewLayout()
             {
-                Y = Application.GetRealHeight(64 + 52),
-                Height = Application.GetRealHeight(603 - 12 - 52),
+                Y = Application.GetRealHeight(64 + 52 +10),
+                Height = Application.GetRealHeight(603 - 12 - 52-10),
             };
             bodyView.AddChidren(functionListView);
 
             if (titleId == StringId.Lights)
             {
+                //functionList.AddRange(FunctionList.List.groupControls);
                 functionList.AddRange(FunctionList.List.GetLightList());
-                functionList.AddRange(FunctionList.List.groupControls);
-
-
-                var lightScene = FunctionList.List.scenes.FindAll((obj) => obj.sceneType == SceneType.LightScene);
-
-                foreach (var scene in lightScene)
-                {
-                    functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
-
-                    var sceneRow = new SceneControlZone(scene);
-                    functionListView.AddChidren(sceneRow);
-                    sceneRow.LoadView();
-                }
-
+            }
+            else if(titleId == StringId.HorseRaceLamp)
+            {
+                functionList.AddRange(FunctionList.List.GetSeries());
             }
             else if (titleId == StringId.AC)
             {
@@ -171,7 +160,9 @@
             }
             else if (titleId == StringId.Electric)
             {
+               
                 functionList.AddRange(FunctionList.List.GetElectricals());
+
             }
             else if (titleId == StringId.EnvironmentalScience)
             {
@@ -185,13 +176,17 @@
             {
                 functionList.AddRange(FunctionList.List.GetAirFreshList());
             }
-            else if(titleId == StringId.MechanicalArm)
+            else if (titleId == StringId.MechanicalArm)
             {
                 functionList.AddRange(FunctionList.List.GetMechanicalArmList());
             }
-            else if(titleId == StringId.SecurityMonitoring)
+            else if (titleId == StringId.SecurityMonitoring)
             {
                 functionList.AddRange(FunctionList.List.GetIpCamImouList());
+            }
+            else if(titleId == StringId.EnergyMonitoring)
+            {
+                functionList.AddRange(FunctionList.List.GetEnergyList());
             }
             functionList = functionList.OrderByDescending(o => o.controlCounter).ToList();
 
@@ -200,28 +195,13 @@
             LoadDialog_ChangeFloor();
 
 
-            #region 鍔犺浇缁勫悎璋冨厜鍦烘櫙
-            if (titleId == StringId.Lights)
-            {
-                foreach (var lightScene in FunctionList.List.scenes)
-                {
-                    if (lightScene.sceneType == SceneType.LightScene)
-                        if (lightScene != null)
-                        {
-                            functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
-                            var sceneRow = new SceneControlZone(lightScene);
-                            functionListView.AddChidren(sceneRow);
-                            sceneRow.LoadView();
-                        }
-                }
-            }
-            #endregion
+        
 
         }
         /// <summary>
         /// 鏄剧ず鐨勮澶囩殑鎬绘暟
         /// </summary>
-        int showCount = 0;
+        int showCount = -1;
         /// <summary>
         /// 鍔犺浇鍔熻兘row
         /// </summary>
@@ -239,24 +219,40 @@
                     {
                         if (!isAppend)
                         {
-                            showCount = 0;
+                            showCount = -1;
                             functionListView.RemoveAll();
+                            #region 鍔犺浇缁勫悎璋冨厜鍦烘櫙
+                            if (titleId == StringId.Lights)
+                            {
+                                foreach (var lightScene in FunctionList.List.scenes)
+                                {
+                                    if (lightScene.sceneType == SceneType.LightScene)
+                                        if (lightScene != null)
+                                        {
+                                            var sceneRow = new SceneControlZone(lightScene);
+                                            functionListView.AddChidren(sceneRow);
+                                            sceneRow.LoadView();
+                                            functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
+                                        }
+                                }
+                            }
+                            #endregion
                         }
-                        int i = 0;
-                        foreach (var function in showList)
+                        for (var i = 0;i<50;i++)
+                        //foreach (var function in showList)
                         {
-                            i++;
-                            if (i > 50)
+                            showCount++;
+                            if (showCount >= showList.Count)
                             {
                                 break;
                             }
-                            showCount++;
+                            var function = showList[showCount];
 
                             if (function.spk == SPK.SensorDryContact || function.spk == SPK.SensorDryContact2)
                             {
                                 continue;
                             }
-                            if (function.spk == SPK.LightRGBW || function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
+                            if (function.spk == SPK.LightCCT || function.spk == SPK.LightRGBW || function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
                             {
                                 var functionDiv = new FunctionControlZone(function,null)
                                 {
@@ -290,9 +286,38 @@
                                 functionListView.AddChidren(functionDiv);
 
                             }
+                            else if (function.spk == SPK.ElectricalTvHisense)
+                            {
+                                Action deviceDelAction = () =>
+                                {
+                                    //鍒犻櫎璁惧鎴愬姛鍚庢洿鏂癠I
+                                    if (functionListView==null) {
+                                        return;
+                                    }
+                                    functionListView.RemoveAll();
+                                    showList.Remove(function);//鍏堢Щ闄�
+                                    ShowFunctionRow(showList,isAppend);
+                                    this.DelAction?.Invoke();
+
+                                };
+                                var functionDiv = new FunctionControlZone(function, deviceDelAction) 
+                                {
+                                    Gravity = Gravity.CenterHorizontal,
+                                    Width = Application.GetRealWidth(343),
+                                    Height = Application.GetRealHeight(96),
+                                    Radius = (uint)Application.GetMinRealAverage(12),
+                                    BorderColor = 0x00FFFFFF,
+                                    BorderWidth = 1,
+                                    BackgroundColor = CSS_Color.MainBackgroundColor,
+                                    Tag = function.spk + function.sid
+                                };
+                                functionDiv.LoadFunctionDiv();
+                                functionDiv.OrderEvent = OrderEvent;
+                                functionListView.AddChidren(functionDiv);
+                            }
                             else
                             {
-                                var functionDiv = new FunctionControlZone(function,null)
+                                var functionDiv = new FunctionControlZone(function, null)
                                 {
                                     Gravity = Gravity.CenterHorizontal,
                                     Width = Application.GetRealWidth(343),
@@ -317,12 +342,8 @@
                                 TextAlignment = TextAlignment.Center,
                                 TextSize = CSS_FontSize.SubheadingFontSize,
                                 TextColor = CSS_Color.FirstLevelTitleColor,
-                                Text = "鍔犺浇鏇村",
+                                TextID = StringId.LoadMore,
                             };
-                            if (Language.CurrentLanguage != "Chinese")
-                            {
-                                btnAppend.Text = "Load more";
-                            }
                             functionListView.AddChidren(btnAppend);
                             btnAppend.MouseUpEventHandler = (sender, e) =>
                             {

--
Gitblit v1.8.0