From 4c586bb23cdcae56ae4e4c62e90e148dc10b9d90 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 17 五月 2022 14:19:31 +0800 Subject: [PATCH] Merge branch 'Dev-Branch' into wxr1215 --- HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs | 424 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 424 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs new file mode 100644 index 0000000..1f5553b --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacWeekHistoryPage.cs @@ -0,0 +1,424 @@ +锘縰sing System; +using System.Collections.Generic; +using HDL_ON.DAL.Server; +using HDL_ON.Entity; +using HDL_ON.Stan; +using HDL_ON.UI.CSS; +using Shared; + +namespace HDL_ON.UI +{ + public class CacWeekHistoryPage : FrameLayout + { + + CacWeekHistoryPage bodyView; + HorizontalScrolViewLayout dateHorView; + Function device; + /// <summary> + /// 鏁版嵁鏄剧ず绫诲瀷 + /// room_temp 娓╁害 + /// room_humidity 婀垮害 + /// </summary> + string showType; + Dictionary<string, double> dataDic = new Dictionary<string, double>(); + public CacWeekHistoryPage(Function device,string type) + { + bodyView = this; + this.device = device; + showType = type; + BackgroundColor = CSS_Color.BackgroundColor; + } + + public void InitView() + { + if (showType == "room_temp") + { + new TopViewDiv(bodyView, Language.StringByID(StringId.Temp)).LoadTopView(); + } + else + { + new TopViewDiv(bodyView, Language.StringByID(StringId.Humidity)).LoadTopView(); + } + + + + InitContentView(); + } + + + private void InitContentView() + { + FrameLayout contentView = new FrameLayout() + { + Y = Application.GetRealHeight(80), + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(482), + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealWidth(5) + }; + bodyView.AddChidren(contentView); + + Button btnTitle = new Button() + { + Height = Application.GetRealHeight(60), + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + TextAlignment = TextAlignment.Center, + }; + if (showType == "room_temp") + { + btnTitle.Text = "鏈�杩�7澶╂瘡澶╁钩鍧囧鍐呮俯搴︾粺璁″浘"; + } + else + { + btnTitle.Text = "鏈�杩�7澶╂瘡澶╁钩鍧囧鍐呮箍搴︾粺璁″浘"; + } + contentView.AddChidren(btnTitle); + + FrameLayout dataView = new FrameLayout() + { + Y = Application.GetRealHeight(39), + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(293), + Height = Application.GetRealHeight(345 + 30), + }; + contentView.AddChidren(dataView); + + Button btnUnit = new Button() + { + Height = Application.GetRealHeight(15 + 30), + TextAlignment = TextAlignment.CenterLeft, + TextColor = 0xFF43425D, + TextSize = 8, + }; + if (showType == "room_temp") + { + btnUnit.Text = Language.StringByID(StringId.Uint) + "锛氣剝"; + } + else + { + btnUnit.Text = Language.StringByID(StringId.Uint) + "%"; + } + dataView.AddChidren(btnUnit); + +#if DEBUG + //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", -48); + //dataDic.Add("0205", -20); + //dataDic.Add("0206", -20); + //dataDic.Add("0207", -20); +#endif + + DataItemView dataShowView = new DataItemView("0",360); + //dataShowView.Height = Application.GetRealHeight(360); + dataShowView.Y = Application.GetRealHeight(30); + + List<string> items = new List<string>() + { + "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) + { + DataItemView dataItemView; + if (item == "0" ) + { + dataItemView = dataShowView; + index++; + } + else + { + dataItemView = new DataItemView(item,30); + dataItemView.Y = ++index * Application.GetRealHeight(30) + Application.GetRealHeight(15); + } + dataItemView.InitView(showType == "room_temp"); + dataView.AddChidren(dataItemView); + } + dateHorView = new HorizontalScrolViewLayout() + { + 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() + { + Y = contentView.Bottom + Application.GetRealHeight(28), + Height = Application.GetRealHeight(20), + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, + TextAlignment = TextAlignment.Center, + Text = "*鍙�氳繃鐐瑰嚮鏌卞舰鍥炬煡鐪嬪綋澶�24灏忔椂娓╁害缁熻" + }; + bodyView.AddChidren(btnTip); + + + new System.Threading.Thread(() => + { + + 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 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(device.deviceId,showType, data.Key, data.Value); + cv.X = Application.GetRealWidth(valueIndex * 38 + 25); + cv.InitView(); + dataShowView.AddChidren(cv); + cv.Clicker(); + + + valueIndex++; + } + } + + + + } + + class DataItemView : FrameLayout + { + string value; + Button btnLine; + int height; + public DataItemView(string value,int height) + { + this.value = value; + Width = Application.GetRealWidth(293); + this.height = height; + Height = Application.GetRealHeight(height); + } + + public void InitView(bool isTemp) { + + Button btnValue = new Button() + { + Width = Application.GetRealWidth(18), + Height = Application.GetRealHeight(30), + TextAlignment = TextAlignment.CenterRight, + TextColor = 0xFF43425D, + TextSize = 8, + Text = value + }; + AddChidren(btnValue); + + btnLine = new Button() + { + 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); + + + + + + } + + } + + class ColumnarView : VerticalScrolViewLayout + { + string functionId; + string time; + string type; + double value; + string valueText; + /// <summary> + /// 鏂瑰悜锛氬悜涓娿�佸悜涓� + /// </summary> + bool isUpward; + Button btnValue; + Button btnValueText; + + + 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; + } + else + { + this.value = value * -1; + } + Width = Application.GetRealWidth(39); + Height = Application.GetRealHeight((int)(value * 3 + 30)); + } + + public void InitView() + { + int yValue = 0; + btnValue = new Button() + { + Gravity = Gravity.CenterHorizontal, + Height = Application.GetRealHeight((int)(value * 3)), + Width = Application.GetRealWidth(16), + BackgroundColor = 0xFFFF9D54, + }; + + btnValueText = new Button() + { + Height = Application.GetRealHeight(30), + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + TextColor = 0xFF43425D, + Text = valueText, + }; + if(type == "room_temp") + { + 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 + { + 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(functionId,type, time); + MainPage.BasePageView.AddChidren(page); + page.InitView(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + btnValueText.MouseUpEventHandler = (sender, e) => + { + var page = new CacDayHistoryPage(functionId,type, time); + MainPage.BasePageView.AddChidren(page); + page.InitView(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + } + } +} -- Gitblit v1.8.0