From 1d25d355cb0efc9685a8ad5c870b5941b95ce9b8 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 30 三月 2021 09:11:57 +0800
Subject: [PATCH] 1

---
 HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs |  398 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 387 insertions(+), 11 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs
index fcff06d..560fb7a 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs
@@ -1,5 +1,7 @@
 锘縰sing System;
 using System.Collections.Generic;
+using HDL_ON.DAL.Server;
+using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
 using Shared;
 namespace HDL_ON.UI
@@ -7,26 +9,44 @@
     public class EnergyMainPage : FrameLayout
     {
         FrameLayout bodyView;
+
+        List<uint> colorList = new List<uint>(){0xFF80AEFF, 0xFFFFD154, 0xFFFF9D54, 0xFFFE6A6A, 0xFFB183C3, 0xFFADE764,
+                                        0xFFD7504B, 0xFFC6E579, 0xFFF4E001, 0xFFF0805A, 0xFF26C0C0};
+        List<string> colorList2 = new List<string>() {
+                                        "#80AEFF", "#FFD154", "#FF9D54", "#FE6A6A", "#B183C3", "#ADE764",
+                                        "#D7504B", "#C6E579", "#F4E001", "#F0805A", "#26C0C0"};
+                                        
         public EnergyMainPage()
         {
             bodyView = this;
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
         public void LoadPage()
         {
             new TopViewDiv(bodyView, Language.StringByID(StringId.EnergyMonitoring)).LoadTopView();
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
+            var contentView = new VerticalScrolViewLayout()
+            {
+                Y = Application.GetRealHeight(64),
+                Height = Application.GetRealHeight(603),
+            };
+            bodyView.AddChidren(contentView);
+
+            #region 椤堕儴view
             var generalTableView = new FrameLayout()
             {
                 Gravity = Gravity.CenterHorizontal,
-                Y = Application.GetRealHeight(80),
+                Y = Application.GetRealHeight(16),
                 Width = Application.GetRealWidth(343),
                 Height = Application.GetRealWidth(148),
                 Radius = (uint)Application.GetRealWidth(5),
                 BackgroundColor = CSS_Color.MainBackgroundColor,
             };
-            bodyView.AddChidren(generalTableView);
+            contentView.AddChidren(generalTableView);
 
             TextButton btnTotalValue = new TextButton()
             {
@@ -58,30 +78,31 @@
             };
             generalTableView.AddChidren(btnTotalValueUint);
 
-            var btnValue = new Button()
+            var btnRealTimeData = new Button()
             {
                 X = Application.GetRealWidth(18),
                 Y = btnTotalValue.Bottom,
                 Width = Application.GetRealWidth(209),
                 Height = Application.GetRealWidth(28),
-                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextColor = CSS_Color.TextualColor,
                 TextSize = CSS_FontSize.SubheadingFontSize,
-                IsBold = true,
                 TextAlignment = TextAlignment.CenterLeft,
+                TextID = StringId.RealTimePowerConsumption,
             };
-            generalTableView.AddChidren(btnValue);
+            generalTableView.AddChidren(btnRealTimeData);
+            btnRealTimeData.Text = Language.StringByID(StringId.RealTimePowerConsumption).Replace("{0}", "0");
 
             var echartsView = new FrameLayout()
             {
-                Width = Application.GetRealWidth(100),
-                Height = Application.GetRealWidth(100),
+                Width = Application.GetRealWidth(118),
+                Height = Application.GetRealWidth(118),
                 X = Application.GetRealWidth(227),
-                Y = Application.GetRealWidth(16),
+                //Y = Application.GetRealWidth(16),
             };
             generalTableView.AddChidren(echartsView);
             MyEchartsViewOn myEchartsView = new MyEchartsViewOn() {
-                Width = Application.GetRealWidth(100),
-                Height = Application.GetRealWidth(100),
+                Width = Application.GetRealWidth(118),
+                Height = Application.GetRealWidth(118),
             };
 
             echartsView.AddChidren(myEchartsView);
@@ -97,6 +118,361 @@
             myEchartsView.ShowWithOption(echartRootJson);
 
 
+            var btnDrodDown = new Button()
+            {
+                Y = Application.GetRealWidth(118),
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealWidth(30),
+                UnSelectedImagePath = "FunctionIcon/Energy/EnergyDrodDownIcon.png",
+            };
+            generalTableView.AddChidren(btnDrodDown);
+
+            #endregion
+
+
+            var energyList = FunctionList.List.GetEnergyList();
+            var energyListView = new FrameLayout()
+            {
+                Y = generalTableView.Bottom + Application.GetRealWidth(8),
+                Height = Application.GetRealWidth(116 * energyList.Count) ,
+            };
+            contentView.AddChidren(energyListView);
+            int index = 0;
+            foreach(var energy in energyList)
+            {
+                EnergyRow(energy, energyListView, index);
+                index++;
+            }
+        }
+
+        public void ddd(FrameLayout contentView)
+        {
+
+            FrameLayout diagramView = new FrameLayout()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealWidth(420),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(12),
+                BorderColor = 0x00000000,
+                BorderWidth = 0,
+            };
+            contentView.AddChidren(diagramView);
+
+            #region 閫夋嫨鏁版嵁鏃ユ湡鑼冨洿
+            var showDataTypeView = new FrameLayout()
+            {
+                X = Application.GetRealWidth(183),
+                Y = Application.GetRealHeight(12),
+                Width = Application.GetRealWidth(144),
+                Height = Application.GetRealHeight(24),
+                BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg1.png",
+            };
+            diagramView.AddChidren(showDataTypeView);
+
+            var btnShowHistroyData_Day = new Button()
+            {
+                Width = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.PromptingColor2,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                IsSelected = true,
+                TextID = StringId.day,
+            };
+            showDataTypeView.AddChidren(btnShowHistroyData_Day);
+
+            var btnShowHistroyData_Week = new Button()
+            {
+                X = Application.GetRealWidth(48),
+                Width = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.PromptingColor2,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                TextID = StringId.week,
+            };
+            showDataTypeView.AddChidren(btnShowHistroyData_Week);
+
+            var btnShowHistroyData_Month = new Button()
+            {
+                X = Application.GetRealWidth(48 * 2),
+                Width = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.PromptingColor2,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                Text = DateTime.Now.Month.ToString() + Language.StringByID(StringId.month),
+            };
+            showDataTypeView.AddChidren(btnShowHistroyData_Month);
+            #endregion
+
+            var historyDataView = new FrameLayout()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(52),
+                Width = Application.GetRealWidth(343 - 32),
+                Height = Application.GetRealHeight(270),
+            };
+            diagramView.AddChidren(historyDataView);
+
+            var myEchartsView = new MyEchartsViewOn();
+
+            historyDataView.AddChidren(myEchartsView);
+
+        }
+            /// <summary>
+            /// 璇诲彇浼犳劅鍣ㄥ巻鍙叉暟鎹�
+            /// </summary>
+            void ddd2(string curQueryType,Function function,int index)
+            {
+                var seriesList = new List<EchartSeriesItem>();
+                var loadPage = new Loading()
+                {
+                    LodingBackgroundColor = 0x88888888,
+                };
+                historyDataView.AddChidren(loadPage);
+
+                new System.Threading.Thread(() =>
+                {
+                    try
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            loadPage.Start(Language.StringByID(StringId.PleaseWait));
+                        });
+                        int i = 0;
+
+                        {
+                            var sensorType = function.spk.Split(".")[0];
+                            var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, function.deviceId, sensorType);
+
+                            if (revertObj != null)
+                            {
+                                if (revertObj.Code == StateCode.SUCCESS)
+                                {
+                                    var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString());
+
+                                    var sItem = new EchartSeriesItem
+                                    {
+                                        data = new List<int>(),
+                                        lineStyle = new EchartLineStyle()
+                                        {
+                                            color = colorList2[i],
+#if __IOS__
+                                            width = 5,
+#elif __ANDROID__
+                                        width = 2,
+#endif
+                                        },
+                                    };
+
+                                    foreach (var d in revertData)
+                                    {
+                                        echartRootJson.xAxis.data.Add(d.fieldName);
+                                        echartRootJson.yAxis.data.Add(d.fieldValue);
+                                    }
+                                    seriesList.Add(sItem);
+                                }
+                                else
+                                {
+                                    Application.RunOnMainThread(() =>
+                                    {
+                                        IMessageCommon.Current.ShowErrorInfoAlter("", true, 2, Language.StringByID(StringId.GetSensorHistoryFailed), false);
+                                    });
+                                }
+                            }
+                            i++;
+                        }
+
+                    }
+                    catch (Exception ex)
+                    {
+                        MainPage.Log($"sensor history error : {ex.Message}");
+                    }
+                    finally
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            loadPage.Hide();
+                        });
+                    }
+                })
+                { IsBackground = true }.Start();
+                EchartsOption echartRootJson = new EchartsOption();
+                echartRootJson.series = seriesList;
+
+
+#if __IOS__
+                echartRootJson.xAxis.axisLabel.fontSize = 22;
+                echartRootJson.yAxis.axisLabel.fontSize = 22;
+#else
+                    echartRootJson.xAxis.axisLabel.fontSize = 8;
+                    echartRootJson.yAxis.axisLabel.fontSize = 8;
+#endif
+                var echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson);
+                myEchartsView.ShowWithOptionJsonString(echartRootJsonString);
+
+            }
+
+            var curQueryType = "";
+
+            void LoadEvent_ChangeSensorHistoryShowType()
+            {
+                btnShowHistroyData_Day.MouseUpEventHandler = (sender, e) =>
+                {
+                    showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg1.png";
+                    btnShowHistroyData_Day.IsSelected = true;
+                    btnShowHistroyData_Month.IsSelected = false;
+                    btnShowHistroyData_Week.IsSelected = false;
+                    curQueryType = "hour";
+                    LoadMothed_GetSensorHistoryData();
+                };
+
+                btnShowHistroyData_Month.MouseUpEventHandler = (sender, e) =>
+                {
+                    showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg3.png";
+                    btnShowHistroyData_Day.IsSelected = false;
+                    btnShowHistroyData_Month.IsSelected = true;
+                    btnShowHistroyData_Week.IsSelected = false;
+                    curQueryType = "week";
+                    LoadMothed_GetSensorHistoryData();
+                };
+                btnShowHistroyData_Week.MouseUpEventHandler = (sender, e) =>
+                {
+                    showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg2.png";
+                    btnShowHistroyData_Day.IsSelected = false;
+                    btnShowHistroyData_Month.IsSelected = false;
+                    btnShowHistroyData_Week.IsSelected = true;
+                    curQueryType = "month";
+                    LoadMothed_GetSensorHistoryData();
+                };
+
+            }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public void EnergyRow(Function energy, FrameLayout view, int index)
+        {
+            var btnLine = new Button()
+            {
+                Y = Application.GetRealWidth(116 * index),
+                Height = Application.GetRealWidth(16),
+            };
+            view.AddChidren(btnLine);
+
+            var row = new FrameLayout()
+            {
+                Y = btnLine.Bottom,
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealWidth(100),
+                Radius = (uint)Application.GetRealWidth(12),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+            };
+            view.AddChidren(row);
+
+            var btnColorTip = new Button()
+            {
+                X = Application.GetRealWidth(8),
+                Y = Application.GetRealWidth(16),
+                Width = Application.GetRealWidth(12),
+                Height = Application.GetRealWidth(12),
+                BackgroundColor = colorList[index],
+            };
+            row.AddChidren(btnColorTip);
+
+            var btnName = new Button()
+            {
+                X = Application.GetRealWidth(8 + 10 + 32),
+                Y = Application.GetRealHeight(10),
+                Width = Application.GetRealWidth(200),
+                Height = Application.GetRealHeight(24),
+                Text = energy.name,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextSize = CSS_FontSize.TextFontSize,
+            };
+            row.AddChidren(btnName);
+
+            var btnFromFloor = new Button()
+            {
+                X = Application.GetRealWidth(8 + 10 + 32),
+                Y = Application.GetRealHeight(10 + 24),
+                Width = Application.GetRealWidth(200),
+                Height = Application.GetRealHeight(18),
+                Text = energy.GetRoomListName(),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.PromptingColor1,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+            };
+            row.AddChidren(btnFromFloor);
+
+            var btnValue = new Button()
+            {
+                X = Application.GetRealWidth(28),
+                Y = Application.GetRealWidth(57),
+                Width = Application.GetRealWidth(226),
+                Height = Application.GetRealWidth(43),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextSize = CSS_FontSize.HeadlineFontSize,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                Text = "---"
+            };
+            row.AddChidren(btnValue);
+
+
+            var btnSetting = new Button()
+            {
+                X = Application.GetRealWidth(291),
+                Y = Application.GetRealWidth(6),
+                Width = Application.GetMinRealAverage(32),
+                Height = Application.GetMinRealAverage(32),
+                UnSelectedImagePath = "Public/FuncInfoSetIcon.png",
+            };
+            row.AddChidren(btnSetting);
+
+            Button btnSeltSensorValue = new Button()
+            {
+                X = Application.GetRealWidth(16),
+                Y = Application.GetRealWidth(47),
+                Width = Application.GetRealWidth(200),
+                Height = Application.GetRealWidth(43),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                IsBold = true,
+                TextSize = CSS_FontSize.HeadlineFontSize,
+            };
+            row.AddChidren(btnSeltSensorValue);
+
+            Button btnShowData;
+            btnShowData = new Button()
+            {
+                X = Application.GetRealWidth(291),
+                Y = Application.GetRealWidth(62),
+                Width = Application.GetMinRealAverage(32),
+                Height = Application.GetMinRealAverage(32),
+                UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/DiagramIcon.png",
+                SelectedImagePath = "FunctionIcon/EnvironmentalScience/DiagramIconOn.png",
+                IsSelected = true,
+            };
+            row.AddChidren(btnShowData);
+
+            btnSetting.MouseUpEventHandler = (sender, e) =>
+            {
+                Action backAction = () =>
+                {
+                    btnName.Text = energy.name;
+                };
+                var infoView = new FunctionBaseInfoSetPage(energy, backAction);
+                MainPage.BasePageView.AddChidren(infoView);
+                infoView.LoadPage();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+
         }
     }
 }

--
Gitblit v1.8.0