From 203c3a3ffde6259413d9743f6a723b95b1e7989c Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 06 七月 2023 22:43:05 +0800
Subject: [PATCH] 门锁功能

---
 HDL_ON/UI/UI2/2-Classification/FunctionPage.cs |  116 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 73 insertions(+), 43 deletions(-)

diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
index 5ba2bed..785a7fd 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,18 +28,41 @@
         #endregion
 
         List<Function> functionList;
+        int titleId;
 
         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)
+            if (titleId == StringId.Lights && !DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl)
             {
                 Action action = () =>
                 {
@@ -141,17 +164,11 @@
 
             if (titleId == StringId.Lights)
             {
+                functionList.AddRange(FunctionList.List.groupControls);
                 functionList.AddRange(FunctionList.List.GetLightList());
-                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.AC)
@@ -197,28 +214,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>
@@ -236,18 +238,34 @@
                     {
                         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)
                             {
@@ -255,7 +273,7 @@
                             }
                             if (function.spk == SPK.LightRGBW || function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
                             {
-                                var functionDiv = new FunctionControlZone(function)
+                                var functionDiv = new FunctionControlZone(function,null)
                                 {
                                     Gravity = Gravity.CenterHorizontal,
                                     Width = Application.GetRealWidth(343),
@@ -267,11 +285,12 @@
                                     Tag = function.spk + function.sid
                                 };
                                 functionDiv.LoadFunctionDiv();
+                                functionDiv.OrderEvent = OrderEvent;
                                 functionListView.AddChidren(functionDiv);
                             }
                             else if (function.spk == SPK.IpCam_Imou)
                             {
-                                var functionDiv = new FunctionControlZone(function)
+                                var functionDiv = new FunctionControlZone(function,null)
                                 {
                                     Gravity = Gravity.CenterHorizontal,
                                     Width = Application.GetRealWidth(343),
@@ -288,7 +307,7 @@
                             }
                             else
                             {
-                                var functionDiv = new FunctionControlZone(function)
+                                var functionDiv = new FunctionControlZone(function,null)
                                 {
                                     Gravity = Gravity.CenterHorizontal,
                                     Width = Application.GetRealWidth(343),
@@ -300,6 +319,7 @@
                                     Tag = function.spk + function.sid
                                 };
                                 functionDiv.LoadFunctionDiv();
+                                functionDiv.OrderEvent = OrderEvent;
                                 functionListView.AddChidren(functionDiv);
                             }
                             functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) });
@@ -312,12 +332,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) =>
                             {
@@ -346,7 +362,21 @@
             })
             { IsBackground = true }.Start();
         }
-
+        /// <summary>
+        /// 鎺掑簭浜嬩欢
+        /// </summary>
+        void OrderEvent()
+        {
+            Action action = () =>
+            {
+                functionList = functionList.OrderBy(o => o.FunctionOrderNumber).ToList();
+                ShowFunctionRow(functionList);
+            };
+            var skipView = new OrderFunctionPage();
+            MainPage.BasePageView.AddChidren(skipView);
+            skipView.LoadPage(functionList, action);
+            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+        }
 
         ///// <summary>
         ///// 鍔犺浇鍔熻兘绫诲瀷鎺у埗鍗$墖

--
Gitblit v1.8.0