using System;
|
using Shared;
|
using Shared.SimpleControl;
|
using Shared.SimpleControl.R;
|
namespace SuperGateWay
|
{
|
class SelectedLogicStatus:FrameLayout
|
{
|
public SelectedLogicStatus ()
|
{
|
Tag = "Logic";
|
}
|
public bool IsDeviceEditor;
|
public void Show (GateWay gateWay, Logic logic)
|
{
|
this.BackgroundColor = 0xFF1F1F1F;
|
this.AddChidren (new Button {
|
Height = Application.GetRealHeight (30),
|
});
|
|
var topFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (30),
|
};
|
AddChidren (topFrameLayout);
|
|
var titleName = new Button {
|
TextID = MyInternationalizationString.automation,
|
TextSize = 17,
|
};
|
topFrameLayout.AddChidren (titleName);
|
|
var back = new Button {
|
Width = Application.GetRealWidth (82),
|
Height = Application.GetRealHeight (89),
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/HomepageBack.png",
|
};
|
topFrameLayout.AddChidren (back);
|
back.MouseDownEventHandler += (sender, e) => {
|
RemoveFromParent ();
|
IsDeviceEditor = false;
|
};
|
|
var tetleframeLayout = new FrameLayout {
|
Y = topFrameLayout.Bottom,
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff0f0f0f,
|
};
|
AddChidren (tetleframeLayout);
|
|
var tetlebtn = new Button {
|
Width = Application.GetRealWidth (400),
|
TextID = MyInternationalizationString.selectsavedautomationstate,
|
//Text = "请选择已保存自动化",
|
TextSize = 16,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
};
|
tetleframeLayout.AddChidren (tetlebtn);
|
|
var middle = new VerticalScrolViewLayout ();
|
middle.Y = tetleframeLayout.Bottom;
|
middle.Height = Application.GetRealHeight (Application.DesignHeight - 130 - 100 - 80);
|
middle.BackgroundColor = 0xff2F2F2F;
|
this.AddChidren (middle);
|
|
|
Input inputifon = new Input ();
|
inputifon.compare = "=";
|
inputifon.sid = logic.sid;
|
Logic.CurrentLogic.AddInput (inputifon);
|
|
var openRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
};
|
middle.AddChidren (openRowLayout);
|
|
var btnlogicopen = new Button {
|
Width = Application.GetRealWidth (200),
|
TextID = MyInternationalizationString.open1,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
};
|
openRowLayout.AddChidren (btnlogicopen);
|
|
string IsselectedLogic = null;
|
var disableRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
};
|
middle.AddChidren (disableRowLayout);
|
|
var btnlogicdisable = new Button {
|
Width = Application.GetRealWidth (200),
|
TextID = MyInternationalizationString.disable,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
};
|
disableRowLayout.AddChidren (btnlogicdisable);
|
|
///开启点击事件
|
EventHandler<MouseEventArgs> copenclick = (seder, e) => {
|
openRowLayout.BackgroundColor = 0xfffe5e00;
|
disableRowLayout.BackgroundColor = 0x00000000;
|
IsselectedLogic = "true";
|
inputifon.value = 1;
|
};
|
openRowLayout.MouseUpEventHandler += copenclick;
|
btnlogicopen.MouseUpEventHandler += copenclick;
|
|
///禁止点击事件
|
EventHandler<MouseEventArgs> disableclick = (seder, e) => {
|
openRowLayout.BackgroundColor = 0x00000000;
|
disableRowLayout.BackgroundColor = 0xfffe5e00;
|
IsselectedLogic = "false";
|
inputifon.value = 0;
|
};
|
disableRowLayout.MouseUpEventHandler += disableclick;
|
btnlogicdisable.MouseUpEventHandler += disableclick;
|
|
if (IsDeviceEditor) {
|
foreach (var deviceinput in Logic.CurrentLogic.input) {
|
if (deviceinput.sid == null) {
|
continue;
|
}
|
var tempSid = deviceinput.sid;
|
//判断SID是否有效的,如果不是有效的当前这个场景数据就不处理
|
Convert.ToUInt64 (tempSid, 16);
|
var sidUlong = Convert.ToUInt64 (tempSid, 16);
|
|
var type = (byte)((sidUlong >> 60) & 0xF);
|
if (type == 3) {
|
if (logic.sid == tempSid) {
|
//Logic当前状态值
|
if (deviceinput.value.ToString () == "1") {
|
openRowLayout.BackgroundColor = 0xfffe5e00;
|
disableRowLayout.BackgroundColor = 0x00000000;
|
} else {
|
openRowLayout.BackgroundColor = 0x00000000;
|
disableRowLayout.BackgroundColor = 0xfffe5e00;
|
}
|
break;
|
}
|
}
|
|
}
|
}
|
|
var btncomplete = new Button {
|
Y = middle.Bottom,
|
Height = Application.GetRealHeight (80),
|
TextID = MyInternationalizationString.complete,
|
TextSize = 16,
|
};
|
AddChidren (btncomplete);
|
|
|
btncomplete.MouseUpEventHandler += (sedder, e) => {
|
if (Logic.CurrentLogic.input.Count == 8) {
|
new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.Morethan8), Language.StringByID (MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
|
if (IsselectedLogic != null) {
|
Logic.CurrentLogic.AddInput (inputifon);
|
} else {
|
if (!IsDeviceEditor) {
|
var alert = new Alert (Language.StringByID (MyInternationalizationString.Prompt),
|
Language.StringByID (MyInternationalizationString.selectlogiccondition),
|
Language.StringByID (MyInternationalizationString.OK)); alert.Show ();
|
return;
|
}
|
IsDeviceEditor = false;
|
}
|
var logicCommunalPage = new LogicCommunalPage ();
|
MainPage.MainFrameLayout.AddChidren (logicCommunalPage);
|
logicCommunalPage.Show (gateWay, () => { });
|
//var selectedLogic = new SelectedLogic ();
|
//MainPage.MainFrameLayout.AddChidren (selectedLogic);
|
//selectedLogic.Show (gateWay, logic);
|
};
|
}
|
}
|
}
|