| | |
| | | { |
| | | |
| | | 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; |
| | |
| | | |
| | | 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(); |
| | |
| | | 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() |
| | | { |
| | |
| | | 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); |
| | |
| | | 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, |
| | |
| | | }; |
| | | 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); |
| | | |
| | | |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | class ColumnarView : VerticalScrolViewLayout |
| | | { |
| | | int value; |
| | | string functionId; |
| | | string time; |
| | | string type; |
| | | double value; |
| | | string valueText; |
| | | /// <summary> |
| | | /// 方向:向上、向下 |
| | | /// </summary> |
| | |
| | | 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; |
| | |
| | | this.value = value * -1; |
| | | } |
| | | Width = Application.GetRealWidth(39); |
| | | Height = Application.GetRealHeight(value * 3 + 30); |
| | | Height = Application.GetRealHeight((int)(value * 3 + 30)); |
| | | } |
| | | |
| | | public void InitView() |
| | |
| | | btnValue = new Button() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Height = Application.GetRealHeight(value * 3), |
| | | Height = Application.GetRealHeight((int)(value * 3)), |
| | | Width = Application.GetRealWidth(16), |
| | | BackgroundColor = 0xFFFF9D54, |
| | | }; |
| | |
| | | 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; |