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/DeviceInfoIconControl.cs | 121 +++++++++++++++++++++++++++++++++-------
1 files changed, 99 insertions(+), 22 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceInfoIconControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceInfoIconControl.cs
index b0c3624..863d55a 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceInfoIconControl.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceInfoIconControl.cs
@@ -6,20 +6,24 @@
namespace Shared.Phone.UserCenter
{
/// <summary>
- /// 璁惧淇℃伅鐣岄潰鐨勮澶囧浘鏍囨帶浠�
+ /// 璁惧淇℃伅鐣岄潰鐨勮澶囧浘鏍囨帶浠�(鍏煎缃戝叧)
/// </summary>
- public class DeviceInfoIconControl : FrameLayout
+ public class DeviceInfoIconControl : FrameLayoutStatuControl
{
#region 鈻� 鍙橀噺澹版槑___________________________
/// <summary>
/// 璁惧Mac鍦板潃
/// </summary>
- private string deviceMac = string.Empty;
+ private string deviceMac = null;
/// <summary>
/// 璁惧绔偣
/// </summary>
- private int deviceEpoint = 0;
+ private int deviceEpoint = -1;
+ /// <summary>
+ /// 缃戝叧瀵硅薄
+ /// </summary>
+ private ZbGateway zbGateway = null;
/// <summary>
/// 鍥炬爣鎺т欢
/// </summary>
@@ -32,36 +36,90 @@
/// <summary>
/// 璁惧淇℃伅鐣岄潰鐨勮澶囧浘鏍囨帶浠�
/// </summary>
- /// <param name="i_device">璁惧鍥炶矾瀵硅薄</param>
- public DeviceInfoIconControl(CommonDevice i_device)
+ public DeviceInfoIconControl()
{
- deviceMac = i_device.DeviceAddr;
- deviceEpoint = i_device.DeviceEpoint;
-
//绗竴灞傚簳鑹�
- this.Height = Application.GetMinRealAverage(207);
- this.Width = Application.GetMinRealAverage(207);
+ this.Height = this.GetPictrueRealSize(207);
+ this.Width = this.GetPictrueRealSize(207);
this.BackgroundColor = UserCenterColor.Current.White;
- this.Radius = (uint)Application.GetMinRealAverage(207);
+ this.Radius = (uint)this.GetPictrueRealSize(207) / 2;
+ this.UseClickStatu = false;
}
/// <summary>
- /// 鍒濆鍖�
+ /// 鍒濆鍖�(璁惧)
/// </summary>
- public void InitControl()
+ /// <param name="i_device">璁惧瀵硅薄</param>
+ public void InitControl(CommonDevice i_device)
{
+ this.deviceMac = i_device.DeviceAddr;
+ //闃叉鍑虹幇璇樊
+ int iconWidth = this.GetPictrueRealSize(207) - this.GetPictrueRealSize(12) - this.GetPictrueRealSize(12);
//绗簩灞傚簳鑹�
- var btnIcon2 = new NormalViewControl(Application.GetMinRealAverage(184), Application.GetMinRealAverage(184), false);
+ var btnIcon2 = new NormalViewControl(iconWidth, iconWidth, false);
btnIcon2.BackgroundColor = 0xfffef1ed;
- btnIcon2.Radius = (uint)Application.GetMinRealAverage(184);
+ btnIcon2.Radius = (uint)iconWidth / 2;
btnIcon2.Gravity = Gravity.Center;
- this.AddChidren(btnIcon2);
+ this.AddChidren(btnIcon2, ChidrenBindMode.BindEvent);
//璁惧鍥炬爣
- btnIcon = new NormalViewControl(Application.GetMinRealAverage(121), Application.GetMinRealAverage(121), false);
+ var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
+ if (listDevice.Count == 0)
+ {
+ //瀵瑰簲鍗曠函鍙湁200鍥炶矾鐨勮澶�
+ listDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac));
+ }
+ btnIcon = new NormalViewControl(this.GetPictrueRealSize(121), this.GetPictrueRealSize(121), false);
btnIcon.Gravity = Gravity.Center;
- Common.LocalDevice.Current.SetDeviceBeloneIconToControl(btnIcon, Common.LocalDevice.Current.GetDevicesByMac(deviceMac));
- this.AddChidren(btnIcon);
+ Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice);
+ this.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
+ }
+
+ /// <summary>
+ /// 鍒濆鍖�(璁惧绔偣)
+ /// </summary>
+ /// <param name="i_device">璁惧瀵硅薄</param>
+ public void InitControl(string deviceMacAddr, int epoint)
+ {
+ this.deviceMac = deviceMacAddr;
+ this.deviceEpoint = epoint;
+ //闃叉鍑虹幇璇樊
+ int iconWidth = this.GetPictrueRealSize(207) - this.GetPictrueRealSize(12) - this.GetPictrueRealSize(12);
+ //绗簩灞傚簳鑹�
+ var btnIcon2 = new NormalViewControl(iconWidth, iconWidth, false);
+ btnIcon2.BackgroundColor = 0xfffef1ed;
+ btnIcon2.Radius = (uint)iconWidth / 2;
+ btnIcon2.Gravity = Gravity.Center;
+ this.AddChidren(btnIcon2, ChidrenBindMode.BindEvent);
+
+ //璁惧鍥炬爣
+ btnIcon = new NormalViewControl(this.GetPictrueRealSize(121), this.GetPictrueRealSize(121), false);
+ btnIcon.Gravity = Gravity.Center;
+ Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, Common.LocalDevice.Current.GetDevice(deviceMacAddr, epoint));
+ this.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
+ }
+
+ /// <summary>
+ /// 鍒濆鍖�(缃戝叧)
+ /// </summary>
+ /// <param name="i_gateway">缃戝叧瀵硅薄</param>
+ public void InitControl(ZbGateway i_gateway)
+ {
+ this.zbGateway = i_gateway;
+ //闃叉鍑虹幇璇樊
+ int iconWidth = this.GetPictrueRealSize(207) - this.GetPictrueRealSize(12) - this.GetPictrueRealSize(12);
+ //绗簩灞傚簳鑹�
+ var btnIcon2 = new NormalViewControl(iconWidth, iconWidth, false);
+ btnIcon2.BackgroundColor = 0xfffef1ed;
+ btnIcon2.Radius = (uint)iconWidth / 2;
+ btnIcon2.Gravity = Gravity.Center;
+ this.AddChidren(btnIcon2, ChidrenBindMode.BindEvent);
+
+ //璁惧鍥炬爣
+ btnIcon = new NormalViewControl(this.GetPictrueRealSize(121), this.GetPictrueRealSize(121), false);
+ btnIcon.Gravity = Gravity.Center;
+ HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, i_gateway);
+ this.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
}
#endregion
@@ -73,8 +131,27 @@
/// </summary>
public void RefreshControl()
{
- //鍒锋柊鍥炬爣
- Common.LocalDevice.Current.SetDeviceBeloneIconToControl(btnIcon, Common.LocalDevice.Current.GetDevicesByMac(deviceMac));
+ if (this.deviceEpoint != -1)
+ {
+ //鍒锋柊鍥炬爣
+ Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, Common.LocalDevice.Current.GetDevice(this.deviceMac, this.deviceEpoint));
+ }
+ else if (this.deviceMac != null)
+ {
+ //鍒锋柊鍥炬爣
+ var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
+ if (listDevice.Count == 0)
+ {
+ //瀵瑰簲鍗曠函鍙湁200鍥炶矾鐨勮澶�
+ listDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac));
+ }
+ Common.LocalDevice.Current.SetDeviceObjectIconToControl(btnIcon, listDevice);
+ }
+ else
+ {
+ //鍒锋柊鍥炬爣
+ HdlGatewayLogic.Current.SetGatewayIcon(btnIcon, this.zbGateway);
+ }
}
#endregion
--
Gitblit v1.8.0