using System;
|
using System.Collections.Generic;
|
using Newtonsoft.Json.Linq;
|
using Shared;
|
using Shared.Common;
|
using Shared.Phone;
|
using Shared.R;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.Device.Logic
|
{
|
public class AddScenePage : FrameLayout
|
{
|
|
Button roomname;
|
public AddScenePage()
|
{
|
Tag = "Logic";
|
}
|
public void Show()
|
{
|
this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
|
|
var topFrameLayout = new FrameLayout
|
{
|
Height = Application.GetRealHeight(220),
|
Y = Application.GetRealHeight(80),
|
};
|
|
AddChidren(topFrameLayout);
|
|
var titleName = new Button
|
{
|
//Text = "添加场景",
|
TextID = MyInternationalizationString.addscene,
|
TextSize = 17,
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth(150),
|
};
|
topFrameLayout.AddChidren(titleName);
|
|
var back = new Button
|
{
|
Width = Application.GetRealWidth(110),
|
Height = Application.GetRealHeight(110),
|
X = Application.GetRealWidth(20),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "ZigeeLogic/Back.png",
|
};
|
topFrameLayout.AddChidren(back);
|
back.MouseDownEventHandler += (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
|
roomname = new Button
|
{
|
Width = Application.GetMinRealAverage(300 + 300),
|
Height = Application.GetMinRealAverage(80),
|
X = Application.GetRealWidth(1080 - 300 - 30 - 300),
|
Y = Application.GetRealHeight(120),
|
TextAlignment = TextAlignment.CenterRight,
|
//Text = "自定义房间",
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
TextID=MyInternationalizationString.customroom,
|
};
|
topFrameLayout.AddChidren(roomname);
|
|
var middle = new VerticalScrolViewLayout();
|
middle.Y = topFrameLayout.Bottom;
|
middle.Height = Application.GetRealHeight(1920 - 300);
|
middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
this.AddChidren(middle);
|
|
roomname.MouseUpEventHandler += (sender, e) =>
|
{
|
var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
|
this.AddChidren(flMain);
|
flMain.MouseUpEventHandler += (sender2, e2) =>
|
{
|
flMain.RemoveFromParent();
|
};
|
var roombj = new VerticalScrolViewLayout
|
{
|
|
Width = Application.GetRealWidth(400),
|
Height = Application.GetRealHeight(600),
|
X = Application.GetRealWidth(1080 - 400 - 60),
|
Y = Application.GetRealHeight(220 + 30 + 80),
|
BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
|
Radius = (uint)Application.GetRealHeight(30),
|
};
|
flMain.AddChidren(roombj);
|
List<Common.Room> roomlist = new List<Common.Room>();
|
roomlist.Clear();
|
Common.Room customroom = new Common.Room();
|
//虚拟一个房间加载本地所有场景;
|
customroom.SceneUIList.AddRange(Common.Room.AllRoomSceneUIList);
|
customroom.Name =Language.StringByID(MyInternationalizationString.customroom);
|
roomlist.Add(customroom);
|
roomlist.AddRange(Common.Room.Lists);
|
foreach (var room in roomlist)
|
{
|
var rowLayout = new RowLayout
|
{
|
Height = Application.GetRealHeight(150),
|
};
|
roombj.AddChidren(rowLayout);
|
|
var btnroomname = new Button
|
{
|
Width = Application.GetRealWidth(300),
|
Text = room.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth(30),
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
};
|
rowLayout.AddChidren(btnroomname);
|
|
EventHandler<MouseEventArgs> roomclick = (sender1, e1) =>
|
{
|
|
flMain.RemoveFromParent();
|
roomname.Text = room.Name;
|
SceneView(middle, room.SceneUIList);
|
|
};
|
rowLayout.MouseUpEventHandler += roomclick;
|
btnroomname.MouseUpEventHandler += roomclick;
|
|
}
|
|
};
|
|
SceneView(middle,Common.Room.AllRoomSceneUIList);
|
|
}
|
|
|
void SceneView(VerticalScrolViewLayout middle,List<SceneUI>scenelist)
|
{
|
middle.RemoveAll();
|
foreach (var tempScene in scenelist)
|
{
|
var deviceRowLayout = new RowLayout
|
{
|
Height = Application.GetRealHeight(180),
|
};
|
middle.AddChidren(deviceRowLayout);
|
|
var btn = new Button
|
{
|
Height = Application.GetRealHeight(180),
|
Width = LayoutParams.MatchParent,
|
|
};
|
deviceRowLayout.AddChidren(btn);
|
|
var devicetypename = new Button
|
{
|
Width = Application.GetRealWidth(600),
|
Text = tempScene.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth(40),
|
//SelectedBackgroundColor = 0xfffe5e00,
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
};
|
deviceRowLayout.AddChidren(devicetypename);
|
|
EventHandler<MouseEventArgs> sceneclick = (sender, e) =>
|
{
|
Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
|
if (actionsInfo.ContainsKey("LinkType"))
|
{
|
actionsInfo.Remove("LinkType");
|
}
|
if (actionsInfo.ContainsKey("DeviceAddr"))
|
{
|
actionsInfo.Remove("DeviceAddr");
|
}
|
actionsInfo.Add("LinkType", 2);
|
actionsInfo.Add("DeviceAddr", tempScene.Id);
|
|
LogicIfon.AddSceneactions(tempScene,actionsInfo);
|
var logicCommunalPage = new LogicCommunalPage();
|
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
|
UserView.HomePage.Instance.PageIndex += 1;
|
logicCommunalPage.Show(() => { });
|
};
|
|
deviceRowLayout.MouseUpEventHandler += sceneclick;
|
btn.MouseUpEventHandler += sceneclick;
|
devicetypename.MouseUpEventHandler += sceneclick;
|
|
}
|
|
}
|
|
|
}
|
}
|