xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
HDL_ON/UI/UI2/FuntionControlView/FunctionBaseInfoSetPage.cs
@@ -47,7 +47,7 @@
        /// <summary>
        /// 加载界面
        /// </summary>
        public void LoadPage()
        public void LoadPage(bool locationSetting = true)
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, Language.StringByID(StringId.Setting)).LoadTopView(actionRefresh);
@@ -111,58 +111,59 @@
                });
            #endregion
            #region 位置管理
            var locationMagtView = new FrameLayout()
            if (locationSetting)
            {
                Height = Application.GetRealHeight(55),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            contentView.AddChidren(locationMagtView);
            var btnLocationMagtTitle = new Button()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(160),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.LocationManagement,
            };
            locationMagtView.AddChidren(btnLocationMagtTitle);
            btnLocationValues = new Button()
            {
                X = Application.GetRealWidth(86),
                Width = Application.GetRealWidth(237),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.TextFontSize,
                Text = function.GetRoomListName(),
            };
            locationMagtView.AddChidren(btnLocationValues);
            btnLocationInfoRight = new Button()
            {
                X = Application.GetRealWidth(339),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                UnSelectedImagePath = "Public/RightIcon.png",
            };
            locationMagtView.AddChidren(btnLocationInfoRight);
            locationMagtView.AddChidren(
                new Button()
                #region 位置管理
                var locationMagtView = new FrameLayout()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Y = Application.GetRealHeight(54),
                    BackgroundColor = CSS_Color.DividingLineColor,
                    Width = Application.GetRealWidth(343),
                    Height = Application.GetRealHeight(1)
                });
            #endregion
                    Height = Application.GetRealHeight(55),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                };
                contentView.AddChidren(locationMagtView);
                var btnLocationMagtTitle = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Width = Application.GetRealWidth(160),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.SubheadingFontSize,
                    TextID = StringId.LocationManagement,
                };
                locationMagtView.AddChidren(btnLocationMagtTitle);
                btnLocationValues = new Button()
                {
                    X = Application.GetRealWidth(86),
                    Width = Application.GetRealWidth(237),
                    TextAlignment = TextAlignment.CenterRight,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.TextFontSize,
                    Text = function.GetRoomListName(),
                };
                locationMagtView.AddChidren(btnLocationValues);
                btnLocationInfoRight = new Button()
                {
                    X = Application.GetRealWidth(339),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetMinRealAverage(16),
                    Height = Application.GetMinRealAverage(16),
                    UnSelectedImagePath = "Public/RightIcon.png",
                };
                locationMagtView.AddChidren(btnLocationInfoRight);
                locationMagtView.AddChidren(
                    new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Y = Application.GetRealHeight(54),
                        BackgroundColor = CSS_Color.DividingLineColor,
                        Width = Application.GetRealWidth(343),
                        Height = Application.GetRealHeight(1)
                    });
                #endregion
            }
            #region 共享
            //var sharedView = new FrameLayout()
            //{
@@ -257,13 +258,18 @@
                };
                energyView1.AddChidren(btnEnergyText1);
                double realTimePower = 0;
                double.TryParse(function.GetAttrState(FunctionAttributeKey.Power), out realTimePower);
                realTimePower /= 1000;
                var energyValue1 = new Button()
                {
                    Width = Application.GetRealWidth(355),
                    TextAlignment = TextAlignment.CenterRight,
                    TextSize = CSS_FontSize.TextFontSize,
                    TextColor = CSS_Color.PromptingColor1,
                    Text = function.GetAttrState(FunctionAttributeKey.Power) + "kW",
                    Text = realTimePower + "kW",
                };
                energyView1.AddChidren(energyValue1);
@@ -296,7 +302,7 @@
                };
                energyView2.AddChidren(btnEnergyText2);
                var energyValue2 = new Button()
                var btnEnergyValue2 = new Button()
                {
                    Width = Application.GetRealWidth(355),
                    TextAlignment = TextAlignment.CenterRight,
@@ -304,7 +310,7 @@
                    TextColor = CSS_Color.PromptingColor1,
                    Text = "--kW",
                };
                energyView2.AddChidren(energyValue2);
                energyView2.AddChidren(btnEnergyValue2);
                energyView2.AddChidren(
                    new Button()
@@ -316,26 +322,38 @@
                        Height = Application.GetRealHeight(1)
                    });
                new System.Threading.Thread(() => {
                    var pm = new DAL.Server.HttpServerRequest();
                    var data = pm.GetLastMonthHistory(function.deviceId,FunctionAttributeKey.TotalElectricity);
                    if(data!= null)
                new System.Threading.Thread(() =>
                {
                    var pm = new HttpServerRequest();
                    var data = pm.GetLastMonthHistory(function.deviceId, FunctionAttributeKey.TotalElectricity);
                    if (data != null)
                    {
                        if(data.Code == StateCode.SUCCESS)
                        if (data.Code == StateCode.SUCCESS)
                        {
                            var dataPack = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(data.Data.ToString());
                            if(dataPack!=null)
                            if (dataPack != null)
                            {
                                var dataValue = dataPack.GetValue("property").ToString();
                                if(!string.IsNullOrEmpty(dataValue))
                                try
                                {
                                    btnEnergyText2.Text = dataValue + "kW";
                                    var dataValue = dataPack.GetValue("monthDiff").ToString();
                                    if (!string.IsNullOrEmpty(dataValue))
                                    {
                                        Application.RunOnMainThread(() =>
                                        {
                                            btnEnergyValue2.Text = dataValue + "kW‧h";
                                        });
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }) { IsBackground = true }.Start();
                })
                { IsBackground = true }.Start();
                #endregion
            }