using System;
using System.Collections.Generic;
using Shared.Common;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DoorLock
{
public class DoorLockListPage : FrameLayout, ZigBee.Common.IStatus
{
///
/// 按键模式接收
///
/// Common.
public void Changed(CommonDevice common)
{
//if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch)
//{
// return;
//}
Shared.Application.RunOnMainThread(() =>
{
//var dev = common as Panel;
});
}
#region 变量声明
///
/// 列表控件
///
private VerticalScrolViewLayout listView = null;
///
/// 门锁设备列表
///
private List localDoorLocklist = new List();
#endregion
///
/// 界面加载
///
public void Show()
{
#region topFrameLayout (只有UI,无数据处理)
var topFrameLayout = new FrameLayout()
{
Height = Application.GetRealHeight(220),
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor,
};
this.AddChidren(topFrameLayout);
var titleFrameLayout = new FrameLayout()
{
Y = Application.GetRealHeight(80),
Height = Application.GetRealHeight(140),
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor,
};
topFrameLayout.AddChidren(titleFrameLayout);
var title = new Button()
{
TextAlignment = TextAlignment.Center,
Text = Language.StringByID(R.MyInternationalizationString.DoorLock),
TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor,
Width = Application.GetRealWidth(1080 - 500),
Gravity = Gravity.CenterHorizontal,
};
titleFrameLayout.AddChidren(title);
var back = new Button()
{
X = Application.GetRealWidth(50),
Height = Application.GetRealHeight(100),
Width = Application.GetRealWidth(100),
UnSelectedImagePath = "Item/Back.png",
SelectedImagePath = "Item/BackOn.png",
Gravity = Gravity.CenterVertical,
};
titleFrameLayout.AddChidren(back);
#endregion
#region midFrameLayout
var midFrameLayout = new FrameLayout()
{
Width = LayoutParams.MatchParent,
Height = Application.GetRealHeight(1920 - 220),
Y = topFrameLayout.Bottom,
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCBackgroundColor,
};
this.AddChidren(midFrameLayout);
listView = new VerticalScrolViewLayout();
midFrameLayout.AddChidren(listView);
#endregion
#region 数据信息处理
listView.RemoveAll();
localDoorLocklist.Clear();
//foreach (var dev in Shared.Common.LocalDevice.Current.listAllDevice)
//{
// if(dev.Type ==ZigBee.Device.DeviceType.DoorLock)
// {
// localDoorLocklist.Add(dev);
// }
//}
//测试代码
for (int i = 0; i < 3; i++)
{
var tempDoorLock = new ZigBee.Device.DoorLock();
localDoorLocklist.Add(tempDoorLock);
}
foreach (var doorLock in localDoorLocklist)
{
this.AddDoorLockRow(doorLock);
}
#endregion
}
///
/// 添加设备的菜单行
///
/// 设备对象
private void AddDoorLockRow(ZigBee.Device.CommonDevice doorLock)
{
var doorLockView = new RowLayout()
{
Height = Application.GetRealHeight(180),
};
listView.AddChidren(doorLockView);
var btnPoint = new Button()
{
Width = Application.GetRealWidth(10),
Height = Application.GetRealHeight(10),
X = Application.GetRealWidth(40),
Gravity = Gravity.CenterVertical,
//UnSelectedImagePath = "Item/Point.png",
//SelectedImagePath = "Item/Point.png",
};
doorLockView.AddChidren(btnPoint);
var tempDeviceName = new Button()
{
Width = Application.GetRealWidth(340),
X = btnPoint.Right + Application.GetRealWidth(20),
TextAlignment = TextAlignment.CenterLeft,
Text = "门锁1",
TextColor = 0xff000000,
Tag = doorLock,
};
doorLockView.AddChidren(tempDeviceName);
var btnRight = new Button()
{
Height = Application.GetRealHeight(110),
Width = Application.GetRealWidth(110),
UnSelectedImagePath = "Item/Next.png",
SelectedImagePath = "Item/Down.png",
Gravity = Gravity.CenterVertical,
X = Application.CurrentWidth - Application.GetRealWidth(150),
};
doorLockView.AddChidren(btnRight);
EventHandler openDoorLockControlPageEvent = (button, mouseEventArgs) =>
{
//var doorLockManagement = new Shared.Phone.UserCenter.DoorLock.DoorLockManagement();
//Shared.Phone.UserView.HomePage.Instance.AddChidren(doorLockManagement);
//Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
//doorLockManagement.Show();
};
doorLockView.MouseUpEventHandler += openDoorLockControlPageEvent;
tempDeviceName.MouseUpEventHandler += openDoorLockControlPageEvent;
btnRight.MouseUpEventHandler += openDoorLockControlPageEvent;
}
public void DeviceInfoChange(CommonDevice common, string typeTag)
{
}
public void ChangedILogicStatus(ZigBee.Device.Logic logic)
{
}
public void ChangedISceneStatus(Scene scene)
{
}
}
}