From 6d73bf6e816570291865674bef8bce8972e4de3f Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 01 十二月 2021 16:32:57 +0800
Subject: [PATCH] 2021-12-01-01

---
 HDL_ON/UI/UI2/FuntionControlView/FunctionBaseInfoSetPage.cs |  360 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 247 insertions(+), 113 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/FunctionBaseInfoSetPage.cs b/HDL_ON/UI/UI2/FuntionControlView/FunctionBaseInfoSetPage.cs
index af59d9a..704093f 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/FunctionBaseInfoSetPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/FunctionBaseInfoSetPage.cs
@@ -1,6 +1,8 @@
 锘縰sing System;
+using HDL_ON.DAL.Server;
 using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
+using Newtonsoft.Json.Linq;
 using Shared;
 
 namespace HDL_ON.UI
@@ -9,35 +11,62 @@
     {
         #region 鎺т欢鍒楄〃
         FrameLayout bodyView;
-
+        /// <summary>
+        /// 鍔熻兘鍚嶇О鏄剧ず鎸夐挳
+        /// </summary>
+        Button btnFunctionName;
+        /// <summary>
+        /// 鍔熻兘鍚嶇О缂栬緫鎸夐挳
+        /// </summary>
+        Button btnEditName;
+        /// <summary>
+        /// 浣嶇疆淇℃伅鏄剧ず鎸夐挳
+        /// </summary>
+        Button btnLocationValues;
+        /// <summary>
+        /// 浣嶇疆淇℃伅璺宠浆缂栬緫鎸夐挳
+        /// </summary>
+        Button btnLocationInfoRight;
 
         #endregion
 
         #region 灞�閮ㄥ彉閲�
         Function function;
+        /// <summary>
+        /// 鍚庨��鏃讹紝鍒锋柊涔嬪墠鐣岄潰鐨勬樉绀轰俊鎭�
+        /// </summary>
+        Action actionRefresh;
         #endregion
 
-        public FunctionBaseInfoSetPage(Function func)
+        public FunctionBaseInfoSetPage(Function func, Action action)
         {
             bodyView = this;
             function = func;
+            actionRefresh = action;
         }
         /// <summary>
         /// 鍔犺浇鐣岄潰
         /// </summary>
-        public void LoadPage()
+        public void LoadPage(bool locationSetting = true)
         {
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
-            new PublicAssmebly().LoadTopView(bodyView, Language.StringByID(StringId.Setting));
+            new TopViewDiv(bodyView, Language.StringByID(StringId.Setting)).LoadTopView(actionRefresh);
+
+            var contentView = new VerticalScrolViewLayout()
+            {
+                Y = Application.GetRealHeight(64),
+                Height = Application.GetRealHeight(600),
+                ScrollEnabled = false,
+            };
+            bodyView.AddChidren(contentView);
 
             #region name view
             var nameView = new FrameLayout()
             {
-                Y = Application.GetRealHeight(64),
                 Height = Application.GetRealHeight(50),
                 BackgroundColor = CSS_Color.MainBackgroundColor,
             };
-            bodyView.AddChidren(nameView);
+            contentView.AddChidren(nameView);
 
             var btnNameText = new Button()
             {
@@ -50,18 +79,18 @@
             };
             nameView.AddChidren(btnNameText);
 
-            var btnNameValues = new Button()
+            btnFunctionName = new Button()
             {
-                X = Application.GetRealWidth(186),
-                Width = Application.GetRealWidth(137),
+                X = Application.GetRealWidth(86),
+                Width = Application.GetRealWidth(237),
                 TextAlignment = TextAlignment.CenterRight,
                 TextColor = CSS_Color.PromptingColor1,
                 TextSize = CSS_FontSize.TextFontSize,
                 Text = function.name,
             };
-            nameView.AddChidren(btnNameValues);
+            nameView.AddChidren(btnFunctionName);
 
-            var btnEditName = new Button()
+            btnEditName = new Button()
             {
                 X = Application.GetRealWidth(333),
                 Gravity = Gravity.CenterVertical,
@@ -81,125 +110,108 @@
                     Height = Application.GetRealHeight(1)
                 });
 
-            btnEditName.MouseUpEventHandler += (sender, e) => {
-                //鍒涘缓鍥炶皟浜嬩欢
-                Action<string> callBackAction = (name) =>
+            #endregion
+            if (locationSetting)
+            {
+                #region 浣嶇疆绠$悊
+                var locationMagtView = new FrameLayout()
                 {
-                    function.name = name;
-                    DB_ResidenceData.residenceData.SaveResidenceData();
+                    Height = Application.GetRealHeight(55),
+                    BackgroundColor = CSS_Color.MainBackgroundColor,
                 };
-                new PublicAssmebly().LoadDialog_EditParater(StringId.ChangeName, function.name, callBackAction);
-            };
+                contentView.AddChidren(locationMagtView);
 
-
-            #endregion
-
-            #region 浣嶇疆绠$悊
-            var locationMagtView = new FrameLayout()
-            {
-                Y = nameView.Bottom,
-                Height = Application.GetRealHeight(55),
-                BackgroundColor = CSS_Color.MainBackgroundColor,
-            };
-            bodyView.AddChidren(locationMagtView);
-
-            var btnLocationMagtText = 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(btnLocationMagtText);
-
-            var btnLocationValues = new Button()
-            {
-                X = Application.GetRealWidth(186),
-                Width = Application.GetRealWidth(137),
-                TextAlignment = TextAlignment.CenterRight,
-                TextColor = CSS_Color.PromptingColor1,
-                TextSize = CSS_FontSize.TextFontSize,
-                Text = function.GetRoomListName(),
-            };
-            locationMagtView.AddChidren(btnLocationValues);
-
-            var btnLocationMagtRight = new Button()
-            {
-                X = Application.GetRealWidth(339),
-                Gravity = Gravity.CenterVertical,
-                Width = Application.GetMinRealAverage(16),
-                Height = Application.GetMinRealAverage(16),
-                UnSelectedImagePath = "Public/RightIcon.png",
-            };
-            locationMagtView.AddChidren(btnLocationMagtRight);
-
-            locationMagtView.AddChidren(
-                new Button()
+                var btnLocationMagtTitle = new Button()
                 {
-                    Gravity = Gravity.CenterHorizontal,
-                    Y = Application.GetRealHeight(54),
-                    BackgroundColor = CSS_Color.DividingLineColor,
-                    Width = Application.GetRealWidth(343),
-                    Height = Application.GetRealHeight(1)
-                });
-            btnLocationMagtRight.MouseUpEventHandler += (sender, e) =>
-            {
-                SkipChooseRoomPage();
-            };
-            #endregion
+                    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()
-            {
-                Y = locationMagtView.Bottom,
-                Height = Application.GetRealHeight(55),
-                BackgroundColor = CSS_Color.MainBackgroundColor,
-            };
-            bodyView.AddChidren(sharedView);
+            //var sharedView = new FrameLayout()
+            //{
+            //    Height = Application.GetRealHeight(55),
+            //    BackgroundColor = CSS_Color.MainBackgroundColor,
+            //};
+            //contentView.AddChidren(sharedView);
 
-            var btnSharedText = new Button()
-            {
-                X = Application.GetRealWidth(16),
-                Width = Application.GetRealWidth(160),
-                TextAlignment = TextAlignment.CenterLeft,
-                TextColor = CSS_Color.FirstLevelTitleColor,
-                TextSize = CSS_FontSize.SubheadingFontSize,
-                TextID = StringId.Shared,
-            };
-            sharedView.AddChidren(btnSharedText);
+            //var btnSharedText = new Button()
+            //{
+            //    X = Application.GetRealWidth(16),
+            //    Width = Application.GetRealWidth(160),
+            //    TextAlignment = TextAlignment.CenterLeft,
+            //    TextColor = CSS_Color.FirstLevelTitleColor,
+            //    TextSize = CSS_FontSize.SubheadingFontSize,
+            //    TextID = StringId.Shared,
+            //};
+            //sharedView.AddChidren(btnSharedText);
 
-            var btnSharedRight = new Button()
-            {
-                X = Application.GetRealWidth(339),
-                Gravity = Gravity.CenterVertical,
-                Width = Application.GetMinRealAverage(16),
-                Height = Application.GetMinRealAverage(16),
-                UnSelectedImagePath = "Public/RightIcon.png",
-            };
-            sharedView.AddChidren(btnSharedRight);
+            //var btnSharedRight = new Button()
+            //{
+            //    X = Application.GetRealWidth(339),
+            //    Gravity = Gravity.CenterVertical,
+            //    Width = Application.GetMinRealAverage(16),
+            //    Height = Application.GetMinRealAverage(16),
+            //    UnSelectedImagePath = "Public/RightIcon.png",
+            //};
+            //sharedView.AddChidren(btnSharedRight);
 
-            sharedView.AddChidren(
-                new Button()
-                {
-                    Gravity = Gravity.CenterHorizontal,
-                    Y = Application.GetRealHeight(54),
-                    BackgroundColor = CSS_Color.DividingLineColor,
-                    Width = Application.GetRealWidth(343),
-                    Height = Application.GetRealHeight(1)
-                });
-
+            //sharedView.AddChidren(
+            //    new Button()
+            //    {
+            //        Gravity = Gravity.CenterHorizontal,
+            //        Y = Application.GetRealHeight(54),
+            //        BackgroundColor = CSS_Color.DividingLineColor,
+            //        Width = Application.GetRealWidth(343),
+            //        Height = Application.GetRealHeight(1)
+            //    });
             #endregion
 
+#if stage2
             #region 娣诲姞鍒版闈�
             var addToDesktopView = new FrameLayout()
             {
-                Y = sharedView.Bottom,
                 Height = Application.GetRealHeight(55),
                 BackgroundColor = CSS_Color.MainBackgroundColor,
             };
-            bodyView.AddChidren(addToDesktopView);
+            contentView.AddChidren(addToDesktopView);
 
             var btnAddToDesktopText = new Button()
             {
@@ -223,8 +235,130 @@
             addToDesktopView.AddChidren(btnAddToDesktopRight);
 
             #endregion
+#endif
+
+            if (function.spk == SPK.ElectricEnergy)
+            {
+                #region 鑳芥簮鏁版嵁
+                var energyView1 = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(55),
+                    BackgroundColor = CSS_Color.MainBackgroundColor,
+                };
+                contentView.AddChidren(energyView1);
+
+                var btnEnergyText1 = new Button()
+                {
+                    X = Application.GetRealWidth(16),
+                    Width = Application.GetRealWidth(160),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextColor = CSS_Color.FirstLevelTitleColor,
+                    TextSize = CSS_FontSize.SubheadingFontSize,
+                    TextID = StringId.RealTimeEnergyConsumption,
+                };
+                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 = realTimePower + "kW",
+                };
+                energyView1.AddChidren(energyValue1);
+
+                energyView1.AddChidren(
+                    new Button()
+                    {
+                        Gravity = Gravity.CenterHorizontal,
+                        Y = Application.GetRealHeight(54),
+                        BackgroundColor = CSS_Color.DividingLineColor,
+                        Width = Application.GetRealWidth(343),
+                        Height = Application.GetRealHeight(1)
+                    });
+                //-----------------
+
+                var energyView2 = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(55),
+                    BackgroundColor = CSS_Color.MainBackgroundColor,
+                };
+                contentView.AddChidren(energyView2);
+
+                var btnEnergyText2 = new Button()
+                {
+                    X = Application.GetRealWidth(16),
+                    Width = Application.GetRealWidth(160),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextColor = CSS_Color.FirstLevelTitleColor,
+                    TextSize = CSS_FontSize.SubheadingFontSize,
+                    TextID = StringId.EnergyConsumptionOfThisMonth,
+                };
+                energyView2.AddChidren(btnEnergyText2);
+
+                var btnEnergyValue2 = new Button()
+                {
+                    Width = Application.GetRealWidth(355),
+                    TextAlignment = TextAlignment.CenterRight,
+                    TextSize = CSS_FontSize.TextFontSize,
+                    TextColor = CSS_Color.PromptingColor1,
+                    Text = "--kW",
+                };
+                energyView2.AddChidren(btnEnergyValue2);
+
+                energyView2.AddChidren(
+                    new Button()
+                    {
+                        Gravity = Gravity.CenterHorizontal,
+                        Y = Application.GetRealHeight(54),
+                        BackgroundColor = CSS_Color.DividingLineColor,
+                        Width = Application.GetRealWidth(343),
+                        Height = Application.GetRealHeight(1)
+                    });
+
+                new System.Threading.Thread(() =>
+                {
+                    var pm = new HttpServerRequest();
+                    var data = pm.GetLastMonthHistory(function.deviceId, FunctionAttributeKey.TotalElectricity);
+                    if (data != null)
+                    {
+                        if (data.Code == StateCode.SUCCESS)
+                        {
+                            var dataPack = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(data.Data.ToString());
+                            if (dataPack != null)
+                            {
+                                try
+                                {
+                                    var dataValue = dataPack.GetValue("monthDiff").ToString();
+                                    if (!string.IsNullOrEmpty(dataValue))
+                                    {
+                                        Application.RunOnMainThread(() =>
+                                        {
+                                            btnEnergyValue2.Text = dataValue + "kW鈥";
+                                        });
+                                    }
+                                }
+                                catch
+                                {
+
+                                }
+                            }
+                        }
+                    }
+
+                })
+                { IsBackground = true }.Start();
+
+                #endregion
+            }
+
+            LoadEventList();
         }
 
 

--
Gitblit v1.8.0