陈嘉乐
2021-03-29 e990a9737e423d7005506a569e98fb4032fceb46
HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs
New file
@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
    public class EnergyMainPage : FrameLayout
    {
        FrameLayout bodyView;
        public EnergyMainPage()
        {
            bodyView = this;
        }
        public void LoadPage()
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.EnergyMonitoring)).LoadTopView();
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            var generalTableView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(80),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealWidth(148),
                Radius = (uint)Application.GetRealWidth(5),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(generalTableView);
            TextButton btnTotalValue = new TextButton()
            {
                X = Application.GetRealWidth(18),
                Y = Application.GetRealWidth(24),
                Width = Application.GetRealWidth(18),
                Height = Application.GetRealWidth(52),
                TextColor = CSS_Color.FirstLevelTitleColor,
                IsBold = true,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 40,
                Text = "000"
            };
            generalTableView.AddChidren(btnTotalValue);
            btnTotalValue.Width = btnTotalValue.GetTextWidth();
            var btnTotalValueUint = new Button()
            {
                X = btnTotalValue.Right,
                Y = Application.GetRealWidth(24),
                Width = Application.GetRealWidth(60),
                Height = Application.GetRealWidth(28),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                IsBold = true,
                Text = "kW‧h",
                TextAlignment = TextAlignment.CenterLeft,
            };
            generalTableView.AddChidren(btnTotalValueUint);
            var btnValue = new Button()
            {
                X = Application.GetRealWidth(18),
                Y = btnTotalValue.Bottom,
                Width = Application.GetRealWidth(209),
                Height = Application.GetRealWidth(28),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                IsBold = true,
                TextAlignment = TextAlignment.CenterLeft,
            };
            generalTableView.AddChidren(btnValue);
            var echartsView = new FrameLayout()
            {
                Width = Application.GetRealWidth(118),
                Height = Application.GetRealWidth(118),
                X = Application.GetRealWidth(227),
                //Y = Application.GetRealWidth(16),
            };
            generalTableView.AddChidren(echartsView);
            MyEchartsViewOn myEchartsView = new MyEchartsViewOn() {
                Width = Application.GetRealWidth(118),
                Height = Application.GetRealWidth(118),
            };
            echartsView.AddChidren(myEchartsView);
            Dictionary<string, string> list = new Dictionary<string, string>();
            list.Add("电冰箱", "12");
            list.Add("电风扇", "2");
            list.Add("空调", "9");
            list.Add("洗衣机", "3");
            list.Add("电脑", "33");
            var echartsPie = new EchartsOption_Pie();
            var echartRootJson = echartsPie.InitDateJson(list);
            //var echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson);
            myEchartsView.ShowWithOption(echartRootJson);
        }
    }
}