From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs new file mode 100755 index 0000000..cc6932b --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs @@ -0,0 +1,221 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 鍋氭垚涓�涓樉绀鸿澶囩被鍨�+璁惧MAC澶囨敞鐨凴owLayout + /// </summary> + public class DeviceObjectControl : RowLayoutControl + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁惧鐨凪ac鍦板潃 + /// </summary> + public string deviceMac = string.Empty; + /// <summary> + /// 鍙細鍒锋柊涓�娆� + /// </summary> + private bool hadRefresh = false; + /// <summary> + /// 浼犳劅鍣ㄦ帹閫佷腑 + /// </summary> + private bool sensorPushing = false; + /// <summary> + /// 鍦ㄧ嚎鐘舵�� + /// </summary> + private bool m_isOnline = true; + /// <summary> + /// 鍦ㄧ嚎鐘舵�� + /// </summary> + public bool IsOnline + { + get { return m_isOnline; } + set + { + if (m_isOnline != value) + { + m_isOnline = value; + //璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥 + this.SetOnlineStatu(m_isOnline); + } + } + } + + /// <summary> + /// 鍥炬爣鎺т欢 + /// </summary> + public IconViewControl btnIcon = null; + /// <summary> + /// 璁惧澶囨敞鎺т欢 + /// </summary> + private NormalViewControl btnDeviceName = null; + /// <summary> + /// 璁惧鎴块棿鎺т欢 + /// </summary> + private NormalViewControl btnDeviceRoom = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鍋氭垚涓�涓樉绀鸿澶囩被鍨�+璁惧MAC澶囨敞鐨凴owLayout + /// </summary> + /// <param name="i_deviceMac">璁惧鐨凪ac鍦板潃</param> + /// <param name="i_ChidrenYaxis">瀛愭帶浠禮杞村亸绉婚噺(銆愬垪琛ㄦ帶浠剁殑rowSpace/2銆戝嵆鍙�,涓嶆噦榛樿涓�0鍗冲彲)</param> + public DeviceObjectControl(string i_deviceMac, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis) + { + this.deviceMac = i_deviceMac; + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + var listDevice = Common.LocalDevice.Current.GetDevicesByMac(this.deviceMac); + if (listDevice.Count == 0) + { + //閽堝鍗曠函鍙湁涓�涓�200绔偣鐨勮澶� + listDevice.Add(Common.LocalDevice.Current.GetOTADevice(this.deviceMac)); + } + //鍥炬爣 + btnIcon = frameTable.AddLeftIcon(81); + Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice); + + //璁惧 + string deviceName = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]); + btnDeviceName = frameTable.AddTopView(deviceName, 800); + frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent); + + //鎴块棿 + string roomName = Common.LocalDevice.Current.GeteRealDeviceRoomName(listDevice[0]); + btnDeviceRoom = frameTable.AddBottomView(roomName, 800); + + //搴曠嚎 + frameTable.AddBottomLine(); + + //璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥 + this.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(listDevice[0]); + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥 + /// </summary> + /// <param name="i_isOnline"></param> + private void SetOnlineStatu(bool i_isOnline) + { + if (i_isOnline == false) + { + btnDeviceName.TextColor = UserCenterColor.Current.TextGrayColor1; + } + else + { + btnDeviceName.TextColor = UserCenterColor.Current.TextColor1; + } + } + + /// <summary> + /// 鍒锋柊鍏ㄩ儴鏄剧ず淇℃伅 + /// </summary> + /// <param name="compel">鏄惁寮哄埗鎵ц</param> + public void RefreshControlInfo(bool compel = false) + { + if (hadRefresh == true && compel == false) + { + return; + } + hadRefresh = true; + + var listDevice = Common.LocalDevice.Current.GetDevicesByMac(this.deviceMac); + if (listDevice.Count == 0) + { + //閽堝鍗曠函鍙湁涓�涓�200绔偣鐨勮澶� + listDevice.Add(Common.LocalDevice.Current.GetOTADevice(this.deviceMac)); + } + //鍥炬爣 + Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice); + //璁惧 + btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]); + //璁惧鎴块棿 + btnDeviceRoom.Text = Common.LocalDevice.Current.GeteRealDeviceRoomName(listDevice[0]); + } + + + /// <summary> + /// 鏄剧ず浼犳劅鍣ㄤ笂鎶ョ殑鐗规晥 + /// </summary> + public void StartSensorPushAppeal() + { + if (this.sensorPushing == true) + { + //浼犳劅鍣ㄦ鍦ㄧ壒鏁堜腑 + return; + } + this.sensorPushing = true; + + HdlThreadLogic.Current.RunThread(() => + { + //闂儊5绉�,闂撮殧400姣 + int count = 5000 / 400; + bool isOpen = false; + while (this.Parent != null && count >= 0) + { + //闂儊鐗规晥 + HdlThreadLogic.Current.RunMain(() => + { + isOpen = !isOpen; + this.SwitchRowStatuAppeal(isOpen); + }, ShowErrorMode.NO); + System.Threading.Thread.Sleep(400); + count--; + } + if (this.Parent != null && isOpen == true) + { + HdlThreadLogic.Current.RunMain(() => + { + //缁撴潫鏃�,榛樿涓烘棤鐗规晥 + this.SwitchRowStatuAppeal(false); + }, ShowErrorMode.NO); + } + this.sensorPushing = false; + + }, ShowErrorMode.NO); + } + + /// <summary> + /// 鍒囨崲琛岄棯鐑佺壒鏁� + /// </summary> + /// <param name="isOpen"></param> + private void SwitchRowStatuAppeal(bool isOpen) + { + if (isOpen == true) + { + //鍥炬爣 + btnIcon.IsSelected = true; + //璁惧 + btnDeviceName.TextColor = UserCenterColor.Current.TextOrangeColor; + //璁惧鎴块棿 + btnDeviceRoom.TextColor = UserCenterColor.Current.TextOrangeColor; + } + else + { + //鍥炬爣 + btnIcon.IsSelected = false; + //璁惧 + btnDeviceName.TextColor = UserCenterColor.Current.TextColor1; + //璁惧鎴块棿 + btnDeviceRoom.TextColor = UserCenterColor.Current.TextGrayColor1; + } + } + + #endregion + } +} -- Gitblit v1.8.0