using System;
|
using Shared.Common;
|
using Shared.R;
|
using Shared;
|
using ZigBee.Device;
|
using System.Collections.Generic;
|
namespace Shared.Phone.Device.Logic
|
{
|
public class CurrentDeviceState
|
{
|
/// <summary>
|
/// 选中该设备功能作为条件或者目标的视图方法
|
/// </summary>
|
/// <param name="common">Common.</param>
|
public static void CurrentDeviceView(FrameLayout flMain, CommonDevice common, bool edit, string str, int intValue)
|
{
|
#region -------界面布局部分
|
//不让当前界面滑动
|
UserView.HomePage.Instance.ScrollEnabled = false;
|
CompleteView completeView = new CompleteView();
|
flMain.AddChidren(completeView.Show(1));
|
completeView.Btntitle.Text = LocalDevice.Current.GetDeviceEpointName(common);
|
EventHandler<MouseEventArgs> clickcancel = (sender, e) =>
|
{
|
if (edit)
|
{
|
UserView.HomePage.Instance.ScrollEnabled = true;
|
}
|
flMain.RemoveFromParent();
|
};
|
flMain.MouseUpEventHandler += clickcancel;
|
completeView.Btncancel.MouseUpEventHandler += clickcancel;
|
|
mFunView openView = new mFunView();
|
openView.frameLayout.Y = Application.GetRealHeight(140 + 20);
|
openView.titleBtn.TextID = MyInternationalizationString.open;
|
|
mFunView closeView = new mFunView();
|
closeView.frameLayout.Y = Application.GetRealHeight(140 + 20 + 160);
|
closeView.titleBtn.TextID = MyInternationalizationString.close;
|
|
mFunView takebackView = new mFunView();
|
takebackView.frameLayout.Y = Application.GetRealHeight(140 + 20 + 160 + 160);
|
takebackView.titleBtn.TextID = MyInternationalizationString.onoff;
|
takebackView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
#region -------进度条控件
|
var horizontalSeekBarRowLien = new RowLayout
|
{
|
//Y = openView.frameLayout.Bottom,
|
Width = Application.GetRealWidth(915),
|
Height = Application.GetRealHeight(160),
|
X = Application.GetRealWidth(80),
|
LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
|
};
|
var horizontalSeekBarVol = new DiyImageSeekBar
|
{
|
//Y = openView.frameLayout.Bottom,//进度条父控件Y坐标
|
X = Application.GetRealWidth(80),//进度条X坐标
|
Width = Application.GetRealWidth(915),//进度条的长度
|
Height = Application.GetRealHeight(160),//进度条父控件高度
|
IsProgressTextShow = true,//显示百分比
|
IsClickable = false,//进度条是否滑动
|
ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected,//选中进度条颜色
|
ThumbImagePath = "ZigeeLogic/progressbtn2.png",//进度条按钮图标
|
ThumbImageHeight = Application.GetRealHeight(56),//进度条按钮图标的高度(默认正方形:宽和高一样)
|
ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor,
|
ProgressTextSize = 12,//显示百分比字体大小12
|
SeekBarViewHeight = Application.GetRealHeight(6),//进度条的高度10
|
SeekBarPadding = 30,
|
};
|
#endregion
|
#endregion
|
|
#region -------数据处理部分
|
#region -------条件
|
Dictionary<string, string> deviceConditionsInfo = new Dictionary<string, string>();
|
Send.dictionary(deviceConditionsInfo, "Type", "1");
|
Send.dictionary(deviceConditionsInfo, "IsValid", "1");
|
Send.dictionary(deviceConditionsInfo, "MacAddr", common.DeviceAddr);
|
Send.dictionary(deviceConditionsInfo, "Epoint", common.DeviceEpoint.ToString());
|
Dictionary<string, string> devices = null;
|
#endregion
|
#region -------目标
|
Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
|
List<Dictionary<string, string>> taskListInfo = new List<Dictionary<string, string>>();
|
actionsInfo.Add("LinkType", 0);
|
actionsInfo.Add("DeviceAddr", common.DeviceAddr);
|
actionsInfo.Add("Epoint", common.DeviceEpoint);
|
actionsInfo.Add("Time", 0);
|
actionsInfo.Add("TaskList", taskListInfo);
|
List<Dictionary<string, string>> TaskList = null;
|
#endregion
|
var _if = str.Split('_');
|
if (edit)
|
{
|
if (_if[0] == "condition")
|
{
|
var deviceinfo = Common.Logic.CurrentLogic.Conditions[intValue];
|
if (deviceinfo["Type"] == "1")
|
{
|
if (common.DeviceAddr == deviceinfo["MacAddr"] && common.DeviceEpoint.ToString() == deviceinfo["Epoint"])
|
{
|
devices = deviceinfo;
|
|
}
|
}
|
}
|
else
|
{
|
var deviceinfo = Common.Logic.CurrentLogic.Actions[intValue];
|
if (deviceinfo["LinkType"].ToString() == "0")
|
{
|
|
if (deviceinfo["DeviceAddr"].ToString() == common.DeviceAddr && deviceinfo["Epoint"].ToString() == common.DeviceEpoint.ToString())
|
{
|
TaskList = deviceinfo["TaskList"] as List<Dictionary<string, string>>;
|
}
|
}
|
|
}
|
}
|
#endregion
|
int l = 0;
|
string SelectedDeviceStatus = "";
|
switch (common.Type)
|
{
|
///灯光
|
case DeviceType.OnOffOutput:
|
{
|
|
if (_if[0] == "condition")
|
{
|
l = 2;
|
Send.dictionary(deviceConditionsInfo, "Cluster_ID", "6");
|
Send.dictionary(deviceConditionsInfo, "AttriButeId", "0");
|
Send.dictionary(deviceConditionsInfo, "Range", "1");
|
Send.dictionary(deviceConditionsInfo, "AttriButeData2", "0");
|
|
#region 灯光View
|
completeView.Show(l).AddChidren(openView.Show());
|
completeView.Show(l).AddChidren(closeView.Show());
|
closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
#endregion
|
|
///点击确认事件
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
SelectedDeviceStatus = "OnOffOutput";
|
Send.dictionary(deviceConditionsInfo, "AttriButeData1", "1");//默认值
|
|
|
};
|
|
///点击取消事件
|
closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
SelectedDeviceStatus = "OnOffOutput";
|
Send.dictionary(deviceConditionsInfo, "AttriButeData1", "0");//默认值
|
|
};
|
|
if (edit && devices != null)
|
{
|
if (devices["AttriButeId"] == "0")
|
{
|
if (devices["AttriButeData1"] == "1")
|
{
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
}
|
else
|
{
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
|
}
|
}
|
}
|
}
|
else
|
{
|
l = 3;
|
#region ----初始化设备功能数据----
|
Dictionary<string, string> switchdictionary = new Dictionary<string, string>();
|
Send.dictionary(switchdictionary, "TaskType", "1");
|
Send.dictionary(switchdictionary, "Data1", "0");
|
Send.dictionary(switchdictionary, "Data2", "0");
|
taskListInfo.Add(switchdictionary);
|
|
#endregion
|
|
#region 灯光View
|
|
completeView.Show(l).AddChidren(openView.Show());
|
completeView.Show(l).AddChidren(closeView.Show());
|
//closeView.frameLayout.Y = openView.frameLayout.Bottom;
|
completeView.Show(l).AddChidren(takebackView.Show());
|
//takebackView.frameLayout.Y = closeView.frameLayout.Bottom;
|
takebackView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
#endregion
|
|
///确认事件
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = false;
|
Send.dictionary(switchdictionary, "Data1", "1");//默认值
|
};
|
///取消事件
|
closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
takebackView.selectedIconBtn.Visible = false;
|
Send.dictionary(switchdictionary, "Data1", "0");//默认值
|
|
};
|
//取反
|
takebackView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = true;
|
Send.dictionary(switchdictionary, "Data1", "2");//默认值
|
|
};
|
|
if (edit && TaskList != null)
|
{
|
foreach (var value in TaskList)
|
{
|
if (value["TaskType"] == "1")
|
{
|
var data1 = value["Data1"];
|
Send.dictionary(switchdictionary, "Data1", data1);
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = false;
|
switch (data1)
|
{
|
case "1":
|
{
|
openView.selectedIconBtn.Visible = true;
|
}
|
break;
|
case "0":
|
{
|
closeView.selectedIconBtn.Visible = true;
|
}
|
break;
|
case "2":
|
{
|
takebackView.selectedIconBtn.Visible = true;
|
}
|
break;
|
}
|
|
}
|
|
}
|
}
|
}
|
|
|
}
|
break;
|
case DeviceType.IASZone:
|
{
|
var iASZonedevice = common as IASZone;
|
if (iASZonedevice.DeviceID != 1026)
|
{
|
break;
|
}
|
|
Send.dictionary(deviceConditionsInfo, "Cluster_ID", "1280");
|
Send.dictionary(deviceConditionsInfo, "AttriButeId", "1281");
|
Send.dictionary(deviceConditionsInfo, "AttriButeData2", "0");
|
|
int timeValue = 0;
|
///点击确认事件
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "IASZone";
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
if (iASZonedevice.IasDeviceType == 13)
|
{
|
|
closeView.selectedIconBtn.Visible = true;
|
}
|
Send.dictionary(deviceConditionsInfo, "Range", "5");
|
Send.dictionary(deviceConditionsInfo, "AttriButeData1", "3");//支持1和2;1+2=3
|
};
|
///点击取消事件
|
closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "IASZone";
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
Send.dictionary(deviceConditionsInfo, "Range", "8");//1
|
Send.dictionary(deviceConditionsInfo, "AttriButeData1", "3");//0
|
if (iASZonedevice.IasDeviceType == 13 || iASZonedevice.IasDeviceType == 541)
|
{
|
SelectedDeviceStatus = "";
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
var ignoreTime = new IgnoreTime();
|
UserView.HomePage.Instance.AddChidren(ignoreTime);
|
UserView.HomePage.Instance.PageIndex += 1;
|
ignoreTime.Show(common, closeView.titleBtn.Text, edit, timeValue, _if[1]);
|
}
|
};
|
|
switch (iASZonedevice.IasDeviceType)
|
{
|
case 13:
|
{
|
|
if (common.ModelIdentifier == "MSPIRB-ZB.10")
|
{
|
int _height = 3;
|
if (edit)
|
{
|
_height = 2;
|
}
|
var view = completeView.Show(_height);
|
openView.titleBtn.TextID = MyInternationalizationString.someone;
|
closeView.titleBtn.TextID = MyInternationalizationString.unattendedtime1;
|
closeView.selectedIconBtn.UnSelectedImagePath = "ZigeeLogic/next.png";
|
closeView.selectedIconBtn.Visible = true;
|
view.AddChidren(openView.Show());
|
view.AddChidren(closeView.Show());
|
|
takebackView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
takebackView.selectedIconBtn.Visible = true;
|
takebackView.titleBtn.TextID = MyInternationalizationString.ambientLight;
|
takebackView.selectedIconBtn.UnSelectedImagePath = "ZigeeLogic/next.png";
|
if (edit)
|
{
|
|
if (devices["Cluster_ID"] == "1024")
|
{
|
flMain.RemoveFromParent();
|
var illumination = new Illumination();
|
UserView.HomePage.Instance.AddChidren(illumination);
|
UserView.HomePage.Instance.PageIndex += 1;
|
illumination.Show(common, takebackView.titleBtn.Text, int.Parse(devices["AttriButeData1"]), true);
|
}
|
else
|
{
|
closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
}
|
}
|
else
|
{
|
view.AddChidren(takebackView.Show());
|
|
}
|
|
|
takebackView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "";
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
openView.selectedIconBtn.Visible = false;
|
var illumination = new Illumination();
|
UserView.HomePage.Instance.AddChidren(illumination);
|
UserView.HomePage.Instance.PageIndex += 1;
|
illumination.Show(common, takebackView.titleBtn.Text, 0, false);
|
|
};
|
|
}
|
else
|
{
|
|
openView.titleBtn.TextID = MyInternationalizationString.someone;
|
closeView.titleBtn.TextID = MyInternationalizationString.unattendedtime1;
|
closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
closeView.selectedIconBtn.UnSelectedImagePath = "ZigeeLogic/next.png";
|
closeView.selectedIconBtn.Visible = true;
|
completeView.Show(2).AddChidren(openView.Show());
|
completeView.Show(2).AddChidren(closeView.Show());
|
|
}
|
}
|
break;
|
case 21:
|
case 22:
|
{
|
#region
|
var view = completeView.Show(3);
|
openView.titleBtn.TextID = MyInternationalizationString.logicopen;
|
closeView.titleBtn.TextID = MyInternationalizationString.logicclose;
|
view.AddChidren(openView.Show());
|
view.AddChidren(closeView.Show());
|
|
takebackView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
takebackView.selectedIconBtn.Visible = true;
|
takebackView.titleBtn.TextID = MyInternationalizationString.closetimeout;
|
takebackView.selectedIconBtn.UnSelectedImagePath = "ZigeeLogic/next.png";
|
view.AddChidren(takebackView.Show());
|
takebackView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "";
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = false;
|
var ignoreTime = new IgnoreTime();
|
UserView.HomePage.Instance.AddChidren(ignoreTime);
|
UserView.HomePage.Instance.PageIndex += 1;
|
ignoreTime.Show(common, takebackView.titleBtn.Text, edit, timeValue, _if[1]);
|
|
};
|
|
#endregion
|
}
|
break;
|
case 40:
|
{
|
|
openView.titleBtn.TextID = MyInternationalizationString.smokescreen;
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
completeView.Show(1).AddChidren(openView.Show());
|
}
|
break;
|
case 42:
|
{
|
openView.titleBtn.TextID = MyInternationalizationString.waterleakage;
|
closeView.titleBtn.TextID = MyInternationalizationString.noleakage;
|
closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
completeView.Show(2).AddChidren(openView.Show());
|
completeView.Show(2).AddChidren(closeView.Show());
|
|
}
|
break;
|
case 43:
|
{//召元说的
|
openView.titleBtn.TextID = MyInternationalizationString.gas;
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
completeView.Show(1).AddChidren(openView.Show());
|
}
|
break;
|
case 44:
|
{
|
openView.titleBtn.TextID = MyInternationalizationString.emergencybutton;
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
completeView.Show(1).AddChidren(openView.Show());
|
}
|
break;
|
case 277:
|
{
|
openView.titleBtn.TextID = MyInternationalizationString.callthepolice;
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
completeView.Show(1).AddChidren(openView.Show());
|
}
|
break;
|
default:
|
{
|
openView.titleBtn.TextID = MyInternationalizationString.callthepolice;
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
completeView.Show(1).AddChidren(openView.Show());
|
|
}
|
break;
|
}
|
if (edit && devices != null)
|
{
|
if (devices["AttriButeId"] == "1281")
|
{
|
if (devices.ContainsKey("IgnoreTime") && devices["IgnoreTime"] != "0")
|
{
|
timeValue = int.Parse(devices["IgnoreTime"]);
|
}
|
else
|
{
|
if (devices["Range"] == "5")
|
{
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
}
|
else
|
{
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
}
|
|
}
|
|
|
}
|
|
}
|
|
}
|
break;
|
case DeviceType.OnOffSwitch:
|
{
|
l = 1;
|
Send.dictionary(deviceConditionsInfo, "Cluster_ID", "1282");
|
Send.dictionary(deviceConditionsInfo, "AttriButeId", "1283");
|
Send.dictionary(deviceConditionsInfo, "Range", "0");//按键特殊
|
Send.dictionary(deviceConditionsInfo, "AttriButeData1", "0");
|
Send.dictionary(deviceConditionsInfo, "AttriButeData2", "0");
|
|
completeView.Show(l).AddChidren(openView.Show());
|
openView.titleBtn.Text = LocalDevice.Current.GetDeviceEpointName(common);
|
//openView.titleBtn.Text =Language.StringByID(MyInternationalizationString.OnOffSwitch) + common.DeviceEpoint.ToString();
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "OnOffSwitch";
|
openView.selectedIconBtn.Visible = true;
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
};
|
|
if (edit && devices != null)
|
{
|
openView.selectedIconBtn.Visible = true;
|
openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
}
|
|
}
|
break;
|
case DeviceType.DoorLock:
|
{
|
|
flMain.RemoveFromParent();
|
var memberList = new MemberList();
|
UserView.HomePage.Instance.AddChidren(memberList);
|
UserView.HomePage.Instance.PageIndex += 1;
|
MemberList.edit = false;
|
memberList.Show(common);
|
}
|
break;
|
case DeviceType.TemperatureSensor:
|
{
|
|
//获取设备类型
|
var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { common });
|
|
//空气质量传感器
|
if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
|
{
|
AirSonser(flMain, SelectedDeviceStatus, edit, common, devices);
|
}
|
else
|
{
|
|
|
//编辑时的状态值
|
string str1 = "";
|
string str2 = "";
|
string str3 = "";
|
if (edit && devices != null)
|
{
|
//温度值
|
str1 = devices["AttriButeData1"];
|
//比较关系值
|
str2 = devices["Range"];
|
|
}
|
var temperatureSensor = common as TemperatureSensor;
|
if (temperatureSensor.SensorDiv == 1)
|
{
|
str3 = "℃";
|
Send.dictionary(deviceConditionsInfo, "Cluster_ID", "1026");
|
}
|
else
|
{
|
str3 = "%";
|
Send.dictionary(deviceConditionsInfo, "Cluster_ID", "1029");
|
}
|
Send.dictionary(deviceConditionsInfo, "AttriButeId", "0");
|
Send.dictionary(deviceConditionsInfo, "AttriButeData2", "0");
|
completeView.Show(4);
|
PublicInterface publicInterface = new PublicInterface();
|
publicInterface.TemperatureShow(completeView.fraView, str3, str2, str1, (relationValueStr, tempValueStr) =>
|
{
|
SelectedDeviceStatus = "TemperatureSensor";
|
Send.dictionary(deviceConditionsInfo, "AttriButeData1", tempValueStr);
|
Send.dictionary(deviceConditionsInfo, "Range", relationValueStr);
|
});
|
}
|
}
|
break;
|
///调光灯光
|
case DeviceType.DimmableLight:
|
{
|
l = 4;
|
#region ----初始化设备功能数据----
|
Dictionary<string, string> switchdictionary = new Dictionary<string, string>();
|
Send.dictionary(switchdictionary, "Data2", "0");
|
taskListInfo.Add(switchdictionary);
|
completeView.Show(l).AddChidren(openView.Show());
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
|
horizontalSeekBarRowLien.Y = openView.frameLayout.Bottom;
|
horizontalSeekBarVol.Y = openView.frameLayout.Bottom;
|
completeView.Show(l).AddChidren(horizontalSeekBarRowLien);
|
completeView.Show(l).AddChidren(horizontalSeekBarVol);
|
|
closeView.frameLayout.Y = horizontalSeekBarRowLien.Bottom;
|
completeView.Show(l).AddChidren(closeView.Show());
|
|
takebackView.frameLayout.Y = closeView.frameLayout.Bottom;
|
completeView.Show(l).AddChidren(takebackView.Show());
|
takebackView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
#endregion
|
int Progressvalue = 100;
|
EventHandler<int> progressclick = (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
Progressvalue = horizontalSeekBarVol.Progress;
|
Send.dictionary(switchdictionary, "TaskType", "3");
|
//最大亮度值是254需要转换;
|
var lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100;
|
Send.dictionary(switchdictionary, "Data1", lightbrightnessvalue.ToString());
|
|
};
|
horizontalSeekBarVol.OnProgressChangedEvent += progressclick;
|
horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick;
|
///确认事件
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
horizontalSeekBarVol.IsClickable = true;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected;
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = false;
|
horizontalSeekBarVol.Progress = Progressvalue;
|
Send.dictionary(switchdictionary, "TaskType", "3");
|
//最大亮度值是254需要转换;
|
var lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100;
|
Send.dictionary(switchdictionary, "Data1", lightbrightnessvalue.ToString());
|
};
|
///取消事件
|
closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
horizontalSeekBarVol.IsClickable = false;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColor;
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
takebackView.selectedIconBtn.Visible = false;
|
Send.dictionary(switchdictionary, "TaskType", "1");
|
Send.dictionary(switchdictionary, "Data1", "0");//默认值
|
};
|
//取反
|
takebackView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
horizontalSeekBarVol.IsClickable = false;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColor;
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = true;
|
Send.dictionary(switchdictionary, "TaskType", "1");
|
Send.dictionary(switchdictionary, "Data1", "2");//默认值
|
|
};
|
if (edit && TaskList != null)
|
{
|
foreach (var value in TaskList)
|
{
|
var tasktype = value["TaskType"];
|
var data1 = value["Data1"];
|
Send.dictionary(switchdictionary, "TaskType", tasktype);
|
Send.dictionary(switchdictionary, "Data1", data1);
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = false;
|
horizontalSeekBarVol.IsClickable = false;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColor;
|
if (tasktype == "1")
|
{
|
if (data1 == "0")
|
{
|
closeView.selectedIconBtn.Visible = true;
|
}
|
else if (data1 == "2")
|
{
|
takebackView.selectedIconBtn.Visible = true;
|
}
|
}
|
else if (tasktype == "3")
|
{
|
openView.selectedIconBtn.Visible = true;
|
horizontalSeekBarVol.IsClickable = true;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected;
|
horizontalSeekBarVol.Progress = int.Parse(data1) * 100 / 254;
|
Progressvalue = horizontalSeekBarVol.Progress;
|
|
}
|
break;
|
|
}
|
}
|
|
}
|
break;
|
///窗帘
|
case DeviceType.WindowCoveringDevice:
|
{
|
l = 3;
|
#region ----初始化设备功能数据----
|
Dictionary<string, string> switchdictionary = new Dictionary<string, string>();
|
Send.dictionary(switchdictionary, "TaskType", "6");
|
taskListInfo.Add(switchdictionary);
|
|
completeView.Show(l).AddChidren(openView.Show());
|
openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
|
|
|
horizontalSeekBarRowLien.Y = openView.frameLayout.Bottom;
|
horizontalSeekBarVol.Y = openView.frameLayout.Bottom;
|
completeView.Show(l).AddChidren(horizontalSeekBarRowLien);
|
completeView.Show(l).AddChidren(horizontalSeekBarVol);
|
|
closeView.frameLayout.Y = horizontalSeekBarRowLien.Bottom;
|
completeView.Show(l).AddChidren(closeView.Show());
|
closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
#endregion
|
int Progressvalue = 100;
|
EventHandler<int> progressclick = (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
Progressvalue = horizontalSeekBarVol.Progress;
|
Send.dictionary(switchdictionary, "Data1", "5");
|
Send.dictionary(switchdictionary, "Data2", horizontalSeekBarVol.Progress.ToString());
|
};
|
horizontalSeekBarVol.OnProgressChangedEvent += progressclick;
|
horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick;
|
///确认事件
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
horizontalSeekBarVol.IsClickable = true;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected;
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
horizontalSeekBarVol.Progress = Progressvalue;
|
Send.dictionary(switchdictionary, "Data1", "5");
|
Send.dictionary(switchdictionary, "Data2", horizontalSeekBarVol.Progress.ToString());
|
|
};
|
///取消事件
|
closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
horizontalSeekBarVol.IsClickable = false;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColor;
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
Send.dictionary(switchdictionary, "Data2", "0");
|
Send.dictionary(switchdictionary, "Data1", "1");//默认值
|
|
};
|
|
if (edit && TaskList != null)
|
{
|
foreach (var value in TaskList)
|
{
|
if (value["TaskType"] == "6")
|
{
|
if (value["Data1"] == "5")
|
{
|
|
Send.dictionary(switchdictionary, "Data1", "5");
|
Send.dictionary(switchdictionary, "Data2", value["Data2"]);
|
horizontalSeekBarVol.IsClickable = true;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected;
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
horizontalSeekBarVol.Progress = int.Parse(value["Data2"]);
|
Progressvalue = horizontalSeekBarVol.Progress;
|
}
|
else if (value["Data1"] == "1")
|
{
|
Send.dictionary(switchdictionary, "Data1", "1");
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
horizontalSeekBarVol.IsClickable = false;
|
horizontalSeekBarVol.ProgressBarColor = ZigbeeColor.Current.LogicProgressColor;
|
}
|
|
}
|
|
}
|
}
|
}
|
break;
|
///空气开关
|
case DeviceType.AirSwitch:
|
{
|
{
|
l = 3;
|
#region ----初始化设备功能数据----
|
Dictionary<string, string> switchdictionary = new Dictionary<string, string>();
|
Send.dictionary(switchdictionary, "TaskType", "1");
|
Send.dictionary(switchdictionary, "Data1", "0");
|
Send.dictionary(switchdictionary, "Data2", "0");
|
taskListInfo.Add(switchdictionary);
|
#endregion
|
|
#region 空气灯光View
|
|
completeView.Show(l).AddChidren(openView.Show());
|
completeView.Show(l).AddChidren(closeView.Show());
|
completeView.Show(l).AddChidren(takebackView.Show());
|
takebackView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
|
#endregion
|
|
///确认事件
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = false;
|
Send.dictionary(switchdictionary, "Data1", "1");
|
|
};
|
///取消事件
|
closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
takebackView.selectedIconBtn.Visible = false;
|
Send.dictionary(switchdictionary, "Data1", "0");
|
|
};
|
//取反
|
takebackView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = true;
|
Send.dictionary(switchdictionary, "Data1", "2");
|
|
};
|
|
if (edit && TaskList != null)
|
{
|
foreach (var value in TaskList)
|
{
|
if (value["TaskType"] == "1")
|
{
|
var data1 = value["Data1"];
|
Send.dictionary(switchdictionary, "Data1", data1);
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = false;
|
takebackView.selectedIconBtn.Visible = false;
|
if (data1 == "1")
|
{
|
openView.selectedIconBtn.Visible = true;
|
}
|
else if (data1 == "0")
|
{
|
closeView.selectedIconBtn.Visible = true;
|
}
|
else if (data1 == "2")
|
{
|
takebackView.selectedIconBtn.Visible = true;
|
}
|
break;
|
}
|
|
}
|
}
|
|
}
|
}
|
break;
|
///空调
|
case DeviceType.Thermostat:
|
{
|
l = 6;
|
#region ----初始化设备功能数据----
|
var temperaturedictionary = new Dictionary<string, string>();
|
var modedictionary = new Dictionary<string, string>();
|
var speeddictionary = new Dictionary<string, string>();
|
Send.dictionary(temperaturedictionary, "TaskType", "5");
|
Send.dictionary(modedictionary, "TaskType", "5");
|
Send.dictionary(modedictionary, "Data1", "3");
|
Send.dictionary(speeddictionary, "TaskType", "5");
|
Send.dictionary(speeddictionary, "Data1", "6");
|
taskListInfo.Add(temperaturedictionary);
|
taskListInfo.Add(modedictionary);
|
taskListInfo.Add(speeddictionary);
|
#endregion
|
#region 空调View
|
|
completeView.Show(l).AddChidren(openView.Show());
|
|
#region 空调状态View
|
var PickerViewfra = new FrameLayout
|
{
|
Y = openView.frameLayout.Bottom,
|
Height = Application.GetRealHeight(640),
|
};
|
completeView.Show(l).AddChidren(PickerViewfra);
|
|
//遮挡空调滑动view;
|
var pausePickerViewfra = new FrameLayout
|
{
|
Y = openView.frameLayout.Bottom,
|
Height = Application.GetRealHeight(640),
|
BackgroundColor = 0x60ffffff,
|
};
|
completeView.Show(l).AddChidren(pausePickerViewfra);
|
|
var mUIPickerView = new UIPickerView
|
{
|
Height = Application.GetRealHeight(640 - 5),
|
};
|
PickerViewfra.AddChidren(mUIPickerView);
|
var line = new Button
|
{
|
Y = Application.GetRealHeight(640 - 5),
|
Width = Application.GetRealWidth(920),
|
Height = Application.GetRealHeight(5),
|
X = Application.GetRealWidth(80),
|
BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
|
};
|
PickerViewfra.AddChidren(line);
|
|
var mList1 = new List<string>();
|
var mList2 = new List<string> {
|
Language.StringByID(MyInternationalizationString.logiccool),
|
Language.StringByID(MyInternationalizationString.logicheat),
|
Language.StringByID(MyInternationalizationString.logicauto),
|
Language.StringByID(MyInternationalizationString.logicdry),
|
Language.StringByID(MyInternationalizationString.logicfanonly),
|
};
|
var mList3 = new List<string>{
|
Language.StringByID(MyInternationalizationString.logiclow),
|
Language.StringByID(MyInternationalizationString.logicmedium),
|
Language.StringByID(MyInternationalizationString.logichigh),
|
};
|
for (int i = 16; i < 33; i++)
|
{
|
mList1.Add(i.ToString() + " " + "℃");
|
}
|
mUIPickerView.setNPicker(mList1, mList2, mList3);
|
///默认状态
|
|
|
#endregion
|
|
closeView.frameLayout.Y = PickerViewfra.Bottom;
|
completeView.Show(l).AddChidren(closeView.Show());
|
closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
|
//默认26,自动,中风
|
int indextemperature = 10, indexmode = 2, indexspeed = 1;
|
mUIPickerView.OnSelectChangeEvent += (s1, s2, s3) =>
|
{
|
indextemperature = s1;
|
indexmode = s2;
|
indexspeed = s3;
|
if (openView.selectedIconBtn.Visible)
|
{
|
SelectedDeviceStatus = "yes";
|
var temperature = mList1[s1].Split(' ')[0];
|
var modestring = mList2[s2].Split(' ')[0];
|
var speedstring = mList3[s3].Split(' ')[0];
|
ModeState(modestring, temperaturedictionary, modedictionary);
|
var a = int.Parse(temperature) * 100;
|
Send.dictionary(temperaturedictionary, "Data2", a.ToString());
|
|
SpeedState(speedstring, speeddictionary);
|
}
|
};
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 0);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 1);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 2);
|
#endregion
|
|
if (edit && TaskList != null)
|
{
|
|
foreach (var value in TaskList)
|
{
|
if (TaskList.Count == 1)
|
{
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 0);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 1);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 2);
|
//数组只有一个元素说明当前空调状态为关;
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
pausePickerViewfra.Height = Application.GetRealHeight(600);
|
//如果空调状态是关;直接跳出for循坏;
|
break;
|
|
}
|
else
|
{
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
pausePickerViewfra.Height = Application.GetRealHeight(0);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnSelectedColor, 0);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnSelectedColor, 1);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnSelectedColor, 2);
|
}
|
|
|
if (value["TaskType"] == "5")
|
{
|
if (value["Data1"] == "3")
|
{//3---设置工作模式(1:自动;3:制冷;4:制热;7:送风;8:除湿)
|
Send.dictionary(modedictionary, "Data2", value["Data2"]);
|
string modetext = "";
|
switch (value["Data2"])
|
{
|
case "3":
|
{
|
modetext = Language.StringByID(MyInternationalizationString.logiccool);
|
//indexmode = 0;
|
}
|
break;
|
case "4":
|
{
|
modetext = Language.StringByID(MyInternationalizationString.logicheat);
|
// indexmode = 1;
|
}
|
break;
|
case "1":
|
{
|
modetext = Language.StringByID(MyInternationalizationString.logicauto);
|
// indexmode = 2;
|
}
|
break;
|
case "8":
|
{
|
modetext = Language.StringByID(MyInternationalizationString.logicdry);
|
// indexmode = 3;
|
}
|
break;
|
case "7":
|
{
|
modetext = Language.StringByID(MyInternationalizationString.logicfanonly);
|
//indexmode = 4;
|
}
|
break;
|
}
|
indexmode = mList2.IndexOf(modetext);
|
}
|
else if (value["Data1"] == "6")
|
{//6---设置风扇模式(1:低风;2:中风;3:高风;)
|
Send.dictionary(speeddictionary, "Data2", value["Data2"]);
|
string speedtext = "";
|
switch (value["Data2"])
|
{
|
case "1":
|
{
|
speedtext = Language.StringByID(MyInternationalizationString.logiclow);
|
//indexspeed = 0;
|
}
|
break;
|
|
case "2":
|
{
|
speedtext = Language.StringByID(MyInternationalizationString.logicmedium);
|
// indexspeed = 1;
|
}
|
break;
|
case "3":
|
{
|
speedtext = Language.StringByID(MyInternationalizationString.logichigh);
|
// indexspeed = 2;
|
}
|
break;
|
|
}
|
indexspeed = mList3.IndexOf(speedtext);
|
}
|
//4-设置加热度数;5-设置制冷、除湿度数;7-设置自动度数
|
else if (value["Data1"] == "4" || value["Data1"] == "5" || value["Data1"] == "7")
|
{
|
var s = int.Parse(value["Data2"]) / 100;
|
indextemperature = mList1.IndexOf(s.ToString() + " " + "℃");
|
Send.dictionary(temperaturedictionary, "Data1", value["Data1"]);
|
Send.dictionary(temperaturedictionary, "Data2", value["Data2"]);
|
}
|
|
}
|
}
|
}
|
///更新最新空调状态;
|
mUIPickerView.setCurrentItems(indextemperature, indexmode, indexspeed);
|
///确认事件
|
openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnSelectedColor, 0);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnSelectedColor, 1);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnSelectedColor, 2);
|
mUIPickerView.setCurrentItems(indextemperature, indexmode, indexspeed);
|
pausePickerViewfra.Height = Application.GetRealHeight(0);
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = true;
|
closeView.selectedIconBtn.Visible = false;
|
//清除之前数据;
|
taskListInfo.Clear();
|
//加载新数据;
|
Send.dictionary(temperaturedictionary, "TaskType", "5");
|
Send.dictionary(modedictionary, "TaskType", "5");
|
Send.dictionary(modedictionary, "Data1", "3");
|
Send.dictionary(speeddictionary, "TaskType", "5");
|
Send.dictionary(speeddictionary, "Data1", "6");
|
taskListInfo.Add(temperaturedictionary);
|
taskListInfo.Add(modedictionary);
|
taskListInfo.Add(speeddictionary);
|
|
var temperature = mList1[indextemperature].Split(' ')[0];
|
var modestring = mList2[indexmode].Split(' ')[0];
|
var speedstring = mList3[indexspeed].Split(' ')[0];
|
|
ModeState(modestring, temperaturedictionary, modedictionary);
|
var a = int.Parse(temperature) * 100;
|
Send.dictionary(temperaturedictionary, "Data2", a.ToString());
|
SpeedState(speedstring, speeddictionary);
|
|
};
|
///取消事件
|
closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 0);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 1);
|
mUIPickerView.setTextColorCenter(ZigbeeColor.Current.LogicBtnCancelColor, 2);
|
mUIPickerView.setCurrentItems(indextemperature, indexmode, indexspeed);
|
//清除之前数据;
|
taskListInfo.Clear();
|
Send.dictionary(modedictionary, "TaskType", "5");
|
Send.dictionary(modedictionary, "Data1", "3");
|
Send.dictionary(modedictionary, "Data2", "0");
|
//加载新数据;
|
taskListInfo.Add(modedictionary);
|
pausePickerViewfra.Height = Application.GetRealHeight(600);
|
SelectedDeviceStatus = "yes";
|
openView.selectedIconBtn.Visible = false;
|
closeView.selectedIconBtn.Visible = true;
|
|
};
|
}
|
break;
|
case DeviceType.ColorTemperatureLight:
|
{
|
flMain.RemoveFromParent();
|
var nightlight = new Nightlight();
|
UserView.HomePage.Instance.AddChidren(nightlight);
|
UserView.HomePage.Instance.PageIndex += 1;
|
if (edit)
|
{
|
nightlight.Show(common, edit, _if[1], Common.Logic.CurrentLogic.Actions[intValue]);
|
}
|
else
|
{
|
nightlight.Show(common, edit, _if[1]);
|
}
|
|
}
|
break;
|
|
|
}
|
completeView.Btncomplete.MouseUpEventHandler += (sender, e) =>
|
{
|
UserView.HomePage.Instance.ScrollEnabled = true;
|
if (SelectedDeviceStatus != "")
|
{
|
if (_if[0] == "condition")
|
{ //添加条件
|
LogicIfon.AddDeviceconditions(common, deviceConditionsInfo);
|
}
|
else
|
{ //添加目标
|
if (SelectedDeviceStatus == "DoorLock")
|
{//门锁数据特殊,进行特殊处理;
|
LogicIfon.AddDoorLockActions(common, actionsInfo);
|
}
|
else
|
{
|
LogicIfon.AddDeviceActions(common, actionsInfo);
|
}
|
}
|
}
|
else
|
{
|
if (!edit)
|
{
|
var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal,
|
Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
|
Language.StringByID(MyInternationalizationString.confrim));
|
alert.Show();
|
return;
|
}
|
|
}
|
flMain.RemoveFromParent();
|
switch (_if[1])
|
{
|
case "logic":
|
{
|
//自动化
|
var logicCommunalPage = new LogicCommunalPage();
|
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
|
UserView.HomePage.Instance.PageIndex += 1;
|
logicCommunalPage.Show(() => { });
|
}
|
break;
|
case "mould":
|
{
|
//自动化推荐模板
|
var templatePage = new TemplatePage();
|
UserView.HomePage.Instance.AddChidren(templatePage);
|
UserView.HomePage.Instance.PageIndex += 1;
|
templatePage.Show();
|
}
|
break;
|
case "lockaction":
|
{
|
//门锁联动事件
|
var lockLogicCommunalPage = new DoorLockLogic.LockLogicCommunalPage();
|
UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage);
|
UserView.HomePage.Instance.PageIndex += 1;
|
lockLogicCommunalPage.Show(() => { });
|
}
|
break;
|
}
|
|
|
};
|
}
|
/// <summary>
|
/// 空调模式的状态
|
/// </summary>
|
/// <param name="modestring"></param>
|
/// <param name="temperaturedictionary"></param>
|
/// <param name="modedictionary"></param>
|
public static void ModeState(string modestring, Dictionary<string, string> temperaturedictionary, Dictionary<string, string> modedictionary)
|
{
|
|
if (modestring == Language.StringByID(MyInternationalizationString.logiccool))
|
{
|
Send.dictionary(modedictionary, "Data2", "3");
|
Send.dictionary(temperaturedictionary, "Data1", "5");
|
}
|
else if (modestring == Language.StringByID(MyInternationalizationString.logicheat))
|
{
|
|
Send.dictionary(modedictionary, "Data2", "4");
|
Send.dictionary(temperaturedictionary, "Data1", "4");
|
}
|
else if (modestring == Language.StringByID(MyInternationalizationString.logicauto))
|
{
|
|
Send.dictionary(modedictionary, "Data2", "1");
|
Send.dictionary(temperaturedictionary, "Data1", "7");
|
}
|
else if (modestring == Language.StringByID(MyInternationalizationString.logicdry))
|
{
|
|
Send.dictionary(modedictionary, "Data2", "8");
|
Send.dictionary(temperaturedictionary, "Data1", "5");
|
}
|
else if (modestring == Language.StringByID(MyInternationalizationString.logicfanonly))
|
{
|
Send.dictionary(temperaturedictionary, "Data1", "20");
|
Send.dictionary(modedictionary, "Data2", "7");
|
}
|
|
}
|
/// <summary>
|
/// 风速的模式
|
/// </summary>
|
/// <param name="speedstring"></param>
|
/// <param name="speeddictionary"></param>
|
public static void SpeedState(string speedstring, Dictionary<string, string> speeddictionary)
|
{
|
|
if (speedstring == Language.StringByID(MyInternationalizationString.logiclow))
|
{
|
|
Send.dictionary(speeddictionary, "Data2", "1");
|
|
}
|
else if (speedstring == Language.StringByID(MyInternationalizationString.logicmedium))
|
{
|
|
Send.dictionary(speeddictionary, "Data2", "2");
|
|
}
|
else if (speedstring == Language.StringByID(MyInternationalizationString.logichigh))
|
{
|
|
Send.dictionary(speeddictionary, "Data2", "3");
|
}
|
|
}
|
/// <summary>
|
/// 空气质量传感器View(特殊处理)
|
/// </summary>
|
/// <param name="flMain"></param>
|
/// <param name="SelectedDeviceStatus"></param>
|
/// <param name="edit"></param>
|
/// <param name="common"></param>
|
/// <param name="dic"></param>
|
private static void AirSonser(FrameLayout flMain,string SelectedDeviceStatus,bool edit,CommonDevice common, Dictionary<string, string> dic=null) {
|
flMain.RemoveAll();
|
if (edit&&dic!=null) {
|
AirProperty(flMain, dic, common,"", edit, SelectedDeviceStatus);
|
}
|
else
|
{
|
PublicInterface publicInterface = new PublicInterface();
|
var list0 = publicInterface.GetViewList("空气质量传感器");
|
publicInterface.SingleSelectionShow(flMain, list0, MyInternationalizationString.airqualitysensor, "", (tagText) =>
|
{
|
flMain.RemoveAll();
|
SelectedDeviceStatus = "TemperatureSensor";
|
AirProperty(flMain, dic, common,tagText, edit, SelectedDeviceStatus);
|
}, () => { flMain.RemoveFromParent(); });
|
}
|
}
|
/// <summary>
|
/// 空气质量传感器属性值(特殊处理)
|
/// </summary>
|
/// <param name="flMain"></param>
|
/// <param name="dic"></param>
|
/// <param name="common"></param>
|
/// <param name="tagText"></param>
|
/// <param name="edit"></param>
|
/// <param name="SelectedDeviceStatus"></param>
|
private static void AirProperty(FrameLayout flMain, Dictionary<string, string> dic,CommonDevice common,string tagText,bool edit, string SelectedDeviceStatus) {
|
PublicInterface publicInterface = new PublicInterface();
|
string range = "";
|
string stateText = "";
|
if (edit&& dic!=null)
|
{
|
range = dic["Range"];
|
switch (dic["Cluster_ID"])
|
{
|
case "1066":
|
{
|
if (dic["AttriButeId"] == "57344")
|
{
|
tagText = Language.StringByID(MyInternationalizationString.kongqizhiliang);
|
switch (dic["AttriButeData1"])
|
{
|
|
case "1":
|
{
|
stateText = Language.StringByID(MyInternationalizationString.you);
|
}
|
break;
|
case "2":
|
{
|
stateText = Language.StringByID(MyInternationalizationString.liang);
|
}
|
break;
|
case "3":
|
{
|
stateText = Language.StringByID(MyInternationalizationString.cha);
|
}
|
break;
|
}
|
}
|
else
|
{
|
tagText = Language.StringByID(MyInternationalizationString.pm25);
|
///Pm2.5
|
int intValue = int.Parse(dic["AttriButeData1"]);
|
if (0 < intValue && intValue < 30)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.pmyou);
|
}
|
else if (36 < intValue && intValue < 75)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.pmliang);
|
}
|
else if (76 < intValue && intValue < 115)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.pmqingdu);
|
}
|
else if (intValue > 115)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.pmzhongdu);
|
}
|
|
}
|
}
|
break;
|
case "1037":
|
{
|
tagText = Language.StringByID(MyInternationalizationString.co2);
|
///co2
|
int intValue = int.Parse(dic["AttriButeData1"]);
|
if (0 < intValue && intValue < 1000)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.co2qingxin);
|
}
|
else if (1000 < intValue && intValue < 2000)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.co2huizhuo);
|
}
|
else if (2000 < intValue && intValue < 5000)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.co2queyang);
|
}
|
else if (intValue > 5000)
|
{
|
stateText = Language.StringByID(MyInternationalizationString.co2yanzhongqueyang);
|
}
|
}
|
break;
|
case "1026":
|
{
|
tagText = Language.StringByID(MyInternationalizationString.sensortemperature);
|
stateText = dic["AttriButeData1"];
|
}
|
break;
|
case "1029":
|
{
|
tagText = Language.StringByID(MyInternationalizationString.sensorhumidity);
|
stateText = dic["AttriButeData1"];
|
}
|
break;
|
}
|
}
|
Dictionary<string, string> airqualitysensorDic = new Dictionary<string, string>();
|
Send.dictionary(airqualitysensorDic, "Type", "1");
|
Send.dictionary(airqualitysensorDic, "IsValid", "1");
|
Send.dictionary(airqualitysensorDic, "MacAddr", common.DeviceAddr);
|
Send.dictionary(airqualitysensorDic, "Epoint", common.DeviceEpoint.ToString());
|
if (tagText == Language.StringByID(MyInternationalizationString.kongqizhiliang))
|
{
|
|
var list1 = publicInterface.GetViewList("空气质量");
|
publicInterface.SingleSelectionShow(flMain, list1, MyInternationalizationString.airqualitysensor, stateText, (strText) =>
|
{
|
SelectedDeviceStatus = "TemperatureSensor";
|
string valuaStr = "";
|
if (strText == Language.StringByID(MyInternationalizationString.you))
|
{
|
valuaStr = "1";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.liang))
|
{
|
valuaStr = "2";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.cha))
|
{
|
valuaStr = "3";
|
}
|
Send.dictionary(airqualitysensorDic, "Cluster_ID", "1066");
|
Send.dictionary(airqualitysensorDic, "AttriButeId", "57344");
|
Send.dictionary(airqualitysensorDic, "AttriButeData1", valuaStr);
|
Send.dictionary(airqualitysensorDic, "AttriButeData2", "0");
|
Send.dictionary(airqualitysensorDic, "Range", "1");
|
AddDic(flMain, SelectedDeviceStatus, edit, common, airqualitysensorDic);
|
|
|
}, () => {
|
if (edit) { flMain.RemoveFromParent(); }
|
else
|
{
|
AirSonser(flMain, SelectedDeviceStatus, edit, common);
|
} });
|
|
}
|
else if (tagText == Language.StringByID(MyInternationalizationString.pm25))
|
{
|
var list2 = publicInterface.GetViewList("pm2.5");
|
publicInterface.SingleSelectionShow(flMain, list2, MyInternationalizationString.pm25, stateText, (strText) =>
|
{
|
SelectedDeviceStatus = "TemperatureSensor";
|
string valuaStr = "";
|
if (strText == Language.StringByID(MyInternationalizationString.pmyou))
|
{
|
valuaStr = "18";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.pmliang))
|
{
|
valuaStr = "54";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.pmqingdu))
|
{
|
valuaStr = "105";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.pmzhongdu))
|
{
|
valuaStr = "130";
|
}
|
Send.dictionary(airqualitysensorDic, "Cluster_ID", "1066");
|
Send.dictionary(airqualitysensorDic, "AttriButeId", "0");
|
Send.dictionary(airqualitysensorDic, "AttriButeData1", valuaStr);
|
Send.dictionary(airqualitysensorDic, "AttriButeData2", "0");
|
Send.dictionary(airqualitysensorDic, "Range", "1");
|
AddDic(flMain, SelectedDeviceStatus, edit, common, airqualitysensorDic);
|
|
|
}, () => {
|
if (edit) { flMain.RemoveFromParent(); }
|
else
|
{
|
AirSonser(flMain, SelectedDeviceStatus, edit, common);
|
}
|
});
|
|
}
|
else if (tagText == Language.StringByID(MyInternationalizationString.co2))
|
{
|
|
var list2 = publicInterface.GetViewList("co2");
|
publicInterface.SingleSelectionShow(flMain, list2, MyInternationalizationString.co2, stateText, (strText) =>
|
{
|
SelectedDeviceStatus = "TemperatureSensor";
|
string valuaStr = "";
|
if (strText == Language.StringByID(MyInternationalizationString.co2qingxin))
|
{
|
valuaStr = "500";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.co2huizhuo))
|
{
|
valuaStr = "1500";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.co2queyang))
|
{
|
valuaStr = "2500";
|
}
|
else if (strText == Language.StringByID(MyInternationalizationString.co2yanzhongqueyang))
|
{
|
valuaStr = "5500";
|
}
|
Send.dictionary(airqualitysensorDic, "Cluster_ID", "1037");
|
Send.dictionary(airqualitysensorDic, "AttriButeId", "0");
|
Send.dictionary(airqualitysensorDic, "AttriButeData1", valuaStr);
|
Send.dictionary(airqualitysensorDic, "AttriButeData2", "0");
|
Send.dictionary(airqualitysensorDic, "Range", "1");
|
AddDic(flMain, SelectedDeviceStatus, edit, common, airqualitysensorDic);
|
|
|
}, () => {
|
if (edit) { flMain.RemoveFromParent(); }
|
else
|
{
|
AirSonser(flMain, SelectedDeviceStatus, edit, common);
|
}
|
});
|
|
|
|
}
|
else if (tagText == Language.StringByID(MyInternationalizationString.sensortemperature))
|
{
|
//编辑时的状态值
|
string str1 = range;
|
string str2 = stateText;
|
publicInterface.TemperatureShow1(flMain, tagText, "℃", str1, str2, (relationValueStr, tempValueStr) =>
|
{
|
|
SelectedDeviceStatus = "TemperatureSensor";
|
Send.dictionary(airqualitysensorDic, "Cluster_ID", "1026");
|
Send.dictionary(airqualitysensorDic, "AttriButeId", "0");
|
Send.dictionary(airqualitysensorDic, "AttriButeData1", tempValueStr);
|
Send.dictionary(airqualitysensorDic, "AttriButeData2", "0");
|
Send.dictionary(airqualitysensorDic, "Range", relationValueStr);
|
AddDic(flMain, SelectedDeviceStatus, edit, common, airqualitysensorDic);
|
|
|
}, () =>
|
{
|
if (edit) { flMain.RemoveFromParent(); }
|
else
|
{
|
AirSonser(flMain, SelectedDeviceStatus, edit, common);
|
}
|
|
});
|
}
|
else if (tagText == Language.StringByID(MyInternationalizationString.sensorhumidity))
|
{
|
//编辑时的状态值
|
string str1 = range;
|
string str2 = stateText;
|
publicInterface.TemperatureShow1(flMain, tagText, "%", str1, str2, (relationValueStr, tempValueStr) =>
|
{
|
SelectedDeviceStatus = "TemperatureSensor";
|
Send.dictionary(airqualitysensorDic, "Cluster_ID", "1029");
|
Send.dictionary(airqualitysensorDic, "AttriButeId", "0");
|
Send.dictionary(airqualitysensorDic, "AttriButeData1", tempValueStr);
|
Send.dictionary(airqualitysensorDic, "AttriButeData2", "0");
|
Send.dictionary(airqualitysensorDic, "Range", relationValueStr);
|
AddDic(flMain, SelectedDeviceStatus, edit, common, airqualitysensorDic);
|
}, () => {
|
if (edit) { flMain.RemoveFromParent(); }
|
else
|
{
|
AirSonser(flMain, SelectedDeviceStatus, edit, common);
|
}
|
});
|
}
|
|
}
|
/// <summary>
|
/// 空气质量传感器(特殊处理)
|
/// </summary>
|
/// <param name="flMain"></param>
|
/// <param name="SelectedDeviceStatus"></param>
|
/// <param name="edit"></param>
|
/// <param name="common"></param>
|
/// <param name="dic"></param>
|
private static void AddDic(FrameLayout flMain, string SelectedDeviceStatus, bool edit, CommonDevice common, Dictionary<string, string> dic )
|
{
|
UserView.HomePage.Instance.ScrollEnabled = true;
|
if (SelectedDeviceStatus != "")
|
{
|
//添加条件
|
LogicIfon.AddDeviceconditions(common, dic);
|
}
|
else
|
{
|
if (!edit)
|
{
|
var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal,
|
Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
|
Language.StringByID(MyInternationalizationString.confrim));
|
alert.Show();
|
return;
|
}
|
|
}
|
flMain.RemoveFromParent();
|
//自动化
|
var logicCommunalPage = new LogicCommunalPage();
|
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
|
UserView.HomePage.Instance.PageIndex += 1;
|
logicCommunalPage.Show(() => { });
|
}
|
|
}
|
}
|