wxr
2022-11-23 32a8370517ce75caac836edc82f62614d5f9b187
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),
            };
@@ -205,44 +243,6 @@
        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 +464,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 +473,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 +507,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 +516,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 +525,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);
                }
@@ -1166,7 +1166,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 +1191,7 @@
                TextAlignment = TextAlignment.Center,
                TextColor = color,
                TextSize = 20,
                Text = value,
                Text = value + unitString,
            };
            contentView.AddChidren(btnValue);
@@ -1206,9 +1206,9 @@
            };
            contentView.AddChidren(btnText);
            if(!string.IsNullOrEmpty(unitString))
            if(!string.IsNullOrEmpty(unitStr2))
            {
                btnText.Text += "(" + unitString + ")";
                btnText.Text += "(" + unitStr2 + ")";
            }
@@ -1220,7 +1220,7 @@
            {
                value = value.Remove(value.IndexOf('.'), value.Length - value.IndexOf('.'));
            }
            btnValue.Text = value;
            btnValue.Text = value + unitString;
        }
    }