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/FuntionControlView/Acst/AcstParentPage.cs |  142 +++++++++++++++++++++++++----------------------
 1 files changed, 76 insertions(+), 66 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs
index 0887152..97c577b 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs
@@ -18,6 +18,7 @@
 
         VerticalScrolViewLayout contentView;
 
+        string helloText = "涓婂崍濂�";
 
         #region 澶╂皵鎺т欢
         Button btnOutdoorTemp;
@@ -65,8 +66,45 @@
         public AcstParentPage()
         {
             basePage = this;
+            var curTime = DateTime.Now;
+            if (Language.CurrentLanguage != "Chinese")
+            {
+                helloText = "Good morning";
+            }
+            if (curTime.Hour >= 8 && curTime.Hour < 12)
+            {
+                helloText = "涓婂崍濂�";
+                if (Language.CurrentLanguage != "Chinese")
+                {
+                    helloText = "Good morning";
+                }
+                curColor = CSS.CSS_Color.MainColor;
+                imageFolder = "blue";
+            }
+            else if (curTime.Hour >= 12 && curTime.Hour < 18)
+            {
+                helloText = "涓嬪崍濂�";
+                if (Language.CurrentLanguage != "Chinese")
+                {
+                    helloText = "Good afternoon";
+                }
+                curColor = 0xFFE7914F;
+                imageFolder = "orange";
+            }
+            else
+            {
+                helloText = "鏅氫笂濂�";
+                if (Language.CurrentLanguage != "Chinese")
+                {
+                    helloText = "Good evening";
+                }
+
+                curColor = 0xFF9175F3;
+                imageFolder = "purple";
+            }
             this.function = FunctionList.List.GetAcstParentList()[0];
             this.BackgroundColor = CSS.CSS_Color.BackgroundColor;
+            //this.AddChidren(new Button() { Height = Application.GetRealHeight(50), BackgroundColor = curColor });
             contentView = new VerticalScrolViewLayout() {
                 Height = Application.GetRealHeight(667 - 56),
             };
@@ -188,61 +226,30 @@
                 }
                 Application.RunOnMainThread(() =>
                 {
-                    var view = basePage.subViewList[temp.sid];
-                    if (view != null)
+                    try
                     {
-                        view.btnSubHumidityValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%";
-                        view.btnSubTempValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "掳";
-                        view.btnSubPower.IsSelected = temp.GetAttrState(AcstSub_AttrEnum.on_off.ToString()) == "on";
+                        AcstSubControlView view = null;
+                        basePage.subViewList.TryGetValue(temp.sid, out view);
+                        if (view != null)
+                        {
+                            view.btnSubHumidityValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%";
+                            view.btnSubTempValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "掳";
+                            view.btnSubPower.IsSelected = temp.GetAttrState(AcstSub_AttrEnum.on_off.ToString()) == "on";
+                        }
+                    }
+                    catch (Exception ex ) {
+                        MainPage.Log($"绉戞妧绯荤粺鏇存柊寮傚父1:{ex.Message}");
                     }
                 });
             }
             catch (Exception ex)
             {
-                MainPage.Log("绉戞妧绯荤粺鏇存柊寮傚父11");
+                MainPage.Log($"绉戞妧绯荤粺鏇存柊寮傚父123:{ex.Message}");
             }
         }
 
         public void LoadPage()
         {
-            var curTime = DateTime.Now;
-            string helloText = "涓婂崍濂�"; 
-            if (Language.CurrentLanguage != "Chinese")
-            {
-                helloText = "Good morning";
-            }
-            if (curTime.Hour >= 8 && curTime.Hour < 12)
-            {
-                helloText = "涓婂崍濂�";
-                if (Language.CurrentLanguage != "Chinese")
-                {
-                    helloText = "Good morning";
-                }
-                curColor = CSS.CSS_Color.MainColor;
-                imageFolder = "blue";
-            }
-            else if (curTime.Hour >= 12 && curTime.Hour < 18)
-            {
-                helloText = "涓嬪崍濂�";
-                if (Language.CurrentLanguage != "Chinese")
-                {
-                    helloText = "Good afternoon";
-                }
-                curColor = 0xFFE7914F;
-                imageFolder = "orange";
-            }
-            else
-            {
-                helloText = "鏅氫笂濂�";
-                if (Language.CurrentLanguage != "Chinese")
-                {
-                    helloText = "Good evening";
-                }
-                
-                curColor = 0xFF9175F3;
-                imageFolder = "purple";
-            }
-
             #region 澶撮儴淇℃伅鍖哄煙
             FrameLayout topView = new FrameLayout()
             {
@@ -464,7 +471,7 @@
                     {
                         tempValues = tempValues.Remove(tempValues.IndexOf('.'), tempValues.Length - tempValues.IndexOf('.'));
                     }
-                    sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempValues, "掳", Language.StringByID(StringId.Temp));
+                    sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempValues, "掳","", Language.StringByID(StringId.Temp));
                 }
                 if (humiObj != null)
                 {
@@ -473,19 +480,19 @@
                     {
                         humiValues = humiValues.Remove(humiValues.IndexOf('.'), humiValues.Length - humiValues.IndexOf('.'));
                     }
-                    sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiValues , "%", Language.StringByID(StringId.Humidity));
+                    sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiValues , "%", "", Language.StringByID(StringId.Humidity));
                 }
                 if (pm25Obj != null)
                 {
-                    sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.state == "" ? "--" : pm25Obj.state, "", "PM2.5");
+                    sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.state == "" ? "--" : pm25Obj.state, "", "", "PM2.5");
                 }
                 if (co2Obj != null)
                 {
-                    sensorDiyView_Co2 = new SensorDiyView(sensorListView, curColor, co2Obj.state == "" ? "--" : co2Obj.state, "", "CO2");
+                    sensorDiyView_Co2 = new SensorDiyView(sensorListView, curColor, co2Obj.state == "" ? "--" : co2Obj.state, "", "", "CO2");
                 }
                 if (tvocObj != null)
                 {
-                    sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.state == "" ? "--" : tvocObj.state, "", "TVOC");
+                    sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.state == "" ? "--" : tvocObj.state, "", "", "TVOC");
                 }
                 #endregion
 
