using System; using HDL_ON.DriverLayer; using HDL_ON.Entity; using Shared; namespace HDL_ON.UI { public partial class SocketPage { /// /// 更新灯光状态 /// public static void UpdataState(SwitchSocket uFan) { Application.RunOnMainThread(() => { try { if (bodyView == null) return; bodyView.btnSwitch.IsSelected = bodyView.btnSwitchIcon.IsSelected = uFan.trait_on_off.value.ToString() == "on"; } catch (Exception ex) { MainPage.Log($"RelayPage error {ex.Message}"); } }); } /// /// 加载事件列表 /// void LoadEventList() { LoadSwitchEvent(); LoadCollectionEvent(); //回退刷新信息事件 actionRefresh = () => { btnFunctionName.Text = btnFunctionName_Out.Text = socketFunction.name; btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = socketFunction.GetRoomListName(); }; } /// /// 收藏功能按钮事件 /// void LoadCollectionEvent() { btnCollection.MouseUpEventHandler += (sender, e) => { btnCollection.IsSelected = socketFunction.collection = btnCollection_Out.IsSelected = !btnCollection.IsSelected; socketFunction.SaveFunctionData(); }; } /// /// 加载开关事件 /// void LoadSwitchEvent() { btnSwitchIcon.MouseUpEventHandler += (sender, e) => { btnSwitchIcon.IsSelected = !btnSwitchIcon.IsSelected; new System.Threading.Thread(() => { socketFunction.trait_on_off.value = btnSwitch.IsSelected ? "on" : "off"; //Control.Send(CommandType_A.write, this.socketFunction); System.Collections.Generic.Dictionary d = new System.Collections.Generic.Dictionary(); d.Add("on_off", socketFunction.trait_on_off.value.ToString()); Control.ins.SendWriteCommand(socketFunction, d); }) { IsBackground = true }.Start(); }; btnSwitch.MouseUpEventHandler += (sender, e) => { btnSwitch.IsSelected = !btnSwitch.IsSelected; new System.Threading.Thread(() => { socketFunction.trait_on_off.value = btnSwitch.IsSelected ? "on" : "off"; //Control.Send(CommandType_A.write, this.socketFunction); System.Collections.Generic.Dictionary d = new System.Collections.Generic.Dictionary(); d.Add("on_off", socketFunction.trait_on_off.value.ToString()); Control.ins.SendWriteCommand(socketFunction, d); }) { IsBackground = true }.Start(); }; } } }