From c7f0f1a0c2148ca9a8944e523404b06351bb7977 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 14 四月 2022 15:35:39 +0800 Subject: [PATCH] 金茂温控器更新 --- HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs | 304 ++++++++++++++++++++++++++++++++------------------ 1 files changed, 193 insertions(+), 111 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs index 071bc9d..1f5553b 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs @@ -12,13 +12,15 @@ { CacWeekHistoryPage bodyView; + HorizontalScrolViewLayout dateHorView; Function device; /// <summary> /// 鏁版嵁鏄剧ず绫诲瀷 - /// temp 娓╁害 - /// humidity 婀垮害 + /// room_temp 娓╁害 + /// room_humidity 婀垮害 /// </summary> string showType; + Dictionary<string, double> dataDic = new Dictionary<string, double>(); public CacWeekHistoryPage(Function device,string type) { bodyView = this; @@ -29,7 +31,15 @@ public void InitView() { - new TopViewDiv(bodyView, "鏁版嵁").LoadTopView(); + if (showType == "room_temp") + { + new TopViewDiv(bodyView, Language.StringByID(StringId.Temp)).LoadTopView(); + } + else + { + new TopViewDiv(bodyView, Language.StringByID(StringId.Humidity)).LoadTopView(); + } + InitContentView(); @@ -55,116 +65,101 @@ TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, TextAlignment = TextAlignment.Center, - Text = "鏈�杩�7澶╂瘡澶╁钩鍧囧鍐呮俯搴︾粺璁″浘" }; + if (showType == "room_temp") + { + btnTitle.Text = "鏈�杩�7澶╂瘡澶╁钩鍧囧鍐呮俯搴︾粺璁″浘"; + } + else + { + btnTitle.Text = "鏈�杩�7澶╂瘡澶╁钩鍧囧鍐呮箍搴︾粺璁″浘"; + } contentView.AddChidren(btnTitle); FrameLayout dataView = new FrameLayout() { - Y = Application.GetRealHeight(69), + Y = Application.GetRealHeight(39), Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(293), - Height = Application.GetRealHeight(336), + Height = Application.GetRealHeight(345 + 30), }; contentView.AddChidren(dataView); Button btnUnit = new Button() { - Height = Application.GetRealHeight(15), + Height = Application.GetRealHeight(15 + 30), TextAlignment = TextAlignment.CenterLeft, TextColor = 0xFF43425D, TextSize = 8, - Text = "鍗曚綅锛氣剝" }; + if (showType == "room_temp") + { + btnUnit.Text = Language.StringByID(StringId.Uint) + "锛氣剝"; + } + else + { + btnUnit.Text = Language.StringByID(StringId.Uint) + "%"; + } dataView.AddChidren(btnUnit); - Dictionary<string, int> dataDic = new Dictionary<string, int>(); #if DEBUG - dataDic.Add("0201", 20); - dataDic.Add("0202", -20); - dataDic.Add("0203", 10); - dataDic.Add("0204", 40); - dataDic.Add("0205", 20); - dataDic.Add("0206", 20); - dataDic.Add("0207", 20); + //dataDic.Add("0201", 49); + //dataDic.Add("0202", 20); + //dataDic.Add("0203", 10); + //dataDic.Add("0204", 49); + //dataDic.Add("0205", 20); + //dataDic.Add("0206", 20); + //dataDic.Add("0207", 48); //dataDic.Add("0201", -20); //dataDic.Add("0202", -20); //dataDic.Add("0203", -20); - //dataDic.Add("0204", -40); + //dataDic.Add("0204", -48); //dataDic.Add("0205", -20); //dataDic.Add("0206", -20); //dataDic.Add("0207", -20); #endif - DataItemView dataShowView = new DataItemView("0"); - dataShowView.Height = Application.GetRealHeight(157 * 2 + 1); - dataShowView.Y = Application.GetRealHeight(21); + DataItemView dataShowView = new DataItemView("0",360); + //dataShowView.Height = Application.GetRealHeight(360); + dataShowView.Y = Application.GetRealHeight(30); List<string> items = new List<string>() { - "50","40","30","20","10","0","-10","-20","-30","-40","-50" + "100","90","80","70","60","50","40","30","20","10","0" }; + if (showType == "room_temp") + { + items = new List<string>() + { + "50","40","30","20","10","0","-10","-20","-30","-40","-50" + }; + } int index = 0; - foreach(var item in items) + foreach (var item in items) { DataItemView dataItemView; - if(item == "0") + if (item == "0" ) { dataItemView = dataShowView; + index++; } else { - dataItemView = new DataItemView(item); - dataItemView.Y = index * Application.GetRealHeight(30) + Application.GetRealHeight(15); + dataItemView = new DataItemView(item,30); + dataItemView.Y = ++index * Application.GetRealHeight(30) + Application.GetRealHeight(15); } - dataItemView.InitView(); + dataItemView.InitView(showType == "room_temp"); dataView.AddChidren(dataItemView); - index++; } - - RefrshDataView(dataDic, dataShowView); - + dateHorView = new HorizontalScrolViewLayout() { - var dateHorView = new HorizontalScrolViewLayout() - { - X = Application.GetRealWidth(51), - Y = dataView.Bottom + Application.GetRealHeight(11), - Width = Application.GetRealWidth(267), - Height = Application.GetRealHeight(26), - }; - contentView.AddChidren(dateHorView); - - foreach(var dic in dataDic) - { - FrameLayout dateView = new FrameLayout() - { - Width = Application.GetRealWidth(39), - Height = Application.GetRealHeight(26), - }; - dateHorView.AddChidren(dateView); - - Button btnLineh = new Button() - { - Width = 1, - Height = Application.GetRealHeight(4), - Gravity = Gravity.CenterHorizontal, - BackgroundColor = 0xFFDBDBDB - }; - dateView.AddChidren(btnLineh); - - Button btnDate = new Button() - { - Y = Application.GetRealHeight(12), - Height = Application.GetRealHeight(14), - TextColor = 0xFF43425D, - TextSize = 10, - Text = dic.Key, - }; - dateView.AddChidren(btnDate); - } - - } + X = Application.GetRealWidth(48), + Y = dataView.Bottom,// - Application.GetRealHeight(19), + Width = Application.GetRealWidth(267), + Height = Application.GetRealHeight(26), + }; + contentView.AddChidren(dateHorView); Button btnTip = new Button() { @@ -178,18 +173,82 @@ bodyView.AddChidren(btnTip); - new System.Threading.Thread(() => { - var revertObj = new HttpServerRequest().GetSensorHistory("week", device.deviceId, "room_temp"); + new System.Threading.Thread(() => + { - }) { IsBackground = true }.Start(); + var revertObj = new HttpServerRequest().GetSensorHistory("week", device.deviceId, showType); + if (revertObj.Code == StateCode.SUCCESS) + { + var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString()); + foreach (var reObj in revertData) + { + double value = 0; + try + { + value = Convert.ToDouble(reObj.fieldValue); + } + catch { } + dataDic.Add(reObj.time, value); + } + Application.RunOnMainThread(() => + { + RefrshDataView(dataDic, dataShowView); + RefreshXtext(); + }); + + } + }) + { IsBackground = true }.Start(); } - void RefrshDataView(Dictionary<string,int> dataDic, DataItemView dataShowView) + void RefreshXtext() + { + dateHorView.RemoveAll(); + + foreach (var dic in dataDic) + { + FrameLayout dateView = new FrameLayout() + { + Width = Application.GetRealWidth(39), + Height = Application.GetRealHeight(26), + }; + dateHorView.AddChidren(dateView); + + Button btnLineh = new Button() + { + Width = 1, + Height = Application.GetRealHeight(4), + Gravity = Gravity.CenterHorizontal, + BackgroundColor = 0xFFDBDBDB + }; + dateView.AddChidren(btnLineh); + + Button btnDate = new Button() + { + Y = Application.GetRealHeight(12), + Height = Application.GetRealHeight(14), + TextColor = 0xFF43425D, + TextSize = 10, + Text = dic.Key, + }; + try + { + string[] strs = dic.Key.Split(@"/"); + btnDate.Text = strs[1] + "/" + strs[2]; + } + catch { } + dateView.AddChidren(btnDate); + } + + } + + + void RefrshDataView(Dictionary<string,double> dataDic, FrameLayout dataShowView) { int valueIndex = 0; foreach (var data in dataDic) { - ColumnarView cv = new ColumnarView(data.Value); + ColumnarView cv = new ColumnarView(device.deviceId,showType, data.Key, data.Value); cv.X = Application.GetRealWidth(valueIndex * 38 + 25); cv.InitView(); dataShowView.AddChidren(cv); @@ -207,19 +266,20 @@ class DataItemView : FrameLayout { string value; - - public DataItemView(string value) + Button btnLine; + int height; + public DataItemView(string value,int height) { this.value = value; Width = Application.GetRealWidth(293); - Height = Application.GetRealHeight(30); + this.height = height; + Height = Application.GetRealHeight(height); } - public void InitView() { + public void InitView(bool isTemp) { Button btnValue = new Button() { - Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(18), Height = Application.GetRealHeight(30), TextAlignment = TextAlignment.CenterRight, @@ -229,14 +289,30 @@ }; AddChidren(btnValue); - Button btnLine = new Button() + btnLine = new Button() { - Gravity = Gravity.CenterVertical, X = Application.GetRealWidth(26), Width = Application.GetRealWidth(267), Height = 1, BackgroundColor = CSS_Color.DividingLineColor, }; + if (isTemp) + { + btnLine.Gravity = Gravity.CenterVertical; + btnValue.Gravity = Gravity.CenterVertical; + } + else + { + if (height == 360) + { + btnValue.Y = Application.GetRealHeight(height - 45); + } + else + { + btnLine.Gravity = Gravity.CenterVertical; + } + btnLine.Y = Application.GetRealHeight(height - 30); + } AddChidren(btnLine); @@ -244,11 +320,16 @@ } + } class ColumnarView : VerticalScrolViewLayout { - int value; + string functionId; + string time; + string type; + double value; + string valueText; /// <summary> /// 鏂瑰悜锛氬悜涓娿�佸悜涓� /// </summary> @@ -257,9 +338,13 @@ Button btnValueText; - public ColumnarView(int value) + public ColumnarView(string functionId,string type, string key, double value) { + this.functionId = functionId; + this.type = type; + time = key; this.isUpward = value >= 0; + valueText = value.ToString(); if (isUpward) { this.value = value; @@ -269,7 +354,7 @@ this.value = value * -1; } Width = Application.GetRealWidth(39); - Height = Application.GetRealHeight(value * 3 + 30); + Height = Application.GetRealHeight((int)(value * 3 + 30)); } public void InitView() @@ -278,7 +363,7 @@ btnValue = new Button() { Gravity = Gravity.CenterHorizontal, - Height = Application.GetRealHeight(value * 3), + Height = Application.GetRealHeight((int)(value * 3)), Width = Application.GetRealWidth(16), BackgroundColor = 0xFFFF9D54, }; @@ -288,51 +373,48 @@ Height = Application.GetRealHeight(30), TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextColor = 0xFF43425D, - Text = value + "鈩�", + Text = valueText, }; - AddChidren(btnValueText); - - - if (isUpward) + if(type == "room_temp") { - //btnValue.Height += Application.GetRealHeight(1); - yValue = 158 - 30 - value * 3; - yValue = yValue > 0 ? yValue : 158; - Y = Application.GetRealHeight(yValue); - AddChidren(btnValueText); - AddChidren(btnValue); + btnValueText.Text += "鈩�"; + if (isUpward) + { + yValue = (int)(150 - value * 3); + yValue = yValue > 0 ? yValue : 0; + Y = Application.GetRealHeight(yValue+1); + AddChidren(btnValueText); + AddChidren(btnValue); + } + else + { + Y = Application.GetRealHeight(180); + AddChidren(btnValue); + AddChidren(btnValueText); + } } else { - btnValue.Height += Application.GetRealHeight(2); - Y = Application.GetRealHeight(157); - AddChidren(btnValue); + yValue = (int)(360 -30- 30 - value * 3); + Y = Application.GetRealHeight(yValue+1); AddChidren(btnValueText); + AddChidren(btnValue); + btnValueText.Text += "%"; } - - - - - - - - - - } public void Clicker() { btnValue.MouseUpEventHandler = (sender, e) => { - var page = new CacDayHistoryPage(); + var page = new CacDayHistoryPage(functionId,type, time); MainPage.BasePageView.AddChidren(page); page.InitView(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; btnValueText.MouseUpEventHandler = (sender, e) => { - var page = new CacDayHistoryPage(); + var page = new CacDayHistoryPage(functionId,type, time); MainPage.BasePageView.AddChidren(page); page.InitView(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; -- Gitblit v1.8.0