using System;
namespace Shared.SimpleControl.Pad
{
public class UserDeviceToTV : Dialog
{
VerticalScrolViewLayout RoomListScrolView;
///
/// 当前界面
///
public static UserDeviceToTV curView;
FrameLayout ControlBodyView;
public UserTVNumberView ControlNumberView;
public UserTVFrameLayout ControlTVView;
///
/// 构造函数
///
public UserDeviceToTV ()
{
curView = this;
showAllRoomTV ();
}
///
/// 显示房间的所有电视
///
void showAllRoomTV ()
{
FrameLayout topBackView = new FrameLayout () {
Height = Application.GetRealHeight (150),
BackgroundColor = 0xFF2f2f2f
};
AddChidren (topBackView);
#region 标题
var topView = new FrameLayout () {
Y = Application.GetRealHeight (36),
Height = Application.GetRealHeight (90),
};
AddChidren (topView);
var title = new Button () {
TextAlignment = TextAlignment.Center,
Text = Language.StringByID (R.MyInternationalizationString.TV),
TextSize = 19,
};
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 (100),
Width = Application.GetRealWidth (85),
UnSelectedImagePath = "Item/Back.png",
SelectedImagePath = "Item/BackSelected.png",
Gravity = Gravity.CenterVertical,
};
topView.AddChidren (back);
back.MouseUpEventHandler += (sender, e) => {
Close ();
curView = null;
};
var btnl = new Button () {
Height = 1,
BackgroundColor = 0xFF2f2f2f,
Y = topView.Height - 1
};
topView.AddChidren (btnl);
#endregion
FrameLayout bordorView = new FrameLayout () {
Width = Application.GetRealWidth (480),
Height = Application.GetRealHeight (Application.DesignHeight - 150),
Y = Application.GetRealHeight (150),
BackgroundColor = 0xFF2f2f2f
};
AddChidren (bordorView);
#region powerView
var powerView = new FrameLayout () {
Height = Application.GetRealHeight (110),
BackgroundColor = SkinStyle.Current.MainColor,
};
bordorView.AddChidren (powerView);
var showAllroom = new Button () {
Height = Application.GetRealHeight (108),
TextAlignment = TextAlignment.Center,
Text = " " + Language.StringByID (R.MyInternationalizationString.AllRoom),
};
powerView.AddChidren (showAllroom);
var btnLine1 = new Button () {
Height = 1,
Y = powerView.Height - 1,
BackgroundColor = 0xFF2f2f2f,
};
powerView.AddChidren (btnLine1);
var btnLine = new Button () {
Width = 1,
X = powerView.Width - 1,
BackgroundColor = 0xFF2f2f2f,
};
powerView.AddChidren (btnLine);
#endregion
RoomListScrolView = new VerticalScrolViewLayout () {
Width = LayoutParams.MatchParent,
Height = Application.GetRealHeight (1136 - 126 - 110),
Y = powerView.Bottom
};
bordorView.AddChidren (RoomListScrolView);
ControlBodyView = new FrameLayout () {
Width = Application.GetRealWidth (Application.DesignWidth) - bordorView.Width,
Height = Application.GetRealHeight (Application.DesignHeight - 150),
X = bordorView.Right,
Y = bordorView.Y,
BackgroundColor = SkinStyle.Current.MainColor
};
AddChidren (ControlBodyView);
//显示有多少个房间
int devcieCount = 0;
foreach (var room in Room.Lists) {
if (room.Name == "") {
continue;
}
var infraredList = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.InfraredMode; });
var tvList = infraredList.FindAll ((obj) => { return ((InfraredMode)obj).InfraredType == InfraredType.TV; });
foreach (var tempTV in tvList) {
EventHandler openTVControlPageEvent = (button, mouseEventArgs) => {
for (int i = 0; i < RoomListScrolView.ChildrenCount; i++) {
var view = RoomListScrolView.GetChildren (i);
if (view.Tag == tempTV) {
for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++) {
var btn = (view as FrameLayout).GetChildren (j);
(btn as Button).IsSelected = true;
}
} else {
for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++) {
var btn = (view as FrameLayout).GetChildren (j);
(btn as Button).IsSelected = false;
}
}
}
ControlBodyView.RemoveAll ();
ControlNumberView = new UserTVNumberView () {
Width = Application.GetRealWidth (1000),
};
ControlBodyView.AddChidren (ControlNumberView);
ControlNumberView.Show (room, (InfraredMode)tempTV);
ControlTVView = new UserTVFrameLayout ((InfraredMode)tempTV) {
X = Application.GetRealWidth (1000),
Width = Application.GetRealWidth (Application.DesignWidth - 480 - 1000)
};
ControlBodyView.AddChidren (ControlTVView);
ControlTVView.ShowUserTV (tempTV as InfraredMode);
};
FrameLayout roomView = new FrameLayout () {
Height = Application.GetRealHeight (140),
BackgroundColor = 0xFF2f2f2f,
Tag = room.Name + "-" + tempTV.Name,
};
RoomListScrolView.AddChidren (roomView);
roomView.Tag = tempTV;
Button btnRoomName = new Button () {
Text = room.Name + "-" + tempTV.Name,
Padding = new Padding (0, 35, 0, 0),
TextAlignment = TextAlignment.CenterLeft,
SelectedTextColor = SkinStyle.Current.SelectedColor,
TextColor = SkinStyle.Current.TextColor1,
BackgroundColor = SkinStyle.Current.Transparent,
SelectedBackgroundColor = SkinStyle.Current.MainColor
};
roomView.AddChidren (btnRoomName);
var btnPoint = new Button () {
Width = Application.GetRealWidth (15),
Height = Application.GetRealHeight (15),
X = Application.GetRealWidth (45),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "Item/Point.png",
SelectedImagePath = "Item/PointSelected.png",
};
roomView.AddChidren (btnPoint);
Button btnNull = new Button () {
Height = Application.GetRealHeight (5),
Y = Application.GetRealHeight (138),
BackgroundColor = SkinStyle.Current.MainColor,
};
roomView.AddChidren (btnNull);
Button btnNull2 = new Button () {
Width = 1,
X = roomView.Width - 1,
BackgroundColor = 0xFF2f2f2f,
};
roomView.AddChidren (btnNull2);
Button btnSelected = new Button () {
X = roomView.Width - 5,
Width = 5,
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
BackgroundColor = SkinStyle.Current.Transparent,
};
roomView.AddChidren (btnSelected);
btnRoomName.MouseUpEventHandler += openTVControlPageEvent;
if (devcieCount == 0) {
ControlNumberView = new UserTVNumberView () {
Width = Application.GetRealWidth (1000),
BackgroundColor = 0xFF333333
};
ControlBodyView.AddChidren (ControlNumberView);
ControlNumberView.Show (room, (InfraredMode)tempTV);
ControlTVView = new UserTVFrameLayout ((InfraredMode)tempTV) {
X = Application.GetRealWidth (1020),
Width = Application.GetRealWidth (Application.DesignWidth - 480 - 1000 - 20),
BackgroundColor = 0xFF333333
};
ControlBodyView.AddChidren (ControlTVView);
ControlTVView.ShowUserTV (tempTV as InfraredMode);
btnRoomName.IsSelected = true;
btnPoint.IsSelected = true;
btnSelected.IsSelected = true;
}
devcieCount++;
}
}
}
}
}