From 5428935270159bfc42c2934ed7fb1091554fc9a4 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 09 七月 2020 17:12:42 +0800
Subject: [PATCH] 修改了 sokect
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs | 128 +++++++++++++++++++++++++++---------------
1 files changed, 81 insertions(+), 47 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs
index 3d6dcec..cc6932b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs
@@ -20,24 +20,27 @@
/// </summary>
private bool hadRefresh = false;
/// <summary>
- /// 鍦ㄧ嚎鐘舵��
- /// </summary>
- private bool m_isOnline = false;
- /// <summary>
/// 浼犳劅鍣ㄦ帹閫佷腑
/// </summary>
private bool sensorPushing = false;
/// <summary>
/// 鍦ㄧ嚎鐘舵��
/// </summary>
- public bool isOnline
+ private bool m_isOnline = true;
+ /// <summary>
+ /// 鍦ㄧ嚎鐘舵��
+ /// </summary>
+ public bool IsOnline
{
get { return m_isOnline; }
set
{
- m_isOnline = value;
- //璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥
- this.SetOnlineStatu(m_isOnline);
+ if (m_isOnline != value)
+ {
+ m_isOnline = value;
+ //璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥
+ this.SetOnlineStatu(m_isOnline);
+ }
}
}
@@ -62,7 +65,7 @@
/// 鍋氭垚涓�涓樉绀鸿澶囩被鍨�+璁惧MAC澶囨敞鐨凴owLayout
/// </summary>
/// <param name="i_deviceMac">璁惧鐨凪ac鍦板潃</param>
- /// <param name="i_ChidrenYaxis">瀛愭帶浠禮杞村亸绉婚噺(鐪熷疄鍊�,鏈変簺鐣岄潰闇�瑕佽繖绉嶇壒娈婃搷浣�)</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;
@@ -74,34 +77,29 @@
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.SetDeviceBeloneIconToControl(btnIcon, listDevice);
+ Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice);
//璁惧
string deviceName = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]);
- btnDeviceName = frameTable.AddLeftCaption(deviceName, 800, 60, true);
- btnDeviceName.TextSize = 15;
- //杩欎釜鍧愭爣鏈夌偣鐗规畩
- btnDeviceName.Y = Application.GetRealHeight(12) + this.chidrenYaxis;
- btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceObjectText(listDevice);
- frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly);
+ btnDeviceName = frameTable.AddTopView(deviceName, 800);
+ frameTable.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
//鎴块棿
string roomName = Common.LocalDevice.Current.GeteRealDeviceRoomName(listDevice[0]);
- btnDeviceRoom = frameTable.AddLeftCaption(roomName, 800, 49, true);
- //杩欎釜鍧愭爣鏈夌偣鐗规畩
- btnDeviceRoom.Y = Application.GetRealHeight(72) + this.chidrenYaxis;
- btnDeviceRoom.TextSize = 12;
- btnDeviceRoom.TextColor = UserCenterColor.Current.TextGrayColor1;
- btnDeviceRoom.Text = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]);
- frameTable.AddChidren(btnDeviceRoom, ChidrenBindMode.BindEventOnly);
+ btnDeviceRoom = frameTable.AddBottomView(roomName, 800);
//搴曠嚎
frameTable.AddBottomLine();
//璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥
- this.isOnline = listDevice[0].IsOnline == 1;
+ this.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(listDevice[0]);
}
#endregion
@@ -111,10 +109,10 @@
/// <summary>
/// 璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥
/// </summary>
- /// <param name="isOnline"></param>
- private void SetOnlineStatu(bool isOnline)
+ /// <param name="i_isOnline"></param>
+ private void SetOnlineStatu(bool i_isOnline)
{
- if (isOnline == false)
+ if (i_isOnline == false)
{
btnDeviceName.TextColor = UserCenterColor.Current.TextGrayColor1;
}
@@ -137,14 +135,17 @@
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.SetDeviceBeloneIconToControl(btnIcon, listDevice);
+ Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice);
//璁惧
btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]);
//璁惧鎴块棿
btnDeviceRoom.Text = Common.LocalDevice.Current.GeteRealDeviceRoomName(listDevice[0]);
- //璁剧疆鍦ㄧ嚎鐘舵�佺殑鐗规晥
- this.isOnline = listDevice[0].IsOnline == 1;
}
@@ -159,27 +160,60 @@
return;
}
this.sensorPushing = true;
- //璁惧
- uint oldTextColor1 = btnDeviceName.TextColor;
- btnDeviceName.TextColor = UserCenterColor.Current.TextOrangeColor;
- //璁惧鎴块棿
- uint oldTextColor2 = btnDeviceRoom.TextColor;
- btnDeviceRoom.TextColor = UserCenterColor.Current.TextOrangeColor;
+
HdlThreadLogic.Current.RunThread(() =>
{
- System.Threading.Thread.Sleep(5000);
- HdlThreadLogic.Current.RunMain(() =>
+ //闂儊5绉�,闂撮殧400姣
+ int count = 5000 / 400;
+ bool isOpen = false;
+ while (this.Parent != null && count >= 0)
{
- if (btnDeviceName.Parent != null)
+ //闂儊鐗规晥
+ HdlThreadLogic.Current.RunMain(() =>
{
- //璁惧
- btnDeviceName.TextColor = oldTextColor1;
- //璁惧鎴块棿
- btnDeviceRoom.TextColor = oldTextColor2;
- }
- this.sensorPushing = false;
- }, ShowErrorMode.NO);
- });
+ 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