From f500e14c0a994487070380c50c85e0929cbc8e63 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 05 一月 2021 10:48:04 +0800 Subject: [PATCH] 2021-01-05 1.更新 --- 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