using System;
|
using System.Collections.Generic;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class UserDeviceToSensor : FrameLayout
|
{
|
VerticalScrolViewLayout bodyScrolView;
|
|
FrameLayout LongPressFrameLayout = new FrameLayout ();
|
Button beforeClickButton = new Button ();
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public UserDeviceToSensor ()
|
{
|
BackgroundColor = SkinStyle.Current.MainColor;
|
curView = this;
|
}
|
|
static UserDeviceToSensor curView;
|
public static bool hasModify = false;
|
public static void Refresh ()
|
{
|
if (curView == null)
|
return;
|
if (hasModify) {
|
curView.ShowAllSensor ();
|
hasModify = false;
|
}
|
}
|
|
/// <summary>
|
/// 显示房间的所有场景
|
/// </summary>
|
public void ShowAllSensor ()
|
{
|
this.RemoveAll ();
|
#region 标题
|
var topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
};
|
AddChidren (topView);
|
|
var title = new Button () {
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Environmental,
|
TextSize = 19,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
topView.AddChidren (title);
|
|
var logo = new Button () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (logo);
|
var back = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
(Parent as PageLayout).PageIndex -= 1;
|
curView = null;
|
};
|
#endregion
|
|
var bodyView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (Application.DesignHeight - 126),
|
Y = Application.GetRealHeight(126),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
AddChidren (bodyView);
|
bodyScrolView = new VerticalScrolViewLayout ();
|
bodyView.AddChidren (bodyScrolView);
|
|
InitView ();
|
}
|
|
void InitView ()
|
{
|
bodyScrolView.RemoveAll ();
|
|
List<string> sensorPaths = new List<string> ();
|
//List<string> localFileList = IO.FileUtils.ReadFiles ();
|
//sensorPaths = localFileList.FindAll ((obj) => { return obj.Split ('_') [0] == "Equipment" && obj.Split ('_').Length == 4 && obj.Contains ("Sensor"); });
|
|
foreach (var room in Room.Lists) {
|
if (room == null || string.IsNullOrEmpty (room.Name))
|
continue;
|
var sensor = room.DeviceList.FindAll ((obj) => obj.Type.ToString ().Contains (DeviceType.Sensor.ToString ()));
|
if(sensor == null || sensor.Count == 0){
|
continue;
|
}
|
var rowView = new FrameLayout () {
|
Height = Application.GetRealHeight (130),
|
};
|
bodyScrolView.AddChidren (rowView);
|
|
var tempDeviceName = new Button () {
|
X = Application.GetRealWidth (40),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = room.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
Enable = false,
|
};
|
rowView.AddChidren (tempDeviceName);
|
|
Button rightButton = new Button () {
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
X = Application.GetRealWidth(580),
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
rowView.AddChidren (rightButton);
|
|
|
Button btnEnergyNull = new Button () {
|
Y = Application.GetRealHeight (127),
|
Height = Application.GetRealHeight (3),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.MainColor,
|
};
|
rowView.AddChidren (btnEnergyNull);
|
|
EventHandler<MouseEventArgs> clickEventHandler = (sender, e) => {
|
MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
UserSensorPage usp = new UserSensorPage ();
|
UserMiddle.DevicePageView.AddChidren (usp);
|
usp.ShowUserSensorPage (room);
|
UserMiddle.DevicePageView.PageIndex = 2;
|
});
|
}catch{}
|
finally{
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
|
rightButton.MouseUpEventHandler += clickEventHandler;
|
rowView.MouseUpEventHandler += clickEventHandler;
|
tempDeviceName.MouseUpEventHandler += clickEventHandler;
|
btnEnergyNull.MouseUpEventHandler += clickEventHandler;
|
Button btnllll = new Button ();
|
rowView.AddChidren (btnllll);
|
btnllll.MouseUpEventHandler += clickEventHandler;
|
//rowView.MouseUpEventHandler += (sender, e) => {
|
// UserSensorPage usp = new UserSensorPage ();
|
// UserMiddle.DevicePageView.AddChidren (usp);
|
// usp.ShowUserSensorPage (room);
|
// UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
//};
|
//tempDeviceName.MouseUpEventHandler += (sender, e) => {
|
// UserSensorPage usp = new UserSensorPage ();
|
// UserMiddle.DevicePageView.AddChidren (usp);
|
// usp.ShowUserSensorPage (room);
|
// UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
//};
|
//rightButton.MouseUpEventHandler += (sender, e) => {
|
// UserSensorPage usp = new UserSensorPage ();
|
// UserMiddle.DevicePageView.AddChidren (usp);
|
// usp.ShowUserSensorPage (room);
|
// UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
//};
|
}
|
}
|
}
|
}
|