using System;
|
using System.Collections.Generic;
|
using System.Threading;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class UserRoom : FrameLayout
|
{
|
static Room room;
|
string roomFilePath;
|
List<string> showList;
|
VerticalScrolViewLayout RoomView;
|
static UserRoom curView = null;
|
|
List<Common> EnergtLightList = new List<Common> ();
|
//static string AirQCity = "";
|
//static string AirQTemp = "";
|
//static string AirQHumidityIcon = "";
|
//static string AirQHumidity = "";
|
//static string AirQAirIcon = "";
|
//static string AirQAirPM25 = "";
|
//static string AirQAirPM25Icon = "";
|
|
public UserRoom ()
|
{
|
showList = new List<string> ();
|
Height = Application.GetRealHeight (Application.DesignHeight);
|
}
|
#region Update data
|
|
/// <summary>
|
/// 更新当前地热开关 - 针对单一属性更新
|
/// </summary>
|
public static void Update_FoolHeatPanel_WorkingTemp (string updataFalg, byte workingTemp)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag != null) {
|
if (btn.Tag.ToString () == "Temperature") {
|
btn.Text = workingTemp + "°";
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前地热工作温度 - 针对单一属性更新
|
/// </summary>
|
public static void Update_FoolHeatPanel_Power (string updataFalg, byte power)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null || curView.RoomView == null) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag != null) {
|
if (btn.Tag.ToString () == "Switch") {
|
if (power == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调开关 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_WorkingTemp (string updataFalg, byte workingTemp,byte temperatureMode)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempacBLL = new ACMethod ();
|
if (btn.Tag.ToString () == "Temperature") {
|
btn.Text = workingTemp + "°";
|
//if (btn.Text.Contains("C")) {
|
// btn.Text = workingTemp + "°C";
|
//} else {
|
// btn.Text = workingTemp + "°F";
|
//}
|
}
|
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调模式图标 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_ModeIcon (string updataFalg, byte mode)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempacBLL = new ACMethod ();
|
if (btn.Tag.ToString () == "Mode") {
|
tempacBLL.UpdataACHostModeIcon (mode, btn);
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调风速图标 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_FanIcon (string updataFalg, byte fanMode)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempacBLL = new ACMethod ();
|
if (btn.Tag.ToString () == "Wind") {
|
tempacBLL.UpdataACHostWindIcon (fanMode, btn);
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调工作温度 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_Power (string updataFalg, byte power)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null || curView.RoomView == null) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempacBLL = new ACMethod ();
|
if (btn.Tag.ToString () == "Switch") {
|
if (power == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
public static void UpdataDeviceStatus (Common common)
|
{
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
if (curView == null || curView.RoomView == null) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == common.Type + "_" + common.CommonLoopID) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (common.Type == DeviceType.LightCCT || common.Type == DeviceType.LightRGB || common.Type == DeviceType.LightDALI || common.Type == DeviceType.LightRGBW ||
|
common.Type == DeviceType.LightLogic || common.Type == DeviceType.LightSwitch || common.Type == DeviceType.LightDimming ||
|
common.Type == DeviceType.LightMixSwitch || common.Type == DeviceType.LightMixDimming || common.Type == DeviceType.LightEnergySwitch ||
|
common.Type == DeviceType.LightSwitchSocket || common.Type == DeviceType.FanModule) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
try {
|
if (common.Type == DeviceType.LightRGB || common.Type == DeviceType.LightLogic) {
|
if ((common as LightLogic).CurrentBrightness == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (common.Type == DeviceType.LightSwitch || common.Type == DeviceType.LightMixSwitch
|
|| common.Type == DeviceType.LightSwitchSocket || common.Type == DeviceType.LightEnergySwitch) {
|
if ((common as LightSwitch).CurrentBrightness == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (common.Type == DeviceType.LightDimming || common.Type == DeviceType.LightMixDimming || common.Type == DeviceType.LightDALI) {
|
if ((common as LightDimming).CurrentBrightness == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (common.Type == DeviceType.FanModule) {
|
if ((common as FanModule).WindSpeed == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
}
|
} catch {
|
|
}
|
} else if (deviceRow.GetChildren (j).GetType () == typeof (HorizontalSeekBar) && 3 < (DateTime.Now - (DateTime)deviceRow.GetChildren (j).Tag).TotalSeconds) {
|
//(lightRow.GetChildren (j) as HorizontalSeekBar).Progress = brightness;
|
}
|
} else if (common.Type == DeviceType.FoolHeat) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag != null) {
|
if (btn.Tag.ToString () == "Switch") {
|
if ((common as FoolHeat).Status == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (btn.Tag.ToString () == "Temperature") {
|
btn.Text = (common as FoolHeat).WorkingTemperature.ToString () + "°";
|
}
|
}
|
}
|
} else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared ) {
|
AC ac = (common as AC);
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempacBLL = new ACMethod ();
|
if (btn.Tag.ToString () == "Switch") {
|
if (ac.Power == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (btn.Tag.ToString () == "Temperature") {
|
tempacBLL.UpdataACModeTemperature (ac, ac.SetMode, btn);
|
} else if (btn.Tag.ToString () == "Mode") {
|
tempacBLL.UpdataACHostModeIcon (ac.SetMode, btn);
|
} else if (btn.Tag.ToString () == "Wind") {
|
tempacBLL.UpdataACHostWindIcon (ac.SetFanSpeed, btn);
|
}
|
}
|
} else if (common.Type == DeviceType.FreshAir) {
|
FreshAir fa = (common as FreshAir);
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempfaBLL = new FreshAirBLL ();
|
if (btn.Tag.ToString () == "Switch") {
|
if (fa.SwitchStatus == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (btn.Tag.ToString () == "Temperature") {
|
btn.Text = fa.InTemp.ToString () + "°";
|
} else if (btn.Tag.ToString () == "Mode") {
|
btn.UnSelectedImagePath = tempfaBLL.GetWindIcon (fa.SetPattern);
|
} else if (btn.Tag.ToString () == "Wind") {
|
btn.UnSelectedImagePath = tempfaBLL.GetWindIcon (fa.WindSpeed);
|
}
|
}
|
} else if(common.Type == DeviceType.CurtainModel) {
|
|
}
|
}
|
}
|
}
|
}
|
});
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
} finally {
|
//Application.RunOnMainThread (() => {
|
// MainPage.Loading.Hide ();
|
//});
|
}
|
});
|
|
}
|
#endregion
|
public static Action ReadAirAction;
|
|
public override void RemoveFromParent ()
|
{
|
base.RemoveFromParent ();
|
curView = null;
|
}
|
|
public void InitRoomView (string RoomFilePath)
|
{
|
try {
|
curView = this;
|
RemoveAll ();
|
showList.Clear ();
|
roomFilePath = RoomFilePath;
|
|
room = Room.GetRoomByFilePath (roomFilePath);
|
//room = Room.Lists.Find ((obj) => obj.Name == sendRoom.Name);
|
if (room == null) {
|
if (roomFilePath == Room.FavoriteRoom) {
|
new Room ().Save (Room.FavoriteRoom);
|
room = Room.GetRoomByFilePath (roomFilePath);
|
} else {
|
(Parent as PageLayout).PageIndex -= 1;
|
curView = null;
|
return;
|
}
|
}
|
|
showList.AddRange (room.DeviceFilePathList);
|
showList.AddRange (room.SceneFilePathList);
|
|
#region ---TopView---
|
FrameLayout topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (topView);
|
|
if (roomFilePath == Room.FavoriteRoom) {
|
Button LogoButton = new Button () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (LogoButton);
|
|
LogoButton.MouseUpEventHandler += (sender, e) => {
|
// int i = 10;
|
// while (i > 0) {
|
// i--;
|
// System.Threading.Tasks.Task.Run (() => {
|
// SmartHome.MqttCommon.StartCloudMqtt ();
|
// });
|
// }
|
|
};
|
} else {
|
var back = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
this.RemoveFromParent ();
|
};
|
}
|
|
Button NameButton = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetMinReal (90),
|
Text = MainPage.SoftTitle,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 20,
|
};
|
topView.AddChidren (NameButton);
|
|
Button ItemButton = new Button () {
|
Width = Application.GetMinRealAverage (55),
|
Height = Application.GetMinRealAverage (55),
|
UnSelectedImagePath = "Item/+.png",
|
SelectedImagePath = "Item/+.png",
|
X = Application.GetRealWidth (640 - 80),
|
Y = Application.GetRealHeight (17),
|
};
|
topView.AddChidren (ItemButton);
|
ItemButton.MouseUpEventHandler += (sender, e) => {
|
var userDeviceListPage = new UserDeviceListPage (room, showList,roomFilePath);
|
userDeviceListPage.Show ();
|
Action action = () => {
|
InitRoomView (roomFilePath);
|
};
|
|
Action<List<string>, List<string>> saveAction = (roomSceneFilePathList, roomDeviceFilePathList) => {
|
room.SceneFilePathList.Clear ();
|
room.SceneFilePathList.AddRange (roomSceneFilePathList);
|
room.DeviceFilePathList.Clear ();
|
room.DeviceFilePathList.AddRange (roomDeviceFilePathList);
|
room.Save (room.RoomFilePath);
|
Room.UpdateMemorry (room.RoomFilePath);
|
Room.InitAllRoom ();
|
};
|
|
userDeviceListPage.ShowPage (action, saveAction);
|
};
|
#endregion
|
RoomView = new VerticalScrolViewLayout () {
|
Y = topView.Bottom,
|
Height = Application.GetRealHeight (Application.DesignHeight - 126),
|
Width = Application.GetRealWidth (640),
|
};
|
AddChidren (RoomView);
|
if (roomFilePath == Room.FavoriteRoom) {
|
RoomView.Height = Application.GetRealHeight (Application.DesignHeight - UserMiddle.userMenuItemHeight) - topView.Bottom;
|
NameButton.TextID = R.MyInternationalizationString.Favorite;
|
FrameLayout airQualityBackgroundView = new FrameLayout () {
|
Height = MainPage.GetDesignHeight (360),
|
BackgroundImagePath = "Room/FavoriteRoom.png"
|
//BackGroundImage
|
};
|
RoomView.AddChidren (airQualityBackgroundView);
|
if (room.BackGroundImage != "Room/r1.png") {
|
airQualityBackgroundView.BackgroundImagePath = room.BackGroundImage;
|
}
|
FrameLayout airQualityView = new FrameLayout () {
|
//BackgroundColor = SkinStyle.Current.Black50Transparent,
|
};
|
airQualityBackgroundView.AddChidren (airQualityView);
|
|
airQualityView.MouseLongEventHandler += (asdf, fas) => {
|
Action action = () => {
|
airQualityBackgroundView.BackgroundImagePath = room.BackGroundImage;
|
};
|
UserRooms.UpdateFavoriteRoom (action, roomFilePath);
|
};
|
} else {
|
NameButton.Text = room.Name;
|
}
|
|
|
var acList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.HVAC || obj.Type == DeviceType.ACInfrared || obj.Type == DeviceType.ACPanel);
|
foreach (var devcieCommon in acList) {
|
if (devcieCommon == null)
|
continue;
|
#region AC
|
var ac = devcieCommon as AC;
|
EventHandler<MouseEventArgs> openACControlPageEvent = (button, mouseEventArgs) => {
|
UserACPage acView = new UserACPage (ac, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (acView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (acView);
|
}
|
acView.showRoomAC ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
var acRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (140),
|
Tag = devcieCommon.Type + "_" + ac.CommonLoopID
|
};
|
RoomView.AddChidren (acRowView);
|
acRowView.MouseUpEventHandler += openACControlPageEvent;
|
|
var tempDeviceName = new Button () {
|
X = Application.GetRealWidth (40),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = ac.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
acRowView.AddChidren (tempDeviceName);
|
tempDeviceName.MouseUpEventHandler += openACControlPageEvent;
|
|
Button btnMode = new Button () {
|
X = Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetMinRealAverage (100),
|
Height = Application.GetMinRealAverage (100),
|
Tag = "Mode"
|
};
|
acRowView.AddChidren (btnMode);
|
new ACMethod ().UpdataACHostModeIcon (ac.SetMode, btnMode);
|
btnMode.MouseUpEventHandler += openACControlPageEvent;
|
|
Button btnWind = new Button () {
|
X = btnMode.Right + Application.GetRealWidth (0),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetMinRealAverage (100),
|
Height = Application.GetMinRealAverage (100),
|
Tag = "Wind"
|
};
|
acRowView.AddChidren (btnWind);
|
new ACMethod ().UpdataACHostWindIcon (ac.SetFanSpeed, btnWind);
|
btnWind.MouseUpEventHandler += openACControlPageEvent;
|
|
var btnSetTemperature = new Button () {
|
Width = Application.GetRealWidth (310),
|
X = Application.GetRealWidth (280),
|
Y = Application.GetRealHeight (20),
|
TextSize = 26,
|
TextAlignment = TextAlignment.Center,
|
Tag = "Temperature",
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
acRowView.AddChidren (btnSetTemperature);
|
new ACMethod ().UpdataACModeTemperature (ac, ac.SetMode, btnSetTemperature);
|
btnSetTemperature.MouseUpEventHandler += openACControlPageEvent;
|
|
var tempSiwtch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Y = Application.GetRealHeight (67),
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = "Switch"
|
};
|
acRowView.AddChidren (tempSiwtch);
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
tempSiwtch.IsSelected = !tempSiwtch.IsSelected;
|
ac.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0;
|
if (ac.Type == DeviceType.ACPanel) {
|
Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.Power, ac.LoopID });
|
} else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.HVAC || ac.Type == DeviceType.ACInfrared) {
|
Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, ac.Power, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode });
|
}
|
};
|
|
if (0 < ac.Power) {
|
tempSiwtch.IsSelected = true;
|
}
|
|
if (ac.Type == DeviceType.ACPanel) {
|
new System.Threading.Thread (() => {
|
var readRecBytes = Control.ControlBytesSendHasReturn (Command.ReadPanelTempType, ac.SubnetID, ac.DeviceID, new byte [] { });
|
if (readRecBytes != null) {
|
try {
|
if (readRecBytes.Length > 0) {
|
if (ac.TemperatureMode != readRecBytes [0]) {
|
ac.TemperatureMode = readRecBytes [0];
|
IO.FileUtils.SaveEquipmentMessage (ac, ac.LoopID.ToString ());
|
Application.RunOnMainThread (() => {
|
if (readRecBytes [0] == 0) {
|
btnSetTemperature.Text = ac.SetTemperature.ToString () + "°C";
|
} else {
|
var f = ac.IndoorTemperature * 9 / 5 + 32;
|
btnSetTemperature.Text = ac.SetTemperature.ToString () + "°F";
|
}
|
});
|
}
|
}
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
}
|
}
|
}) { IsBackground = true }.Start ();
|
}
|
new System.Threading.Thread (() => {
|
if (ac.Type == DeviceType.ACPanel) {
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 4, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 5, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 6, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 7, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 8, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 19, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadPanelTempTypeACK, ac.SubnetID, ac.DeviceID, new byte [] { }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadPanleTemp, ac.SubnetID, ac.DeviceID, new byte [] { ac.LoopID }, SendCount.Zero);
|
} else if (ac.Type == DeviceType.HVAC || ac.Type == DeviceType.ACInfrared) {
|
Control.ControlBytesSendHasReturn (Command.ReadACMode, ac.SubnetID, ac.DeviceID, new byte [] { ac.LoopID });
|
}
|
}) { IsBackground = true }.Start ();
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
#endregion
|
}
|
var fhList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.FoolHeat || obj.Type == DeviceType.FoolHeatPanel);
|
foreach (var devcieCommon in fhList) {
|
if (devcieCommon == null)
|
continue;
|
|
#region 地热模块
|
var fh = devcieCommon as FoolHeat;
|
var fhRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (110),
|
Tag = devcieCommon.Type + "_" + devcieCommon.CommonLoopID
|
};
|
RoomView.AddChidren (fhRowView);
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
UnSelectedImagePath = "Item/FloorHeating.png",
|
SelectedImagePath = "Item/FloorHeating.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
fhRowView.AddChidren (btnIcon);
|
|
var tempDeviceName = new Button () {
|
X = btnIcon.Right + Application.GetRealWidth (10),
|
Width = Application.GetRealWidth (340),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = fh.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
fhRowView.AddChidren (tempDeviceName);
|
tempDeviceName.MouseUpEventHandler += (sender2, e2) => {
|
UserFHPage fhView = new UserFHPage (fh, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (fhView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (fhView);
|
}
|
fhView.ShowRoomFH ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
|
var btnSetTemperature = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (200),
|
X = Application.GetRealWidth (280),
|
Gravity = Gravity.CenterVertical,
|
Text = fh.WorkingTemperature.ToString () + "°",
|
TextSize = 26,
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
Tag = "Temperature"
|
};
|
fhRowView.AddChidren (btnSetTemperature);
|
|
var tempSiwtch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = "Switch"
|
};
|
fhRowView.AddChidren (tempSiwtch);
|
|
if (fh.Status == 1) {
|
tempSiwtch.IsSelected = true;
|
} else {
|
tempSiwtch.IsSelected = false;
|
}
|
|
//UpdateStatus (roomFH);
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
tempSiwtch.IsSelected = !tempSiwtch.IsSelected;
|
fh.Status = tempSiwtch.IsSelected ? (byte)1 : (byte)0;
|
System.Threading.Tasks.Task.Run (() => {
|
if (fh.Type == DeviceType.FoolHeatPanel) {
|
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 20, fh.Status, fh.LoopID });
|
} else if (fh.Type == DeviceType.FoolHeat) {
|
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.Switch);
|
}
|
});
|
};
|
|
if (0 < fh.Status) {
|
tempSiwtch.IsSelected = true;
|
}
|
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
#endregion
|
}
|
foreach (var deviceCommon in room.DeviceList) {
|
if (deviceCommon == null)
|
continue;
|
|
if (deviceCommon.Type == DeviceType.FoolHeat || deviceCommon.Type == DeviceType.FoolHeatPanel || deviceCommon.Type == DeviceType.Thermostat ||
|
deviceCommon.Type == DeviceType.HVAC || deviceCommon.Type == DeviceType.ACInfrared || deviceCommon.Type == DeviceType.ACPanel ||
|
deviceCommon.Type == DeviceType.FreshAir || deviceCommon.Type == DeviceType.LogicModule) {
|
continue;
|
} else {
|
var DeviceRowView = new FrameLayout () {
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Height = Application.GetRealHeight (100),
|
Tag = deviceCommon.Type + "_" + deviceCommon.CommonLoopID
|
};
|
RoomView.AddChidren (DeviceRowView);
|
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical
|
};
|
DeviceRowView.AddChidren (btnIcon);
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = deviceCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.Right + Application.GetRealWidth (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (btnName);
|
|
Button tempSwitch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = deviceCommon.CommonLoopID
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
|
//Button btnDelFile = new Button () {
|
// TextID = R.MyInternationalizationString.Del,
|
// BackgroundColor = SkinStyle.Current.DelColor,
|
//};
|
////DeviceRowView.AddRightView (btnDelFile);
|
//btnDelFile.MouseUpEventHandler += (sender, e) => {
|
// //if (room.DeviceFilePathList.Contains (deviceFilePath)) {
|
// // room.DeviceFilePathList.Remove (deviceFilePath);
|
// //}
|
// //else if (room.SceneFilePathList.Contains (deviceFilePath)) {
|
// // room.SceneFilePathList.Remove (deviceFilePath);
|
// //}
|
// room.Save (roomFilePath);
|
// this.InitRoomView (roomFilePath);
|
//};
|
//==============================
|
//if (deviceCommon.Type == DeviceType.LogicModule) {
|
// LogicModule lm = deviceCommon as LogicModule;
|
// btnIcon.UnSelectedImagePath = "Scene/Scene.png";
|
// btnIcon.SelectedImagePath = "Scene/Scene.png";
|
// btnName.MouseUpEventHandler += (sender, e) => {
|
// Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
// };
|
// DeviceRowView.MouseUpEventHandler += (sender, e) => {
|
// Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
// };
|
//}
|
if (deviceCommon.Type == DeviceType.FanModule) {
|
#region 风扇
|
FanModule fanModule = deviceCommon as FanModule;//(FanModule)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
|
btnIcon.UnSelectedImagePath = "Fan/Fan.png";
|
btnIcon.SelectedImagePath = "Fan/Fan.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserFan fanView = new UserFan (fanModule);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (fanView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (fanView);
|
}
|
fanView.ShowRoomFan ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.IsSelected = fanModule.Switch == 0 ? false : true;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
fanModule.Switch = fanModule.WindSpeed;
|
} else {
|
fanModule.Switch = 0;
|
}
|
Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.Switch });
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightDimming) {
|
#region 调光器A
|
LightDimming dimming = deviceCommon as LightDimming;
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
if (UserConfig.Instance.UnEnableDimmingLight.Contains (dimming.CommonLoopID)) {
|
return;
|
}
|
Dialog dialogDimming = new Dialog ();
|
FrameLayout dialogBodyView = new FrameLayout ();
|
dialogDimming.AddChidren (dialogBodyView);
|
dialogBodyView.MouseUpEventHandler += (sender1, e2) => {
|
dialogDimming.Close ();
|
};
|
|
FrameLayout dimmingView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (240),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
};
|
dialogBodyView.AddChidren (dimmingView);
|
|
Button btnDialogTitle = new Button () {
|
Height = Application.GetRealHeight (90),
|
Text = dimming.Name,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dimmingView.AddChidren (btnDialogTitle);
|
|
var proessView = new FrameLayout () {
|
Y = btnDialogTitle.Bottom,
|
Height = Application.GetRealHeight (150),
|
};
|
dimmingView.AddChidren (proessView);
|
|
//var tempSeekBarFrame = new FrameLayout () {
|
// Width = Application.GetRealWidth (500 - 120),
|
// Height = Application.GetRealHeight (80),
|
// X = Application.GetRealWidth (30),
|
// Gravity = Gravity.CenterVertical
|
//};
|
//proessView.AddChidren (tempSeekBarFrame);
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Progress = dimming.CurrentBrightness
|
};
|
proessView.AddChidren (horizontalSeekBar);
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = horizontalSeekBar.Right + Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
Text = dimming.CurrentBrightness + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
proessView.AddChidren (btnMaxBrightness);
|
horizontalSeekBar.ProgressChanged += (sender2, e4) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
dimming.LastOpenBrightness = dimming.CurrentBrightness = (byte)e4;
|
if (e4 == 0 || e4 == 100) {
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
return;
|
}
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 800) {
|
return;
|
}
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
};
|
dialogDimming.Show ();
|
};
|
|
tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
dimming.CurrentBrightness = 100;
|
} else {
|
dimming.CurrentBrightness = 0;
|
}
|
byte delayHeight = 0;
|
byte delayLow = 0;
|
if (dimming.CurrentBrightness == 0) {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeClose / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeClose % 256);
|
} else {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeOpen / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeOpen % 256);
|
}
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurrentBrightness, delayHeight, delayLow });
|
|
};
|
|
#region 延时
|
Button btnLightSetting = new Button () {
|
Width = Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (60),
|
Radius = (uint)Application.GetRealHeight (30),
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Light/DimmingSetting.png",
|
SelectedImagePath = "Light/DimmingSetting.png",
|
Visible = dimming.DimmingFunction,
|
};
|
DeviceRowView.AddChidren (btnLightSetting);
|
btnLightSetting.MouseUpEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
FrameLayout dialogView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (520),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.Center,
|
};
|
dialog.AddChidren (dialogView);
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
TextID = R.MyInternationalizationString.DelayTime2,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (btnTitle);
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnTitle.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialogView.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOnReduce);
|
|
Button btnDelayTimeOnText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnReduce.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = dimming.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.AddChidren (btnDelayTimeOnText);
|
|
Button btnDelayTimeOnAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnText.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = dimming.CustomDelayTimeOpen;
|
btnDelayTimeOnAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = true;
|
if (delayTimeOn > 59)
|
return;
|
delayTimeOn++;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn > 59)
|
break;
|
delayTimeOn++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOnReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = true;
|
if (delayTimeOn == 0)
|
return;
|
delayTimeOn--;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn == 0)
|
break;
|
delayTimeOn--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
|
#region ---延时关---
|
Button btnDelayTimeOFFTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnDelayTimeOnReduce.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialogView.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOffReduce);
|
|
Button btnDelayTimeOffText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffReduce.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = dimming.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.AddChidren (btnDelayTimeOffText);
|
|
Button btnDelayTimeOffAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffText.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = dimming.CustomDelayTimeClose;
|
btnDelayTimeOffAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = true;
|
if (delayTimeOff > 59)
|
return;
|
delayTimeOff++;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff > 59)
|
break;
|
delayTimeOff++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOffReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = true;
|
if (delayTimeOff == 0)
|
return;
|
delayTimeOff--;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff == 0)
|
break;
|
delayTimeOff--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
#endregion
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (520 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (239),
|
TextID = R.MyInternationalizationString.Cancel,
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = 1,
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (239),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
string keyString = dimming.CommonLoopID;
|
dimming.CustomDelayTimeOpen = delayTimeOn;
|
dimming.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (dimming.CommonLoopID + "Open")) {
|
room.DelayTime [keyString + "Open"] = delayTimeOn;
|
} else {
|
room.DelayTime.Add (keyString + "Open", delayTimeOn);
|
}
|
if (room.DelayTime.ContainsKey (keyString + "Close")) {
|
room.DelayTime [keyString + "Close"] = delayTimeOff;
|
} else {
|
room.DelayTime.Add (keyString + "Close", delayTimeOff);
|
}
|
room.Save (typeof (Room).Name + "_" + room.Name);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
dialog.Close ();
|
};
|
dialog.Show ();
|
};
|
#endregion
|
|
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightDALI) {
|
#region DALI
|
LightDALI dimming = deviceCommon as LightDALI;// (LightDimming)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
|
//if (dimming == null) {
|
// dimming = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
|
if (UserConfig.Instance.UnEnableDimmingLight.Contains (dimming.CommonLoopID)) {
|
return;
|
}
|
Dialog dialogDimming = new Dialog ();
|
FrameLayout dialogBodyView = new FrameLayout ();
|
dialogDimming.AddChidren (dialogBodyView);
|
dialogBodyView.MouseUpEventHandler += (sender1, e2) => {
|
dialogDimming.Close ();
|
};
|
|
FrameLayout dimmingView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (440),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
};
|
dialogBodyView.AddChidren (dimmingView);
|
|
Button btnDialogTitle = new Button () {
|
Height = Application.GetRealHeight (90),
|
Text = dimming.Name,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dimmingView.AddChidren (btnDialogTitle);
|
|
var btnCurBrightness = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = btnDialogTitle.Bottom,
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + dimming.CurrentBrightness + "%"
|
};
|
dimmingView.AddChidren (btnCurBrightness);
|
|
var proessView = new FrameLayout () {
|
Y = btnCurBrightness.Bottom,
|
Height = Application.GetRealHeight (80),
|
};
|
dimmingView.AddChidren (proessView);
|
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (500 - 60),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Progress = dimming.CurrentBrightness
|
};
|
proessView.AddChidren (horizontalSeekBar);
|
|
horizontalSeekBar.ProgressChanged += (sender2, e4) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnCurBrightness.Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + horizontalSeekBar.Progress + "%";
|
dimming.LastOpenBrightness = dimming.CurrentBrightness = (byte)e4;
|
if (e4 == 0 || e4 == 100) {
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
dimming.LastOpenBrightness = dimming.CurrentBrightness = (byte)e4;
|
return;
|
}
|
|
new System.Threading.Thread (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
}) { IsBackground = true}.Start();
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
btnCurBrightness.Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,dimming.DeviceID, new byte [] { dimming.LoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
};
|
|
|
var btnCurTone = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = proessView.Bottom + Application.GetRealHeight (20),
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + dimming.CurTone + "K"
|
};
|
dimmingView.AddChidren (btnCurTone);
|
|
var proessToneView = new FrameLayout () {
|
Y = btnCurTone.Bottom,
|
Height = Application.GetRealHeight (60),
|
};
|
dimmingView.AddChidren (proessToneView);
|
|
var horizontalToneSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (500 - 60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Max = dimming.TonesRange / 100,
|
Progress = (dimming.CurTone - dimming.WarmTones) / 100
|
};
|
proessToneView.AddChidren (horizontalToneSeekBar);
|
|
var btnWarmToneText = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
TextID = R.MyInternationalizationString.Warm,
|
Y = proessToneView.Bottom,
|
TextAlignment = TextAlignment.TopLeft,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dimmingView.AddChidren (btnWarmToneText);
|
|
var btnColoToneText = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (380),
|
Y = proessToneView.Bottom,
|
TextID = R.MyInternationalizationString.CoolTones,
|
TextAlignment = TextAlignment.TopRight,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
dimmingView.AddChidren (btnColoToneText);
|
horizontalToneSeekBar.ProgressChanged += (sender2, e4) => {
|
var tonesValues = e4 * 100 + dimming.WarmTones;
|
dimming.CurTones_High = (byte)(tonesValues / 256);
|
dimming.CurTones_Low = (byte)(tonesValues % 256);
|
btnCurTone.Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + dimming.CurTone + "K";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalToneSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.control_lamp_color_Temperature, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurTones_High, dimming.CurTones_Low }, SendCount.Zero);
|
});
|
};
|
horizontalToneSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalToneSeekBar.Tag = DateTime.Now;
|
var tonesValues = horizontalToneSeekBar.Progress * 100 + dimming.WarmTones;
|
dimming.CurTones_High = (byte)(tonesValues / 256);
|
dimming.CurTones_Low = (byte)(tonesValues % 256);
|
btnCurTone.Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + dimming.CurTone + "K";
|
Control.ControlBytesSend (Command.control_lamp_color_Temperature, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurTones_High, dimming.CurTones_Low }, SendCount.Zero);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
};
|
|
dialogDimming.Show ();
|
};
|
|
tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
dimming.CurrentBrightness = 100;
|
} else {
|
dimming.CurrentBrightness = 0;
|
}
|
byte delayHeight = 0;
|
byte delayLow = 0;
|
if (dimming.CurrentBrightness == 0) {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeClose / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeClose % 256);
|
} else {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeOpen / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeOpen % 256);
|
}
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurrentBrightness, delayHeight, delayLow });
|
|
};
|
#region 延时
|
Button btnLightSetting = new Button () {
|
Width = Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (60),
|
Radius = (uint)Application.GetRealHeight (30),
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Light/DimmingSetting.png",
|
SelectedImagePath = "Light/DimmingSetting.png",
|
Visible = dimming.DimmingFunction,
|
};
|
DeviceRowView.AddChidren (btnLightSetting);
|
btnLightSetting.MouseUpEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
FrameLayout dialogView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (520),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.Center,
|
};
|
dialog.AddChidren (dialogView);
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
TextID = R.MyInternationalizationString.DelayTime2,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (btnTitle);
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnTitle.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialogView.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOnReduce);
|
|
Button btnDelayTimeOnText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnReduce.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = dimming.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.AddChidren (btnDelayTimeOnText);
|
|
Button btnDelayTimeOnAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnText.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = dimming.CustomDelayTimeOpen;
|
btnDelayTimeOnAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = true;
|
if (delayTimeOn > 59)
|
return;
|
delayTimeOn++;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn > 59)
|
break;
|
delayTimeOn++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOnReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = true;
|
if (delayTimeOn == 0)
|
return;
|
delayTimeOn--;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn == 0)
|
break;
|
delayTimeOn--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
|
#region ---延时关---
|
Button btnDelayTimeOFFTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnDelayTimeOnReduce.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialogView.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOffReduce);
|
|
Button btnDelayTimeOffText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffReduce.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = dimming.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.AddChidren (btnDelayTimeOffText);
|
|
Button btnDelayTimeOffAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffText.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = dimming.CustomDelayTimeClose;
|
btnDelayTimeOffAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = true;
|
if (delayTimeOff > 59)
|
return;
|
delayTimeOff++;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff > 59)
|
break;
|
delayTimeOff++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOffReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = true;
|
if (delayTimeOff == 0)
|
return;
|
delayTimeOff--;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff == 0)
|
break;
|
delayTimeOff--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
#endregion
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (520 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (239),
|
TextID = R.MyInternationalizationString.Cancel,
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = 1,
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (239),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
string keyString = dimming.CommonLoopID;
|
dimming.CustomDelayTimeOpen = delayTimeOn;
|
dimming.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (dimming.CommonLoopID + "Open")) {
|
room.DelayTime [keyString + "Open"] = delayTimeOn;
|
} else {
|
room.DelayTime.Add (keyString + "Open", delayTimeOn);
|
}
|
if (room.DelayTime.ContainsKey (keyString + "Close")) {
|
room.DelayTime [keyString + "Close"] = delayTimeOff;
|
} else {
|
room.DelayTime.Add (keyString + "Close", delayTimeOff);
|
}
|
room.Save (typeof (Room).Name + "_" + room.Name);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
dialog.Close ();
|
};
|
dialog.Show ();
|
};
|
#endregion
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightMixDimming) {
|
#region 调光器
|
LightMixDimming comm = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceCommon.SavePath)));
|
LightMixDimming dimming = deviceCommon as LightMixDimming;
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
if (dimming == null) {
|
dimming = comm;
|
}
|
btnName.MouseUpEventHandler += (sender, e) => {
|
if (UserConfig.Instance.UnEnableDimmingLight.Contains (dimming.CommonLoopID)) {
|
return;
|
}
|
Dialog dialogDimming = new Dialog ();
|
FrameLayout dialogBodyView = new FrameLayout ();
|
dialogDimming.AddChidren (dialogBodyView);
|
dialogBodyView.MouseUpEventHandler += (sender1, e2) => {
|
dialogDimming.Close ();
|
};
|
|
FrameLayout dimmingView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (240),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
};
|
dialogBodyView.AddChidren (dimmingView);
|
|
Button btnDialogTitle = new Button () {
|
Height = Application.GetRealHeight (90),
|
Text = dimming.Name,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dimmingView.AddChidren (btnDialogTitle);
|
|
FrameLayout proessView = new FrameLayout () {
|
Y = btnDialogTitle.Bottom,
|
Height = Application.GetRealHeight (150),
|
};
|
dimmingView.AddChidren (proessView);
|
|
var tempSeekBarFrame = new FrameLayout () {
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical
|
};
|
proessView.AddChidren (tempSeekBarFrame);
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Progress = dimming.CurrentBrightness
|
};
|
tempSeekBarFrame.AddChidren (horizontalSeekBar);
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = tempSeekBarFrame.Right + Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
Text = dimming.CurrentBrightness + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
proessView.AddChidren (btnMaxBrightness);
|
horizontalSeekBar.ProgressChanged += (sender2, e4) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
});
|
|
if (e4 == 0 || e4 == 100) {
|
System.Threading.Tasks.Task.Run (() => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
});
|
}
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
};
|
dialogDimming.Show ();
|
};
|
|
tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
dimming.CurrentBrightness = 100;
|
} else {
|
dimming.CurrentBrightness = 0;
|
}
|
byte delayHeight = 0;
|
byte delayLow = 0;
|
if (dimming.CurrentBrightness == 0) {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeClose / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeClose % 256);
|
} else {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeOpen / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeOpen % 256);
|
}
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, dimming.CurrentBrightness, delayHeight, delayLow });
|
};
|
#region 延时
|
Button btnLightSetting = new Button () {
|
Width = Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (60),
|
Radius = (uint)Application.GetRealHeight (30),
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Light/DimmingSetting.png",
|
SelectedImagePath = "Light/DimmingSetting.png",
|
Visible = dimming.DimmingFunction,
|
};
|
DeviceRowView.AddChidren (btnLightSetting);
|
btnLightSetting.MouseUpEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
FrameLayout dialogView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (520),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.Center,
|
};
|
dialog.AddChidren (dialogView);
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
TextID = R.MyInternationalizationString.DelayTime2,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (btnTitle);
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnTitle.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialogView.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOnReduce);
|
|
Button btnDelayTimeOnText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnReduce.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = dimming.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.AddChidren (btnDelayTimeOnText);
|
|
Button btnDelayTimeOnAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnText.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = dimming.CustomDelayTimeOpen;
|
btnDelayTimeOnAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = true;
|
if (delayTimeOn > 59)
|
return;
|
delayTimeOn++;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn > 59)
|
break;
|
delayTimeOn++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOnReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = true;
|
if (delayTimeOn == 0)
|
return;
|
delayTimeOn--;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn == 0)
|
break;
|
delayTimeOn--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
|
#region ---延时关---
|
Button btnDelayTimeOFFTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnDelayTimeOnReduce.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialogView.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOffReduce);
|
|
Button btnDelayTimeOffText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffReduce.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = dimming.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.AddChidren (btnDelayTimeOffText);
|
|
Button btnDelayTimeOffAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffText.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialogView.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = dimming.CustomDelayTimeClose;
|
btnDelayTimeOffAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = true;
|
if (delayTimeOff > 59)
|
return;
|
delayTimeOff++;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff > 59)
|
break;
|
delayTimeOff++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOffReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = true;
|
if (delayTimeOff == 0)
|
return;
|
delayTimeOff--;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff == 0)
|
break;
|
delayTimeOff--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
#endregion
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (520 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (239),
|
TextID = R.MyInternationalizationString.Cancel,
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = 1,
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (239),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
string keyString = dimming.CommonLoopID;
|
dimming.CustomDelayTimeOpen = delayTimeOn;
|
dimming.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (dimming.CommonLoopID + "Open")) {
|
room.DelayTime [keyString + "Open"] = delayTimeOn;
|
} else {
|
room.DelayTime.Add (keyString + "Open", delayTimeOn);
|
}
|
if (room.DelayTime.ContainsKey (keyString + "Close")) {
|
room.DelayTime [keyString + "Close"] = delayTimeOff;
|
} else {
|
room.DelayTime.Add (keyString + "Close", delayTimeOff);
|
}
|
room.Save (typeof (Room).Name + "_" + room.Name);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
dialog.Close ();
|
};
|
dialog.Show ();
|
};
|
#endregion
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightMixSwitch) {
|
#region
|
//LightMixSwitch dimming = deviceCommon as LightMixSwitch;// (LightMixSwitch)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
LightMixSwitch comm = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixSwitch> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceCommon.SavePath)));
|
LightMixSwitch dimming = deviceCommon as LightMixSwitch;//(LightMixDimming)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
if (dimming == null) {
|
dimming = comm;
|
}
|
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
dimming.CurrentBrightness = 100;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 });
|
} else {
|
dimming.CurrentBrightness = 0;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 });
|
}
|
};
|
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightRGB) {
|
#region RGB
|
LightLogic rgbLight = deviceCommon as LightLogic;//(LightLogic)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
if (rgbLight == null) {
|
rgbLight = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceCommon.SavePath)));
|
}
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
|
btnName.MouseUpEventHandler += (sender, e) => {
|
byte [] lightLigicBytes = new byte [11];
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ("Loading..");
|
});
|
lightLigicBytes = Control.ControlBytesSendHasReturn (Command.ReadLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID });
|
if (lightLigicBytes == null) {
|
lightLigicBytes = new byte [11];
|
}
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
Dialog dialog = new Dialog () {
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
Button btnTopNull = new Button () {
|
Height = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
dialog.AddChidren (btnTopNull);
|
Button btnTitle = new Button () {
|
Y = btnTopNull.Bottom,
|
Height = Application.GetRealHeight (90),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
Text = rgbLight.Name,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextSize = 19
|
};
|
dialog.AddChidren (btnTitle);
|
|
Button btnColor = new Button () {
|
Width = Application.GetRealWidth (100),
|
Height = Application.GetRealHeight (40),
|
X = Application.GetRealWidth (20),
|
Y = btnTitle.Bottom + Application.GetRealHeight (50),
|
Radius = 5,
|
BackgroundColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8])
|
};
|
dialog.AddChidren (btnColor);
|
Button btnColorText = new Button () {
|
Width = Application.GetRealWidth (100),
|
Height = Application.GetRealHeight (40),
|
X = btnColor.X,
|
Y = btnColor.Bottom,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = "Color"
|
};
|
dialog.AddChidren (btnColorText);
|
ColorPicker c = new ColorPicker () {
|
X = Application.GetRealWidth (140),
|
Y = btnTitle.Bottom + Application.GetRealHeight (30),
|
Width = Application.GetMinRealAverage (440),
|
Height = Application.GetMinRealAverage (440),
|
ColorImagePath = "Item/PickerColorWheel.png",
|
};
|
dialog.AddChidren (c);
|
|
DateTime colorChangeTime = DateTime.MinValue;
|
c.ColorChaged += (sender2, e2) => {
|
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 300) {
|
lightLigicBytes [6] = e2 [0];
|
lightLigicBytes [7] = e2 [1];
|
lightLigicBytes [8] = e2 [2];
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
colorChangeTime = DateTime.Now;
|
btnColor.BackgroundColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8]);
|
}
|
};
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = c.Bottom,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialog.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (170),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOnReduce);
|
|
Button btnDelayTimeOnText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnReduce.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = rgbLight.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
SelectedTextColor = SkinStyle.Current.TextColor,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
dialog.AddChidren (btnDelayTimeOnText);
|
|
Button btnDelayTimeOnAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnText.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = rgbLight.CustomDelayTimeOpen;
|
btnDelayTimeOnAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = true;
|
if (delayTimeOn > 59)
|
return;
|
delayTimeOn++;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn > 59)
|
break;
|
delayTimeOn++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOnReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = true;
|
if (delayTimeOn == 0)
|
return;
|
delayTimeOn--;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn == 0)
|
break;
|
delayTimeOn--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
|
#region ---延时关---
|
Button btnDelayTimeOFFTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnDelayTimeOnReduce.Bottom + Application.GetRealHeight (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialog.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (170),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOffReduce);
|
|
Button btnDelayTimeOffText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffReduce.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = rgbLight.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
SelectedTextColor = SkinStyle.Current.TextColor,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
dialog.AddChidren (btnDelayTimeOffText);
|
|
Button btnDelayTimeOffAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffText.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = rgbLight.CustomDelayTimeClose;
|
btnDelayTimeOffAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = true;
|
if (delayTimeOff > 59)
|
return;
|
delayTimeOff++;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff > 59)
|
break;
|
delayTimeOff++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOffReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = true;
|
if (delayTimeOff == 0)
|
return;
|
delayTimeOff--;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff == 0)
|
break;
|
delayTimeOff--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
var seekBarLighting = new HorizontalSeekBar () {
|
X = Application.GetRealWidth (50),
|
Y = btnDelayTimeOffReduce.Bottom + Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (50),
|
Progress = lightLigicBytes [1],
|
ThumbColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8]),
|
Max = 100,
|
};
|
dialog.AddChidren (seekBarLighting); Button btnLightingText = new Button () {
|
X = seekBarLighting.Right + Application.GetRealWidth (5),
|
Y = seekBarLighting.Y,
|
Width = Application.GetRealWidth (80),
|
Height = Application.GetRealHeight (50),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = lightLigicBytes [1].ToString () + "%"
|
};
|
dialog.AddChidren (btnLightingText);
|
seekBarLighting.ProgressChanged += (sender3, e3) => {
|
if(e3 == 0 || e3 == 100) {
|
lightLigicBytes [1] = (byte)e3;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
colorChangeTime = DateTime.Now;
|
btnLightingText.Text = e3.ToString () + "%";
|
rgbLight.LastOpenBrightness = (byte)e3;
|
}
|
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 500) {
|
lightLigicBytes [1] = (byte)e3;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
colorChangeTime = DateTime.Now;
|
btnLightingText.Text = e3.ToString () + "%";
|
rgbLight.LastOpenBrightness = (byte)e3;
|
}
|
};
|
|
var bottomView = new FrameLayout () {
|
Y = dialog.Height - Application.GetRealHeight (100),
|
Height = Application.GetRealHeight (100),
|
};
|
dialog.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (322),
|
TextID = R.MyInternationalizationString.Close,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = Application.GetRealWidth (3),
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (322),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
if (rgbLight.CustomDelayTimeOpen != delayTimeOn || rgbLight.CustomDelayTimeClose != delayTimeOff) {
|
string keyString = rgbLight.SubnetID.ToString () + "_" + rgbLight.DeviceID.ToString () + "_" + rgbLight.LoopID.ToString ();
|
rgbLight.CustomDelayTimeOpen = delayTimeOn;
|
rgbLight.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (keyString + "Open")) {
|
room.DelayTime [keyString + "Open"] = delayTimeOn;
|
} else {
|
room.DelayTime.Add (keyString + "Open", delayTimeOn);
|
}
|
if (room.DelayTime.ContainsKey (keyString + "Close")) {
|
room.DelayTime [keyString + "Close"] = delayTimeOff;
|
} else {
|
room.DelayTime.Add (keyString + "Close", delayTimeOff);
|
}
|
room.Save (typeof (Room).Name + "_" + room.Name);
|
}
|
if (lightLigicBytes [6] != rgbLight.RStatus || lightLigicBytes [7] != rgbLight.GStatus || lightLigicBytes [8] != rgbLight.BStatus) {
|
rgbLight.RStatus = lightLigicBytes [6];
|
rgbLight.GStatus = lightLigicBytes [7];
|
rgbLight.BStatus = lightLigicBytes [8];
|
IO.FileUtils.SaveEquipmentMessage (rgbLight, rgbLight.LoopID.ToString ());
|
}
|
dialog.Close ();
|
};
|
dialog.Show ();
|
});
|
} catch { } finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
|
tempSwitch.IsSelected = rgbLight.CurrentBrightness > 0 ? true : false;
|
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
var lightLigicBytes = Control.ControlBytesSendHasReturn (Command.ReadLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID });
|
if (lightLigicBytes != null) {
|
if (tempSwitch.IsSelected) {
|
rgbLight.CurrentBrightness = 100;
|
lightLigicBytes [1] = 100;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
} else {
|
rgbLight.CurrentBrightness = 0;
|
lightLigicBytes [1] = 0;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
}
|
}
|
});
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightSwitch || deviceCommon.Type == DeviceType.LightEnergySwitch || deviceCommon.Type == DeviceType.LightSwitchSocket) {
|
#region 继电器
|
LightSwitch switchLight = deviceCommon as LightSwitch;
|
tempSwitch.IsSelected = switchLight.CurrentBrightness == 100 ? true : false;
|
if (deviceCommon.Type == DeviceType.LightSwitchSocket) {
|
btnIcon.UnSelectedImagePath = "Light/Socket.png";
|
btnIcon.SelectedImagePath = "Light/Socket.png";
|
} else {
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
}
|
|
#if DEBUG
|
btnName.MouseLongEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
|
var bodyVV = new FrameLayout () {
|
BackgroundColor = 0xFF000000,
|
};
|
dialog.AddChidren (bodyVV);
|
|
var vView1 = new VerticalScrolViewLayout () {
|
Width = Application.GetRealWidth(320),
|
|
};
|
|
dialog.Show ();
|
};
|
#endif
|
|
if (deviceCommon.Type == DeviceType.LightEnergySwitch) {
|
Button btnEnergy = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (30),
|
X = tempSwitch.X,
|
Y = tempSwitch.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = DeviceType.LightEnergySwitch.ToString (),
|
Text = "0 W"
|
};
|
DeviceRowView.AddChidren (btnEnergy);
|
EnergtLightList.Add (deviceCommon);
|
}
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
switchLight.CurrentBrightness = 100;
|
Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 100, 0, 0 });
|
} else {
|
switchLight.CurrentBrightness = 0;
|
Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 0, 0, 0 });
|
}
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.CurtainModel) {
|
#region 窗帘
|
//CurtainModel comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainModel curtain = deviceCommon as CurtainModel;//(CurtainModel)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (curtain == null) {
|
// curtain = comm;
|
//}
|
tempSwitch.RemoveFromParent ();
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserCurtainPage curtainView = new UserCurtainPage (curtain, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (curtainView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (curtainView);
|
}
|
curtainView.showCurtainsRoom ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 1 });
|
} else {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 2 });
|
}
|
//System.Threading.Tasks.Task.Factory.StartNew (() => {
|
// System.Threading.Thread.Sleep (2000);
|
// Application.RunOnMainThread (() => {
|
// });
|
//});
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.CurtainTrietex) {
|
#region 开合帘窗帘
|
//CurtainTrietex comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainTrietex curtain = deviceCommon as CurtainTrietex;//(CurtainTrietex)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (curtain == null) {
|
// curtain = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserCurtainPage curtainView = new UserCurtainPage (curtain, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (curtainView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (curtainView);
|
}
|
curtainView.showCurtainsRoom ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 1 });
|
} else {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 2 });
|
}
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.CurtainRoller) {
|
#region 卷帘
|
//CurtainRoller comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainRoller curtain = deviceCommon as CurtainRoller;//(CurtainRoller)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (curtain == null) {
|
// curtain = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserCurtainPage curtainView = new UserCurtainPage (curtain, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (curtainView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (curtainView);
|
}
|
curtainView.showCurtainsRoom ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 1 });
|
} else {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 2 });
|
}
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.MusicModel) {
|
#region 音乐模块
|
//MusicModel comm = Newtonsoft.Json.JsonConvert.DeserializeObject<MusicModel> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
//MusicModel musicMode = (MusicModel)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (musicMode == null) {
|
// musicMode = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Item/Music.png";
|
btnIcon.SelectedImagePath = "Item/Music.png";
|
tempSwitch.Visible = false;
|
//tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
// tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
// if (tempSwitch.IsSelected) {
|
// //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 1 });
|
// } else {
|
// //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 2 });
|
// }
|
//};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.DryContact) {
|
#region 干接点
|
DryContact dc = deviceCommon as DryContact;// Newtonsoft.Json.JsonConvert.DeserializeObject<DryContact> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
btnIcon.UnSelectedImagePath = "Item/DryContact.png";
|
btnIcon.SelectedImagePath = "Item/DryContact.png";
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.InfraredMode) {
|
#region 红外电视
|
try {
|
InfraredMode infraredTV = deviceCommon as InfraredMode;// Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (infraredTV != null)
|
Console.WriteLine (infraredTV.InfraredType);
|
btnIcon.UnSelectedImagePath = "Item/InfraredTV.png";
|
btnIcon.SelectedImagePath = "Item/InfraredTV.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserTVFrameLayout fhView = new UserTVFrameLayout (infraredTV);
|
//UserMiddle.RoomPageView.AddChidren (fhView);
|
////fhView.Show ();
|
//fhView.ShowUserTV (tempSwitch);
|
//UserMiddle.RoomPageView.PageIndex = 2;
|
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (fhView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (fhView);
|
}
|
fhView.ShowUserTV (tempSwitch);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.RemoveFromParent ();
|
} catch (Exception ex) {
|
Console.WriteLine (ex.ToString ());
|
continue;
|
}
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.UniversalDevice) {
|
#region UniversalDevice
|
UniversalDevice udDevice = deviceCommon as UniversalDevice;
|
switch (udDevice.TargetType) {
|
case 0:
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
break;
|
case 1:
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
break;
|
case 2:
|
btnIcon.UnSelectedImagePath = "AC/AC.png";
|
btnIcon.SelectedImagePath = "AC/AC.png";
|
break;
|
default:
|
btnIcon.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
btnIcon.SelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
break;
|
}
|
tempSwitch.RemoveFromParent ();
|
tempSwitch = new Button () {
|
Width = Application.GetRealWidth (110),
|
Height = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (640 - 110 - 20),
|
Gravity = Gravity.CenterVertical,
|
Radius = 2,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
if (udDevice.ActionType == 0) {
|
tempSwitch.Text = udDevice.ON_Text == null ? Language.StringByID (R.MyInternationalizationString.ON) : udDevice.ON_Text;
|
//tempSwitch.TextID = R.MyInternationalizationString.ON;
|
} else if (udDevice.ActionType == 1) {
|
tempSwitch.Text = udDevice.OFF_Text == null ? Language.StringByID (R.MyInternationalizationString.OFF) : udDevice.OFF_Text;
|
//tempSwitch.TextID = R.MyInternationalizationString.OFF;
|
} else if (udDevice.ActionType == 2) {
|
tempSwitch.Text = udDevice.OFF_Text == null ? Language.StringByID (R.MyInternationalizationString.OFF) : udDevice.OFF_Text;
|
//tempSwitch.TextID = R.MyInternationalizationString.OFF;
|
|
Button tempON = new Button () {
|
Width = Application.GetRealWidth (110),
|
Height = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (640 - 250 - 20),
|
Gravity = Gravity.CenterVertical,
|
Radius = 2,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
Text = udDevice.ON_Text,
|
//TextID = R.MyInternationalizationString.ON,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (tempON);
|
tempON.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
|
}
|
};
|
tempON.MouseDownEventHandler += (sende3r, e3) => {
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
tempON.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
tempON.BorderColor = SkinStyle.Current.BorderColor;
|
});
|
});
|
};
|
}
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
if (udDevice.ActionType == 0) {
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
|
} else if (udDevice.ActionType == 1) {
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
|
} else if (udDevice.ActionType == 2) {
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
|
}
|
}
|
};
|
tempSwitch.MouseDownEventHandler += (sende3r, e3) => {
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
tempSwitch.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
tempSwitch.BorderColor = SkinStyle.Current.BorderColor;
|
});
|
});
|
};
|
#endregion
|
}
|
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
}
|
}
|
|
foreach (var scenFilePath in room.SceneFilePathList) {
|
Common devcieCommon = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (scenFilePath)));
|
if (devcieCommon == null)
|
continue;
|
var DeviceRowView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (93),
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Tag = devcieCommon.CommonLoopID
|
};
|
RoomView.AddChidren (DeviceRowView);
|
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical
|
};
|
DeviceRowView.AddChidren (btnIcon);
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = devcieCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.X + btnIcon.Width + Application.GetRealWidth (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (btnName);
|
|
Button tempSwitch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = devcieCommon.CommonLoopID
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
|
if (scenFilePath.Split ('_') [0].Contains ("Scene")) {
|
#region 场景
|
var scene = Scene.GetSceneByFilePath (scenFilePath);
|
btnIcon.UnSelectedImagePath = "Scene/Scene.png";
|
btnIcon.SelectedImagePath = "Scene/Scene.png";
|
tempSwitch.UnSelectedImagePath = "Item/UserSceneEditIcon.png";
|
tempSwitch.SelectedImagePath = "Item/UserSceneEditIcon.png";
|
tempSwitch.Y = Application.GetRealHeight (10);
|
|
tempSwitch.Width = Application.GetRealWidth (70);
|
tempSwitch.Height = Application.GetRealHeight (76);
|
btnName.MouseDownEventHandler += (sender2, e2) => {
|
btnIcon.IsSelected = btnName.IsSelected = true;
|
new System.Threading.Thread (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
});
|
}) { IsBackground = true }.Start ();
|
};
|
btnName.MouseUpEventHandler += (sender3, e3) => {
|
btnIcon.IsSelected = btnName.IsSelected = false;
|
new ScenePhoneMethod ().ControlScene (scenFilePath);
|
};
|
tempSwitch.MouseDownEventHandler += (sender, e) => {
|
tempSwitch.IsSelected = true;
|
};
|
tempSwitch.MouseUpEventHandler += (sender, e) => {
|
tempSwitch.IsSelected = false;
|
var sceneView = new UserAddSceneDevice (typeof (Room).Name + "_" + room.Name, scenFilePath);
|
UserMiddle.RoomPageView.AddChidren (sceneView);
|
sceneView.ShowScene ((newSceneFilePath) => {
|
try {
|
btnName.Tag = newSceneFilePath;
|
btnName.Text = newSceneFilePath.Split ('_') [2];
|
} catch { }
|
});
|
UserMiddle.RoomPageView.PageIndex = 2;
|
};
|
if (roomFilePath == Room.FavoriteRoom) {
|
tempSwitch.RemoveFromParent ();
|
}
|
#endregion
|
}
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
}
|
|
foreach (var deviceCommon in room.DeviceList) {
|
if (deviceCommon == null)
|
continue;
|
|
if (deviceCommon.Type == DeviceType.LogicModule) {
|
LogicModule lm = deviceCommon as LogicModule;
|
var DeviceRowView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (93),
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Tag = deviceCommon.CommonLoopID
|
};
|
RoomView.AddChidren (DeviceRowView);
|
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical
|
};
|
DeviceRowView.AddChidren (btnIcon);
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = deviceCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.X + btnIcon.Width + Application.GetRealWidth (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (btnName);
|
|
#region
|
btnIcon.UnSelectedImagePath = "Scene/Scene.png";
|
btnIcon.SelectedImagePath = "Scene/Scene.png";
|
btnName.MouseDownEventHandler += (sender2, e2) => {
|
btnIcon.IsSelected = btnName.IsSelected = true;
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
});
|
});
|
};
|
btnName.MouseUpEventHandler += (sender3, e3) => {
|
btnIcon.IsSelected = btnName.IsSelected = false;
|
Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
};
|
DeviceRowView.MouseUpEventHandler += (sender, e) => {
|
Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
};
|
#endregion
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
}
|
}
|
} catch (Exception ex) {
|
Console.WriteLine ("exddd :" + ex.ToString ());
|
} finally {
|
}
|
}
|
}
|
}
|