From d8545fbd1b36a6766c57c987e5d89862b470fed9 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 03 九月 2020 09:46:29 +0800
Subject: [PATCH] 2020-09-03 1.修改风扇默认为关状态。2.Alexa添加设备时,去掉空调和通用开关选择添加支持。 3.场景增加通用开关添加和发送控制支持,Alexa 的场景同样增加通用开关的支持。
---
Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/UserAddSceneDevice.cs | 85 ++++++++++++++++++++++++++++++++----------
1 files changed, 65 insertions(+), 20 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/UserAddSceneDevice.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/UserAddSceneDevice.cs
index 12465b5..c725d7f 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/UserAddSceneDevice.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/UserAddSceneDevice.cs
@@ -1944,43 +1944,46 @@
Width = Application.GetRealWidth (110),
Height = Application.GetRealHeight (70),
Radius = 2,
- BorderColor = SkinStyle.Current.White20Transparent,
+ //BorderColor = SkinStyle.Current.White20Transparent,
BorderWidth = 2,
- Text = udDevice.ON_Text
+ Text = udDevice.ON_Text,
+ BorderColor = SkinStyle.Current.BorderColor,
+ TextColor = SkinStyle.Current.TextColor1,
+ //SelectedTextColor = SkinStyle.Current.TextColor1,
};
windBodyView.AddChidren (tempSiwtch);
if (udDevice.ActionType == 0) {
+ SetUDSendBytes (udDevice, 255);
tempSiwtch.Text = udDevice.ON_Text;
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
if (udDevice.UniversalType == 0xE01C) {
if (udDevice.ActionType == 0) {
- if (udDevice.SendBytes.Count == 0) {
- udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 255 };
- } else
- udDevice.SendBytes [1] = 255;
+ SetUDSendBytes (udDevice, 255);
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
}
tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor;
}
};
} else if (udDevice.ActionType == 1) {
+ SetUDSendBytes (udDevice, 0);
tempSiwtch.TextID = R.MyInternationalizationString.OFF;
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
if (udDevice.UniversalType == 0xE01C) {
if (udDevice.ActionType == 1) {
-
- if (udDevice.SendBytes.Count == 0) {
- udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 0 };
- } else
- udDevice.SendBytes [1] = 0;
+ SetUDSendBytes (udDevice, 0);
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
}
tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor;
}
};
} else if (udDevice.ActionType == 2) {
+ if (udDevice.SendBytes.Count == 0) {
+ //璧嬮粯璁ゅ��
+ udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 255 };
+ }
+
tempSiwtch.TextID = R.MyInternationalizationString.OFF;
tempSiwtch.X = Application.GetRealWidth (100);
tempSiwtch.Y = Application.GetRealHeight (100);
@@ -1993,15 +1996,13 @@
Radius = 2,
BorderColor = SkinStyle.Current.White20Transparent,
BorderWidth = 2,
- TextID = R.MyInternationalizationString.ON
+ TextID = R.MyInternationalizationString.ON,
+ TextColor = SkinStyle.Current.TextColor1,
};
windBodyView.AddChidren (tempON);
tempON.MouseUpEventHandler += (sender3, e3) => {
if (udDevice.UniversalType == 0xE01C) {
- if (udDevice.SendBytes.Count == 0) {
- udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 255 };
- } else
- udDevice.SendBytes [1] = 255;
+ SetUDSendBytes (udDevice, 255);
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
}
tempON.BorderColor = SkinStyle.Current.SelectedColor;
@@ -2009,15 +2010,21 @@
};
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
if (udDevice.UniversalType == 0xE01C) {
- if (udDevice.SendBytes.Count == 0) {
- udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 0 };
- } else
- udDevice.SendBytes [1] = 0;
+ SetUDSendBytes (udDevice, 0);
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
}
tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor;
tempON.BorderColor = SkinStyle.Current.Transparent;
};
+
+
+ if (udDevice.SendBytes [1] > 0) {
+ tempON.BorderColor = SkinStyle.Current.SelectedColor;
+ tempSiwtch.BorderColor = SkinStyle.Current.Transparent;
+ } else {
+ tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor;
+ tempON.BorderColor = SkinStyle.Current.Transparent;
+ }
}
btnSave.MouseUpEventHandler += (sender2, e2) => {
@@ -2028,6 +2035,43 @@
}
dialog.Show ();
}
+
+ /// <summary>
+ /// UniversalDevice
+ /// </summary>
+ /// <param name="udDevice"></param>
+ /// <param name="mStatus"> 255/0</param>
+ public void SetUDSendBytes (UniversalDevice udDevice, byte mStatus) {
+
+ if (udDevice.SendBytes.Count == 0) {
+ udDevice.SendBytes = new List<byte> () { udDevice.LoopID, mStatus };
+ } else {
+ udDevice.SendBytes [1] = mStatus;
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁ActionType鐘舵�侊紝璧嬮粯璁ゅ��
+ /// </summary>
+ /// <param name="udDevice"></param>
+ /// <param name="mStatus"></param>
+ public void SetUDDefaultsSendBytes (UniversalDevice udDevice)
+ {
+ if (udDevice == null) return;
+
+ //鍙紑銆佸紑鍏� 閮介粯璁や负255
+ if (udDevice.SendBytes.Count == 0) {
+ udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 255 };
+ } else {
+ udDevice.SendBytes [1] = 255;
+ }
+
+ //鍙叧銆侀噸缃负0
+ if (udDevice.ActionType == 1) {
+ udDevice.SendBytes [1] = 0;
+ }
+ }
+
/// <summary>
/// 鎴块棿鍜屽満鏅坊鍔犺澶囩殑鏂规硶
@@ -2436,6 +2480,7 @@
break;
case DeviceType.UniversalDevice:
var sssd = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ SetUDDefaultsSendBytes (sssd);
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (sssd)));
break;
default:
--
Gitblit v1.8.0