using System;
|
using System.Collections.Generic;
|
using Shared;
|
using Shared.Phone;
|
using Shared.R;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.Device.Logic
|
{
|
public class SelectedLogic : FrameLayout
|
{
|
public void Show (ZbGateway zbGateway)
|
{
|
UserView.HomePage.Instance.RemoveViewByTag ("Logic");
|
Tag = "Logic";
|
|
|
this.AddChidren (new Button {
|
Height = Application.GetRealHeight (30),
|
BackgroundColor = 0xFF1f1f1f,
|
});
|
|
var topFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (30),
|
BackgroundColor = 0xFF1F1F1F,
|
};
|
AddChidren (topFrameLayout);
|
|
var hdl = new Button {
|
Width = Application.GetRealWidth (104),
|
Height = Application.GetRealHeight (32),
|
X = Application.GetRealWidth (530),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Logo/Logo.png",
|
};
|
//if (superGateWay.Tag != "LogicEdit") {
|
// topFrameLayout.AddChidren (hdl);
|
//}
|
|
var titleName = new Button {
|
//Text = "时间条件",
|
TextID = MyInternationalizationString.Timecondition,
|
TextSize = 17,
|
IsBold = true,
|
};
|
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",
|
};
|
//if (logicedit.Tag == "true") {
|
// topFrameLayout.AddChidren (back);
|
//}
|
back.MouseDownEventHandler += (sender, e) => {
|
RemoveFromParent ();
|
|
};
|
|
var middle = new VerticalScrolViewLayout ();
|
middle.Y = topFrameLayout.Bottom;
|
middle.Height = Application.GetRealHeight (1136 - 130 - 80);
|
middle.BackgroundColor = 0xff2F2F2F;
|
this.AddChidren (middle);
|
|
var conditionRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff323232,
|
};
|
middle.AddChidren (conditionRowLayout);
|
///条件VerticalScrolViewLayout
|
var inputVerticalScrolViewLayout = new VerticalScrolViewLayout {
|
Height = 0,
|
BackgroundColor = 0xffffffff,
|
};
|
middle.AddChidren (inputVerticalScrolViewLayout);
|
conditionRowLayout.AddChidren (new Button {
|
Width = Application.GetRealWidth (200),
|
//Text = "条件",
|
TextID = MyInternationalizationString.condition,
|
TextSize = 16,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
Gravity = Gravity.CenterVertical,
|
});
|
|
var conditionadd = new Button {
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (58),
|
UnSelectedImagePath = "MusicIcon/add.png",
|
X = Application.GetRealWidth (525),
|
Gravity = Gravity.CenterVertical,
|
};
|
conditionRowLayout.AddChidren (conditionadd);
|
|
#region -----显示逻辑条件-----
|
//inputVerticalScrolViewLayout.Height = Application.GetRealHeight (100 * (logicedit.input.Count + logicedit.time.Count));
|
//for (int i = 0; i < logicedit.time.Count; i++) {
|
// var s = logicedit.time [i];
|
// var timerowLayout = new RowLayout {
|
// Height = Application.GetRealHeight (100),
|
// BackgroundColor = 0xff505050,
|
// };
|
// inputVerticalScrolViewLayout.AddChidren (timerowLayout);
|
|
// ///显示时间
|
// var timevalue = new Button {
|
// X = Application.GetRealWidth (40),
|
// Width = Application.GetRealWidth (300),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Gravity = Gravity.CenterVertical,
|
// Text = s,
|
// //TextColor = 0xff121212,
|
// };
|
// timerowLayout.AddChidren (timevalue);
|
|
//}
|
|
//foreach (var deviceinput in logicedit.input) {
|
// if (deviceinput.sid == null || deviceinput.sid == "") {
|
// continue;
|
// }
|
// var tempSid = deviceinput.sid;
|
// //判断SID是否有效的,如果不是有效的当前这个场景数据就不处理
|
// Convert.ToUInt64 (tempSid, 16);
|
// var sidUlong = Convert.ToUInt64 (tempSid, 16);
|
// ///1:设备;2:场景;3:逻辑;
|
// var type = (byte)((sidUlong >> 60) & 0xF);
|
// var statevalue = deviceinput.value.ToString ();
|
|
// var inputrowLayout = new RowLayout {
|
// Height = Application.GetRealHeight (100),
|
// BackgroundColor = 0xff505050,
|
// };
|
// inputVerticalScrolViewLayout.AddChidren (inputrowLayout);
|
|
// ///显示设备名称
|
// var devicename = new Button {
|
// X = Application.GetRealWidth (40),
|
// Width = Application.GetRealWidth (300),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Gravity = Gravity.CenterVertical,
|
// //TextColor = 0xff121212,
|
// };
|
// inputrowLayout.AddChidren (devicename);
|
|
// ///显示设备条件状态控件
|
// var devicestatus = new Button {
|
// Width = Application.GetRealWidth (130),
|
// Height = Application.GetRealHeight (100),
|
// Gravity = Gravity.CenterVertical,
|
// //TextColor = 0xff121212,
|
// X = Application.GetRealWidth (500),
|
// };
|
// inputrowLayout.AddChidren (devicestatus);
|
|
// switch (type) {
|
// case 1: {
|
// var subnetId = (byte)((sidUlong >> 40) & 0xFF);
|
// var deviceId = (byte)((sidUlong >> 32) & 0xFF);
|
// var targetType = (byte)((sidUlong >> 24) & 0xFF);
|
// var property = (byte)((sidUlong >> 16) & 0xFF);
|
// var targetNumber = (uint)((sidUlong >> 0) & 0xFFFF);
|
// ///用来判断为条件,查找当前设备;
|
// var commonLoopID = subnetId + "_" + deviceId + "_" + targetNumber;
|
// var Type = Logic.devicetype (targetType, property);
|
|
// var commonDevice = superGateWay.Commons.Find ((obj) => obj.Type.ToString () == Type && obj.CommonLoopID == commonLoopID);
|
// if (commonDevice == null) {
|
// continue;
|
// }
|
// devicename.Text = commonDevice.Name;
|
|
// try {
|
// switch (commonDevice.Type) {
|
// case DeviceType.CurtainModel: {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
// }
|
// break;
|
// case DeviceType.CurtainRoller: {
|
// devicestatus.Text = statevalue + "%";
|
// }
|
// break;
|
// case DeviceType.LightDimming: {
|
// devicestatus.Text = statevalue + "%";
|
// }
|
// break;
|
// case DeviceType.LightSwitch: {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
|
// }
|
// break;
|
// case DeviceType.HVAC: {
|
|
// if (property == 0) {
|
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
|
// } else if (property == 1) {
|
// if (statevalue == "0") {
|
// //制冷
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.Cool);
|
// } else if (statevalue == "1") {
|
// //制热
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.Hot);
|
// } else if (statevalue == "2") {
|
// //通风
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.Ventila);
|
// } else if (statevalue == "3") {
|
// //自动
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.Auto);
|
// } else if (statevalue == "4") {
|
// //抽湿
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.Dehumidify);
|
// }
|
// } else if (property == 3) {
|
// //空调温度
|
// devicestatus.Text = statevalue + "%";
|
// } else if (property == 5) {
|
// //环境温度
|
// devicestatus.Text = statevalue + "%";
|
// }
|
// }
|
// break;
|
// case DeviceType.FoolHeat: {
|
// if (property == 0) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
// } else if (property == 2) {
|
// devicestatus.Text = statevalue + "℃";
|
// }
|
// }
|
// break;
|
// case DeviceType.FreshAir: {
|
// if (property == 0) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
// } else if (property == 1) {
|
// if (statevalue == "0") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.Smart);
|
// } else if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.FreshAir);
|
// } else if (statevalue == "2") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.InternalCirculation);
|
// } else if (statevalue == "3") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.ConstantTemp);
|
// }
|
// }
|
// }
|
// break;
|
// case DeviceType.MechanicalSwitch: {
|
// if (property == 0) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
// }
|
// }
|
// break;
|
// case DeviceType.AutomaticSwitch: {
|
// if (property == 1) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.singleclick);
|
// } else if (statevalue == "2") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.longpress);
|
// } else if (statevalue == "3") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.longpressrelease);
|
// } else if (statevalue == "4") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.doubleclick);
|
// }
|
// }
|
// }
|
// break;
|
// case DeviceType.DryContact: {
|
// if (property == 0) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
// }
|
// }
|
// break;
|
// case DeviceType.MusicModel: {
|
// if (property == 0) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.play);
|
// } else if (statevalue == "2") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.pause);
|
// }
|
// } else if (property == 1) {
|
// //devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// devicestatus.Text = statevalue + "%";
|
// }
|
// }
|
// break;
|
// case DeviceType.DoorLock: {
|
// if (property == 0) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
// }
|
// } else if (property == 1) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.low);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.normal);
|
// }
|
// } else if (property == 2) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.trigger);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.nontrigger);
|
// }
|
// }
|
// }
|
// break;
|
// case DeviceType.DoorLockID: {
|
// if (property == 0) {
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.trigger);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.nontrigger);
|
// }
|
// }
|
// }
|
// break;
|
// case DeviceType.Sensor: {
|
// if (property == 0) {
|
// devicestatus.Text = statevalue + "℃";
|
// } else if (property == 1) {
|
// devicestatus.Text = statevalue + "%";
|
// } else if (property == 5) {
|
// int intvalue = 90;
|
// intvalue = int.Parse (statevalue);
|
// if (0 <= intvalue && intvalue < 60) {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.difference);
|
// } else if (60 <= intvalue && intvalue < 75) {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.middle);
|
// } else if (75 <= intvalue && intvalue <= 100) {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.excellent);
|
// }
|
// } else if (property == 10) {
|
// int intvalue = 90;
|
// intvalue = int.Parse (statevalue);
|
// if (0 <= intvalue && intvalue < 60) {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.difference);
|
// } else if (60 <= intvalue && intvalue < 75) {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.middle);
|
// } else if (75 <= intvalue && intvalue <= 100) {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.excellent);
|
// }
|
// }
|
// }
|
// break;
|
// }
|
// } catch { }
|
|
// }
|
// break;
|
// case 3: {
|
// var logic = superGateWay.Logics.Find ((obj) => obj.sid == tempSid);
|
// if (logic == null) {
|
// continue;
|
// }
|
// devicename.Text = logic.name;
|
// if (statevalue == "1") {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.open1);
|
// } else {
|
// devicestatus.Text = Language.StringByID (MyInternationalizationString.disable);
|
// }
|
|
// }
|
// break;
|
|
// }
|
|
//}
|
#endregion
|
|
var targetRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff323232,
|
};
|
middle.AddChidren (targetRowLayout);
|
///目标targetVerticalScrolViewLayout
|
var targetVerticalScrolViewLayout = new VerticalScrolViewLayout {
|
Height = 0,
|
BackgroundColor = 0xffffffff,
|
};
|
middle.AddChidren (targetVerticalScrolViewLayout);
|
|
var btntargettitle = new Button {
|
// Text = "执行目标",
|
TextSize = 16,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
Gravity = Gravity.CenterVertical,
|
TextID = MyInternationalizationString.Implementationgoals,
|
};
|
targetRowLayout.AddChidren (btntargettitle);
|
|
var btntargetadd = new Button {
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (58),
|
UnSelectedImagePath = "MusicIcon/add.png",
|
X = Application.GetRealWidth (525),
|
Gravity = Gravity.CenterVertical,
|
};
|
targetRowLayout.AddChidren (btntargetadd);
|
|
#region ----显示执行目标----
|
//foreach (var deviceoutput in logicedit.output) {
|
// targetVerticalScrolViewLayout.Height = Application.GetRealHeight (100 * deviceoutput.objects.Count);
|
// foreach (var device in deviceoutput.objects) {
|
// if (!device.ContainsKey ("sid")) {
|
// continue;
|
// }
|
// var tempSid = device ["sid"]?.ToString ();
|
// if (tempSid == "") {
|
// continue;
|
// }
|
// //判断SID是否有效的,如果不是有效的当前这个场景数据就不处理
|
// Convert.ToUInt64 (tempSid, 16);
|
// var sidUlong = Convert.ToUInt64 (tempSid, 16);
|
// ///1:设备;2:场景;3:逻辑;
|
// var type = (byte)((sidUlong >> 60) & 0xF);
|
// string delay = "";
|
// string statevalue = "";
|
// if (device.ContainsKey ("value")) {
|
// statevalue = device ["value"]?.ToString ();
|
// }
|
// if (device.ContainsKey ("delay")) {
|
// delay = device ["delay"]?.ToString ();
|
// }
|
|
// var inputrowLayout = new RowLayout {
|
// Height = Application.GetRealHeight (100),
|
// BackgroundColor = 0xff505050,
|
// };
|
// targetVerticalScrolViewLayout.AddChidren (inputrowLayout);
|
|
// var devicename = new Button {
|
// // Text = device.Name,
|
// X = Application.GetRealWidth (40),
|
// Width = Application.GetRealWidth (300),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Gravity = Gravity.CenterVertical,
|
// //TextColor = 0xff121212,
|
// };
|
// inputrowLayout.AddChidren (devicename);
|
|
// var btndelay = new Button {
|
// Width = Application.GetRealWidth (150),
|
// Height = Application.GetRealHeight (50),
|
// X = Application.GetRealWidth (300),
|
// Y = Application.GetRealHeight (25),
|
// TextAlignment = TextAlignment.Center,
|
// TextColor = 0xffcccccc,
|
// };
|
// inputrowLayout.AddChidren (btndelay);
|
|
|
|
|
// if (delay != "" && delay != "0") {
|
// var l = int.Parse (delay) / 10;
|
// btndelay.Text = l.ToString () + "s";
|
// }
|
|
// ///显示设备状态控件
|
// var devicestatus = new Button {
|
// Width = Application.GetRealWidth (130),
|
// Height = Application.GetRealHeight (100),
|
// Gravity = Gravity.CenterVertical,
|
// //TextColor = 0xff121212,
|
// X = Application.GetRealWidth (500),
|
// };
|
// inputrowLayout.AddChidren (devicestatus);
|
|
|
// }
|
|
//}
|
#endregion
|
|
var cyclerowlayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff323232,
|
};
|
middle.AddChidren (cyclerowlayout);
|
///执行周期
|
var btncycle = new Button {
|
TextSize = 16,
|
//Text = "执行周期",
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (210),
|
Gravity = Gravity.CenterVertical,
|
TextID = MyInternationalizationString.cycle
|
};
|
cyclerowlayout.AddChidren (btncycle);
|
///显示周期时间
|
var btndisplaycycle = new Button {
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (250),
|
Width = Application.GetRealWidth (300),
|
Gravity = Gravity.CenterVertical,
|
};
|
cyclerowlayout.AddChidren (btndisplaycycle);
|
///更新周期的方法
|
|
var btncycleback = new Button {
|
Width = Application.GetRealWidth (87),
|
Height = Application.GetRealHeight (100),
|
UnSelectedImagePath = "MusicIcon/Next.png",
|
SelectedImagePath = "MusicIcon/NextSelecte.png",
|
X = Application.GetRealWidth (525),//550
|
};
|
cyclerowlayout.AddChidren (btncycleback);
|
|
var btncomplete = new Button {
|
Height = Application.GetRealHeight (80),
|
Y = middle.Bottom,
|
TextID = MyInternationalizationString.complete,
|
TextSize = 16,
|
BackgroundColor = 0xff1f1f1f,
|
};
|
AddChidren (btncomplete);
|
btncomplete.MouseUpEventHandler += (sender, e) => {
|
var logicCommunalPage = new LogicCommunalPage ();
|
UserView.HomePage.Instance.AddChidren (logicCommunalPage);
|
logicCommunalPage.Show (() => { });
|
|
};
|
|
}
|
|
|
}
|
}
|