using System;
|
using Shared;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using System.Collections.Generic;
|
|
namespace HDL_ON.UI
|
{
|
public partial class EnvironmentalSciencePage : FrameLayout
|
{
|
|
#region 控件集合
|
static EnvironmentalSciencePage bodyView;
|
/// <summary>
|
/// 楼层显示
|
/// </summary>
|
Button btnRoom;
|
/// <summary>
|
/// 房间选择下拉图标
|
/// </summary>
|
Button btnFoorDownIcon;
|
#endregion
|
#region 区域变量
|
uint level1Color = 0xFF2172FF;
|
uint level2Color = 0xCC4484F4;
|
uint level3Color = 0x664484F4;
|
uint level4Color = 0xFFADE764;
|
uint level5Color = 0xFFFFDD55;
|
uint level6Color = 0xFFFF9D54;
|
uint level7Color = 0xFFFF3D3D;
|
|
Room room;
|
|
#endregion
|
|
|
public EnvironmentalSciencePage()
|
{
|
bodyView = this;
|
}
|
|
/// <summary>
|
/// 加载界面
|
/// </summary>
|
/// <param name="btnCollectionIcon">收藏按钮</param>
|
/// <param name="btnFunctionName">功能名称信息按钮</param>
|
/// <param name="btnFromFloor">功能楼层信息按钮</param>
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
|
|
#region 顶部天气部分
|
var topWeatherView = new FrameLayout() {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(76),
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(151),
|
BackgroundColor = CSS_Color.MainColor,
|
Radius = (uint)Application.GetRealWidth(12),
|
};
|
bodyView.AddChidren(topWeatherView);
|
|
var btnTemp = new Button()
|
{
|
X = Application.GetRealWidth(24),
|
Y = Application.GetRealHeight(16),
|
Width = Application.GetRealWidth(55),
|
Height = Application.GetRealHeight(48),
|
TextSize = 42,
|
IsBold = true,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.MainBackgroundColor,
|
|
Text = "28",
|
};
|
topWeatherView.AddChidren(btnTemp);
|
|
var btnTempUint = new Button()
|
{
|
X = Application.GetRealWidth(79),
|
Y = Application.GetRealHeight(16),
|
Width = Application.GetRealWidth(20),
|
Height = Application.GetRealHeight(20),
|
TextSize = 12,
|
TextColor = CSS_Color.MainBackgroundColor,
|
Text = "°C",
|
};
|
topWeatherView.AddChidren(btnTempUint);
|
|
var btnWeatherIcon = new Button()
|
{
|
X = Application.GetRealWidth(115),
|
Y = Application.GetRealHeight(16),
|
Width = Application.GetRealWidth(20),
|
Height = Application.GetRealWidth(20),
|
UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/SmogIcon.png",
|
};
|
topWeatherView.AddChidren(btnWeatherIcon);
|
|
var btnWatherText = new Button()
|
{
|
X = Application.GetRealWidth(139),
|
Y = Application.GetRealHeight(16),
|
Width = Application.GetRealWidth(28 * 3),
|
Height = Application.GetRealHeight(20),
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = "雾霾"
|
};
|
topWeatherView.AddChidren(btnWatherText);
|
|
|
var btnTempUpperLimit = new Button()
|
{
|
X = btnWeatherIcon.X,
|
Y = Application.GetRealHeight(46),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/UpArrow.png",
|
};
|
topWeatherView.AddChidren(btnTempUpperLimit);
|
|
var btnTempUpperLimitText = new Button()
|
{
|
X = btnTempUpperLimit.Right,
|
Y = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(42),
|
Height = Application.GetRealHeight(20),
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.TextFontSize,
|
Text = "10°C",
|
};
|
topWeatherView.AddChidren(btnTempUpperLimitText);
|
|
|
var btnTempLowerLimit = new Button()
|
{
|
X = btnTempUpperLimitText.Right,
|
Y = Application.GetRealHeight(46),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/UpArrow.png",
|
};
|
btnTempLowerLimit.SetRotation(180f);
|
topWeatherView.AddChidren(btnTempLowerLimit);
|
|
var btnTempLowerLimitText = new Button()
|
{
|
X = btnTempLowerLimit.Right,
|
Y = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(42),
|
Height = Application.GetRealHeight(20),
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.TextFontSize,
|
Text = "2°C",
|
};
|
topWeatherView.AddChidren(btnTempLowerLimitText);
|
|
|
|
var btnLocationText = new Button()
|
{
|
X = Application.GetRealWidth(233),
|
Y = Application.GetRealHeight(18),
|
Width = Application.GetRealWidth(74),
|
Height = Application.GetRealHeight(17),
|
TextAlignment = TextAlignment.CenterRight,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextColor = CSS_Color.MainBackgroundColor,
|
Text = "广州",
|
};
|
topWeatherView.AddChidren(btnLocationText);
|
|
var btnLocationIcon = new Button()
|
{
|
X = btnLocationText.Right,
|
Y = Application.GetRealHeight(18),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealHeight(16),
|
UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/LocationIcon.png",
|
};
|
topWeatherView.AddChidren(btnLocationIcon);
|
|
Button btnHumidityIcon = new Button()
|
{
|
X = Application.GetRealWidth(26),
|
Y = Application.GetRealHeight(90),
|
Width = Application.GetRealWidth(24),
|
Height = Application.GetRealWidth(24),
|
UnSelectedImagePath = "Public/DeviceInfoIcon/HumidityIcon.png",
|
};
|
topWeatherView.AddChidren(btnHumidityIcon);
|
|
Button btnHumidityText = new Button()
|
{
|
X = Application.GetRealWidth(15),
|
Y = btnHumidityIcon.Bottom,
|
Width = Application.GetRealWidth(46),
|
Height = Application.GetRealHeight(25),
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.MainBackgroundColor,
|
Text = "--%",
|
};
|
topWeatherView.AddChidren(btnHumidityText);
|
|
Button btnPm25Icon = new Button()
|
{
|
X = Application.GetRealWidth(104),
|
Y = Application.GetRealHeight(90),
|
Width = Application.GetRealWidth(24),
|
Height = Application.GetRealWidth(24),
|
UnSelectedImagePath = "Public/DeviceInfoIcon/Pm25Icon.png",
|
};
|
topWeatherView.AddChidren(btnPm25Icon);
|
|
Button btnPm25Values = new Button()
|
{
|
X = Application.GetRealWidth(90),
|
Y = btnHumidityIcon.Bottom,
|
Width = Application.GetRealWidth(52),
|
Height = Application.GetRealHeight(25),
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.MainBackgroundColor,
|
Text = "--",
|
};
|
topWeatherView.AddChidren(btnPm25Values);
|
|
Button btnFanSpeedIcon = new Button()
|
{
|
X = Application.GetRealWidth(182),
|
Y = Application.GetRealHeight(90),
|
Width = Application.GetRealWidth(24),
|
Height = Application.GetRealWidth(24),
|
UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/WeatherFanSpeedIcon.png",
|
};
|
topWeatherView.AddChidren(btnFanSpeedIcon);
|
|
Button btnFanSpeedValues = new Button()
|
{
|
X = Application.GetRealWidth(162),
|
Y = btnFanSpeedIcon.Bottom,
|
Width = Application.GetRealWidth(63),
|
Height = Application.GetRealHeight(25),
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.MainBackgroundColor,
|
Text = "--",
|
};
|
topWeatherView.AddChidren(btnFanSpeedValues);
|
#endregion
|
|
#region contentView
|
FrameLayout contentView = new FrameLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(239),
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(418),
|
Radius = (uint)Application.GetRealWidth(12),
|
BorderColor = 0x00000000,
|
BorderWidth = 0,
|
BackgroundColor = CSS_Color.BackgroundColor,
|
};
|
bodyView.AddChidren(contentView);
|
|
#region 房间顶部切换显示区域
|
room = new Room();
|
if (DB_ResidenceData.residenceData.rooms.Count > 0)
|
{
|
room = DB_ResidenceData.residenceData.rooms[0];
|
}
|
btnFoorDownIcon = new Button()
|
{
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(18),
|
UnSelectedImagePath = "Public/DownIcon.png",
|
};
|
contentView.AddChidren(btnFoorDownIcon);
|
|
btnRoom = new Button()
|
{
|
X = btnFoorDownIcon.Right,
|
Y = Application.GetRealHeight(18),
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetMinRealAverage(16),
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = room.name,
|
};
|
contentView.AddChidren(btnRoom);
|
#endregion
|
|
FrameLayout sensorListView = new FrameLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(50),
|
Width = Application.GetRealWidth(308),
|
Height = Application.GetRealHeight(456),
|
Radius = (uint)Application.GetRealWidth(12),
|
BorderColor = 0x00000000,
|
BorderWidth = 0,
|
};
|
contentView.AddChidren(sensorListView);
|
|
|
int index = 0;
|
foreach(var sensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience)
|
{
|
if(sensor.functionType == FunctionType.Noise|| sensor.functionType == FunctionType.WindPower)
|
{
|
continue;
|
}
|
if(sensor.roomIdList.Contains(room.sid))
|
{
|
FrameLayout sensorView = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(148),
|
Height = Application.GetRealWidth(80),
|
Radius = (uint)Application.GetRealWidth(8),
|
BorderColor = 0x00000000,
|
BorderWidth = 0,
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Y = Application.GetRealWidth(92 * (index / 2))
|
};
|
if(index%2!=0)
|
{
|
sensorView.X = Application.GetRealWidth(160);
|
}
|
sensorListView.AddChidren(sensorView);
|
|
var arcBar = new ArcSeekBar()
|
{
|
ProgressBarUnitSring = "°C",
|
X = Application.GetRealWidth(7),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(48),
|
Height = Application.GetRealWidth(48),
|
Angle = 1,
|
ThumbColor = 0x00000000,
|
ThumbModeFill = true,
|
ProgressBarColor = sensor.levelColorList[sensor.curLevel - 1],
|
ThumbRadius = 1,
|
ArcWidthWithDefaultStyle = Application.GetRealWidth(3),
|
MinValue = 0,
|
MaxValue = 96,
|
Progress = (96 / sensor.levelColorList.Count) * sensor.curLevel,
|
//ProgressBarUnitSring = "",
|
IsClickable = false,
|
ProgressTextColor = 0x00000000,
|
ArcColor = CSS_Color.BackgroundColor,
|
//BackgroundColor = 0x33FF0000,
|
};
|
sensorView.AddChidren(arcBar);
|
|
var btnSensorTitle = new Button()
|
{
|
X = Application.GetRealWidth(7),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(48),
|
Height = Application.GetRealWidth(48),
|
TextAlignment = TextAlignment.Center,
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextID = sensor.functionTypeNameId
|
};
|
sensorView.AddChidren(btnSensorTitle);
|
btnSensorTitle.MouseUpEventHandler = (sender, e) => {
|
var esp = new EnvironmentalSensorPage(sensor);
|
MainPage.BasePageView.AddChidren(esp);
|
esp.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
|
if (sensor.functionType != FunctionType.Noise && sensor.functionType != FunctionType.WindPower)
|
{
|
var btnInfoIcon = new Button()
|
{
|
X = Application.GetRealWidth(120),
|
Width = Application.GetRealWidth(28),
|
Height = Application.GetRealWidth(28),
|
UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/TipInfoIcon.png",
|
};
|
sensorView.AddChidren(btnInfoIcon);
|
btnInfoIcon.MouseUpEventHandler = (sender, e) =>
|
{
|
LoadInfo( sensor);
|
};
|
}
|
|
var btnSensorValues = new Button()
|
{
|
X = Application.GetRealWidth(72),
|
Y = Application.GetRealWidth(17),
|
Width = Application.GetRealWidth(70),
|
Height = Application.GetRealWidth(30),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
|
IsBold = true,
|
Text = sensor.values.ToString(),
|
};
|
sensorView.AddChidren(btnSensorValues);
|
|
var btnLevel = new Button()
|
{
|
X = Application.GetRealWidth(70),
|
Y = btnSensorValues.Bottom,
|
Width = Application.GetRealWidth(50),
|
Height = Application.GetRealWidth(18),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = sensor.levelColorList[sensor.curLevel - 1],
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
TextID = sensor.levelTextList[sensor.curLevel - 1]
|
};
|
sensorView.AddChidren(btnLevel);
|
|
|
|
|
index++;
|
}
|
}
|
|
#endregion
|
|
//LoadEventList();
|
LoadDialog_ChangeRoom();
|
|
new TopViewDiv(bodyView, Language.StringByID(StringId.EnvironmentalScience)).LoadTopView();
|
|
}
|
|
/// <summary>
|
/// 加载传感器等级相关信息
|
/// </summary>
|
/// <param name="btnInfo"></param>
|
/// <param name="sensor"></param>
|
void LoadInfo(Sensor sensor)
|
{
|
Dialog dialog = new Dialog();
|
|
FrameLayout dialogBodyView = new FrameLayout();
|
dialog.AddChidren(dialogBodyView);
|
dialogBodyView.MouseUpEventHandler = (sender, e) => {
|
dialog.Close();
|
};
|
|
VerticalScrolViewLayout infoView = new VerticalScrolViewLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(667 - 94 - (sensor.levelColorList.Count * 44) - 20),
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(94 + (sensor.levelColorList.Count * 44) + sensor.levelColorList.Count),
|
Radius = (uint)Application.GetRealWidth(12),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Animate = Animate.DownToUp,
|
ScrollEnabled = false
|
};
|
dialogBodyView.AddChidren(infoView);
|
|
Button btnTitle = new Button()
|
{
|
Height = Application.GetRealHeight(50),
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
IsBold = true,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextAlignment = TextAlignment.Center,
|
};
|
infoView.AddChidren(btnTitle);
|
|
switch(sensor.functionType)
|
{
|
case FunctionType.PM10:
|
btnTitle.Text = "PM1.0(ug/m²)";
|
break;
|
case FunctionType.PM25:
|
btnTitle.Text = "PM2.5(ug/m²)";
|
break;
|
case FunctionType.WindPower:
|
|
break;
|
case FunctionType.Noise:
|
|
break;
|
case FunctionType.Temp:
|
btnTitle.Text = Language.StringByID(StringId.Temp )+ "(°C)";
|
break;
|
case FunctionType.TVOC:
|
btnTitle.Text = "TVOC(PPM)";
|
break;
|
case FunctionType.CO2:
|
btnTitle.Text = "CO2(PPM)";
|
break;
|
case FunctionType.Humidity:
|
btnTitle.Text = Language.StringByID(StringId.Humidity) + "(%)";
|
break;
|
|
|
}
|
|
FrameLayout subTitleView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(44),
|
};
|
infoView.AddChidren(subTitleView);
|
|
subTitleView.AddChidren(new Button()
|
{
|
X = Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(100),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
IsBold = true,
|
TextID = StringId.IntervalValue,
|
});
|
|
|
subTitleView.AddChidren(new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(100),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
IsBold = true,
|
TextID = StringId.LevelSensor,
|
});
|
|
subTitleView.AddChidren(new Button()
|
{
|
X = Application.GetRealWidth(223),
|
Width = Application.GetRealWidth(100),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
IsBold = true,
|
TextID = StringId.ColorValue,
|
});
|
for (int index = 0; index < sensor.levelTextList.Count;index++)
|
{
|
infoView.AddChidren(new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(303),
|
Height = Application.GetRealWidth(1),
|
BackgroundColor = CSS_Color.DividingLineColor,
|
});
|
|
|
FrameLayout subInfoView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(44),
|
};
|
infoView.AddChidren(subInfoView);
|
|
subInfoView.AddChidren(new Button()
|
{
|
X = Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(100),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
IsBold = true,
|
Text = sensor.intervalValue[index]
|
});
|
|
|
subInfoView.AddChidren(new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(100),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
IsBold = true,
|
TextID =sensor.levelTextList[index]
|
});
|
|
subInfoView.AddChidren(new Button()
|
{
|
X = Application.GetRealWidth(285),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(38),
|
Height = Application.GetRealHeight(18),
|
Radius = (uint)Application.GetRealWidth(4),
|
BackgroundColor = sensor.levelColorList[index]
|
});
|
|
}
|
|
|
|
|
dialog.Show();
|
|
}
|
|
|
|
/// <summary>
|
/// 房间列表点击事件
|
/// </summary>
|
void LoadDialog_ChangeRoom()
|
{
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
|
var dialog = new Dialog();
|
var dialogBody = new FrameLayout();
|
dialog.AddChidren(dialogBody);
|
dialogBody.MouseUpEventHandler += (sender1, e1) => {
|
dialog.Close();
|
};
|
|
var dispalyView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(10),
|
Y = Application.GetRealHeight(266),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealHeight(203),
|
BackgroundImagePath = "PersonalCenter/HomeListbg.png",
|
};
|
dialogBody.AddChidren(dispalyView);
|
|
var contentView = new VerticalScrolViewLayout()
|
{
|
X = Application.GetRealWidth(8),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(45 * 4),
|
};
|
dispalyView.AddChidren(contentView);
|
|
|
foreach (var roomTemp in DB_ResidenceData.residenceData.rooms)
|
{
|
string roomName = roomTemp.name;
|
var btnRoomName = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(112),
|
Height = Application.GetRealHeight(44),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS.CSS_Color.FirstLevelTitleColor,
|
SelectedTextColor = CSS.CSS_Color.MainColor,
|
Text = roomName,
|
TextSize = CSS.CSS_FontSize.SubheadingFontSize,
|
IsSelected = btnRoom.Text == roomName,
|
IsMoreLines = true,
|
Tag = roomName
|
};
|
contentView.AddChidren(btnRoomName);
|
|
btnRoomName.MouseUpEventHandler += (senderH, en) =>
|
{
|
dialog.Close();
|
btnRoom.Text = roomName;
|
room = roomTemp;
|
};
|
}
|
|
dialog.Show();
|
};
|
|
btnRoom.MouseUpEventHandler = eventHandler;
|
btnFoorDownIcon.MouseUpEventHandler = eventHandler;
|
}
|
|
|
}
|
}
|