@@ -507,7 +514,7 @@
                     {
                         text = "Power";
                     }
-                    sensorDiyView_EleActivePower = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state, "KW", text, 100);
+                    sensorDiyView_EleActivePower = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state, "", "KW", text, 100);
                 }
                 if (dayObj != null)
                 {
@@ -516,7 +523,7 @@
                     {
                         text = "Power of today";
                     }
-                    sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.state == "" ? "--" : dayObj.state, "KWh", text, 100);
+                    sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.state == "" ? "--" : dayObj.state, "", "KWh", text, 100);
                 }
                 if (monthObj != null)
                 {
@@ -525,7 +532,7 @@
                     {
                         text = "Power of month";
                     }
-                    sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.state == "" ? "--" : monthObj.state, "KWh", text, 100);
+                    sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.state == "" ? "--" : monthObj.state, "", "KWh", text, 100);
                 }
 
 
@@ -590,7 +597,7 @@
             var btnTitleText2 = new Button()
             {
                 X = btnCollection.Right,
-                Text = "鎴戠殑瀹跺涵",
+                TextID = StringId.MyHome,
                 TextSize = 16,
                 TextColor = 0xFF242424,
                 TextAlignment = TextAlignment.CenterLeft,
@@ -598,10 +605,6 @@
                 Height = Application.GetRealHeight(54),
             };
             subTitleView.AddChidren(btnTitleText2);
-            if(Language.CurrentLanguage != "Chinese")
-            {
-                btnTitleText2.Text = "My Home";
-            }
 
             int subFunctionCount = 0;
 
@@ -617,6 +620,10 @@
             {
                 try
                 {
+#if DEBUG
+                    System.Threading.Thread.Sleep(200);
+#endif
+
                     foreach (var sub in FunctionList.List.GetAcstSubList())
                     {
                         if (subViewList.ContainsKey(sub.sid))
@@ -638,11 +645,14 @@
 
                             AcstSubControlView subFunctionView = new AcstSubControlView(sub, subFunctionListView, imageFolder);
                             subViewList.Add(sub.sid, subFunctionView);
-                            new System.Threading.Thread(() =>
+                            if (basePage != null)
                             {
-                                Control.Ins.SendReadCommand(sub);
-                            })
-                            { IsBackground = true }.Start();
+                                new System.Threading.Thread(() =>
+                                {
+                                    Control.Ins.SendReadCommand(sub);
+                                })
+                                { IsBackground = true }.Start();
+                            }
                         subFunctionCount++;
                         });
 
@@ -1166,7 +1176,7 @@
         public string Tag;
         public string unitString;
 
-        public SensorDiyView(HorizontalScrolViewLayout view,uint color,string value,string unitStr,string text,int setWidth = 60)
+        public SensorDiyView(HorizontalScrolViewLayout view,uint color,string value,string unitStr, string unitStr2, string text,int setWidth = 60)
         {
             unitString = unitStr;
             if (string.IsNullOrEmpty(value))
@@ -1191,7 +1201,7 @@
                 TextAlignment = TextAlignment.Center,
                 TextColor = color,
                 TextSize = 20,
-                Text = value,
+                Text = value + unitString,
             };
             contentView.AddChidren(btnValue);
 
@@ -1206,9 +1216,9 @@
             };
             contentView.AddChidren(btnText);
 
-            if(!string.IsNullOrEmpty(unitString))
+            if(!string.IsNullOrEmpty(unitStr2))
             {
-                btnText.Text += "(" + unitString + ")";
+                btnText.Text += "(" + unitStr2 + ")";
             }
 
 
@@ -1220,7 +1230,7 @@
             {
                 value = value.Remove(value.IndexOf('.'), value.Length - value.IndexOf('.'));
             }
-            btnValue.Text = value;
+            btnValue.Text = value + unitString;
         }
     }
 

--
Gitblit v1.8.0