From 9281822c02a3b2b7f7f6b4215505095e9ff12fe1 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期日, 06 六月 2021 13:52:26 +0800
Subject: [PATCH] 2021-6-6-1
---
HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs | 408 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 395 insertions(+), 13 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs
index fcff06d..80ee1ff 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs
@@ -1,32 +1,53 @@
锘縰sing System;
using System.Collections.Generic;
+using HDL_ON.DAL.Server;
+using HDL_ON.Entity;
using HDL_ON.UI.CSS;
+using HDL_ON.UI.UI2.EchartsOption_Energy;
using Shared;
namespace HDL_ON.UI
{
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 +79,32 @@
};
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),
+ MyEchartsViewOn myEchartsView = new MyEchartsViewOn()
+ {
+ Width = Application.GetRealWidth(118),
+ Height = Application.GetRealWidth(118),
};
echartsView.AddChidren(myEchartsView);
@@ -97,6 +120,365 @@
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++;
+ }
+ }
+ FrameLayout diagramView;
+ List<Function> queryList = new List<Function>();
+ string curQueryType = "hour";
+
+ void d1(FrameLayout contentView)
+ {
+ 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);
+
+
+ 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";
+ d2();
+ };
+
+ 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";
+ d2();
+ };
+ 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";
+ d2();
+ };
+
+ #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);
+
+ }
+
+ void d2()
+ {
+ int index = 0;
+ var echartRootJson = new EchartsOption_Energy();
+ var seriesList = new List<EchartSeriesItem>();
+ foreach (var function in queryList)
+ {
+ var seriesItem = d3(function, index, echartRootJson.xAxis.data);
+ seriesList.Add(seriesItem);
+ }
+ }
+ /// <summary>
+ /// 鏌ヨ鍒楄〃
+ /// </summary>
+ /// <summary>
+ /// 璇诲彇浼犳劅鍣ㄥ巻鍙叉暟鎹�
+ /// </summary>
+ EchartSeriesItem d3(Function function, int index, List<string> xAxisData)
+ {
+ EchartSeriesItem sItem = null;
+ List<string> data = new List<string>();
+ var loadPage = new Loading()
+ {
+ LodingBackgroundColor = 0x88888888,
+ };
+ diagramView.AddChidren(loadPage);
+
+ try
+ {
+ Application.RunOnMainThread(() =>
+ {
+ loadPage.Start(Language.StringByID(StringId.PleaseWait));
+ });
+ 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());
+
+ sItem = new EchartSeriesItem
+ {
+ data = new List<int>(),
+ lineStyle = new EchartLineStyle()
+ {
+ color = colorList2[index],
+#if __IOS__
+ width = 5,
+#elif __ANDROID__
+ width = 2,
+#endif
+ },
+ };
+
+ try
+ {
+ foreach (var d in revertData)
+ {
+ if (xAxisData.Count == 0)
+ {
+ data.Add(d.fieldName);
+ }
+ sItem.data.Add(Convert.ToInt32(d.fieldValue));
+ }
+ xAxisData.AddRange(data);
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"revertData:{ex.Message}");
+ }
+ }
+ else
+ {
+ Application.RunOnMainThread(() =>
+ {
+ IMessageCommon.Current.ShowErrorInfoAlter("", true, 2, Language.StringByID(StringId.GetSensorHistoryFailed), false);
+ });
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"sensor history error : {ex.Message}");
+ }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ loadPage.Hide();
+ });
+ }
+ return sItem;
+
+ //var echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson);
+ //myEchartsView.ShowWithOptionJsonString(echartRootJsonString);
+ }
+
+
+ /// <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;
+ };
+
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.8.0