using 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;
|
Function device;
|
/// <summary>
|
/// 数据显示类型
|
/// temp 温度
|
/// humidity 湿度
|
/// </summary>
|
string showType;
|
public CacWeekHistoryPage(Function device,string type)
|
{
|
bodyView = this;
|
this.device = device;
|
showType = type;
|
BackgroundColor = CSS_Color.BackgroundColor;
|
}
|
|
public void InitView()
|
{
|
new TopViewDiv(bodyView, "数据").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,
|
Text = "最近7天每天平均室内温度统计图"
|
};
|
contentView.AddChidren(btnTitle);
|
|
FrameLayout dataView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(69),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(293),
|
Height = Application.GetRealHeight(336),
|
};
|
contentView.AddChidren(dataView);
|
|
Button btnUnit = new Button()
|
{
|
Height = Application.GetRealHeight(15),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = 0xFF43425D,
|
TextSize = 8,
|
Text = "单位:℃"
|
};
|
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", -20);
|
//dataDic.Add("0202", -20);
|
//dataDic.Add("0203", -20);
|
//dataDic.Add("0204", -40);
|
//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);
|
|
List<string> 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;
|
}
|
else
|
{
|
dataItemView = new DataItemView(item);
|
dataItemView.Y = index * Application.GetRealHeight(30) + Application.GetRealHeight(15);
|
}
|
dataItemView.InitView();
|
dataView.AddChidren(dataItemView);
|
index++;
|
}
|
|
RefrshDataView(dataDic, dataShowView);
|
|
{
|
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);
|
}
|
|
}
|
|
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, "room_temp");
|
|
}) { IsBackground = true }.Start();
|
}
|
|
void RefrshDataView(Dictionary<string,int> dataDic, DataItemView dataShowView)
|
{
|
int valueIndex = 0;
|
foreach (var data in dataDic)
|
{
|
ColumnarView cv = new ColumnarView(data.Value);
|
cv.X = Application.GetRealWidth(valueIndex * 38 + 25);
|
cv.InitView();
|
dataShowView.AddChidren(cv);
|
cv.Clicker();
|
|
|
valueIndex++;
|
}
|
}
|
|
|
|
}
|
|
class DataItemView : FrameLayout
|
{
|
string value;
|
|
public DataItemView(string value)
|
{
|
this.value = value;
|
Width = Application.GetRealWidth(293);
|
Height = Application.GetRealHeight(30);
|
}
|
|
public void InitView() {
|
|
Button btnValue = new Button()
|
{
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(18),
|
Height = Application.GetRealHeight(30),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = 0xFF43425D,
|
TextSize = 8,
|
Text = value
|
};
|
AddChidren(btnValue);
|
|
Button btnLine = new Button()
|
{
|
Gravity = Gravity.CenterVertical,
|
X = Application.GetRealWidth(26),
|
Width = Application.GetRealWidth(267),
|
Height = 1,
|
BackgroundColor = CSS_Color.DividingLineColor,
|
};
|
AddChidren(btnLine);
|
|
|
|
|
|
}
|
}
|
|
class ColumnarView : VerticalScrolViewLayout
|
{
|
int value;
|
/// <summary>
|
/// 方向:向上、向下
|
/// </summary>
|
bool isUpward;
|
Button btnValue;
|
Button btnValueText;
|
|
|
public ColumnarView(int value)
|
{
|
this.isUpward = value >= 0;
|
if (isUpward)
|
{
|
this.value = value;
|
}
|
else
|
{
|
this.value = value * -1;
|
}
|
Width = Application.GetRealWidth(39);
|
Height = Application.GetRealHeight(value * 3 + 30);
|
}
|
|
public void InitView()
|
{
|
int yValue = 0;
|
btnValue = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Height = Application.GetRealHeight(value * 3),
|
Width = Application.GetRealWidth(16),
|
BackgroundColor = 0xFFFF9D54,
|
};
|
|
btnValueText = new Button()
|
{
|
Height = Application.GetRealHeight(30),
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextColor = 0xFF43425D,
|
Text = value + "℃",
|
};
|
AddChidren(btnValueText);
|
|
|
if (isUpward)
|
{
|
//btnValue.Height += Application.GetRealHeight(1);
|
yValue = 158 - 30 - value * 3;
|
yValue = yValue > 0 ? yValue : 158;
|
Y = Application.GetRealHeight(yValue);
|
AddChidren(btnValueText);
|
AddChidren(btnValue);
|
}
|
else
|
{
|
btnValue.Height += Application.GetRealHeight(2);
|
Y = Application.GetRealHeight(157);
|
AddChidren(btnValue);
|
AddChidren(btnValueText);
|
}
|
|
|
|
|
|
|
|
|
|
|
}
|
|
public void Clicker()
|
{
|
btnValue.MouseUpEventHandler = (sender, e) =>
|
{
|
var page = new CacDayHistoryPage();
|
MainPage.BasePageView.AddChidren(page);
|
page.InitView();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
btnValueText.MouseUpEventHandler = (sender, e) =>
|
{
|
var page = new CacDayHistoryPage();
|
MainPage.BasePageView.AddChidren(page);
|
page.InitView();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
}
|
}
|
}
|