using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter
|
{
|
/// <summary>
|
/// 做成一个显示网关信息的RowLayout(左边有个图标)
|
/// </summary>
|
public class GatewayViewRow : StatuRowLayout
|
{
|
/// <summary>
|
/// 网关对象
|
/// </summary>
|
private ZbGateway m_zbGateway = null;
|
/// <summary>
|
/// 网关对象(优先缓存的网关对象,其次才是真实网关)
|
/// </summary>
|
public ZbGateway zbGateway
|
{
|
get { return m_zbGateway; }
|
set
|
{
|
string gwID = Common.LocalGateway.Current.GetGatewayId(value);
|
var way = Common.LocalGateway.Current.GetLocalGateway(gwID);
|
if (way != null)
|
{
|
m_zbGateway = way;
|
}
|
else
|
{
|
m_zbGateway = value;
|
}
|
}
|
}
|
/// <summary>
|
/// 图标控件
|
/// </summary>
|
public RowLeftIconView btnIcon = null;
|
/// <summary>
|
/// 显示文本控件
|
/// </summary>
|
public RowTopBlackView btnName = null;
|
/// <summary>
|
/// 在线状态的控件
|
/// </summary>
|
public RowSecondRightTextView btnOnline = null;
|
/// <summary>
|
/// IP的控件
|
/// </summary>
|
public RowBottomGrayView btnIP = null;
|
|
private bool m_IsOnline = false;
|
/// <summary>
|
/// 在线状态
|
/// </summary>
|
public bool IsOnline
|
{
|
get { return m_IsOnline; }
|
set
|
{
|
m_IsOnline = value;
|
//变更状态
|
this.SetOnlineStatu(m_IsOnline);
|
}
|
}
|
|
/// <summary>
|
/// 显示主或者子网关的字样
|
/// </summary>
|
private bool m_ShowMainGatewayTip = true;
|
/// <summary>
|
/// 显示主或者子网关的字样
|
/// </summary>
|
public bool ShowMainGatewayTip
|
{
|
get { return m_ShowMainGatewayTip; }
|
set
|
{
|
m_ShowMainGatewayTip = value;
|
//设置IP的文本信息
|
this.SetbtnIpText();
|
}
|
}
|
|
/// <summary>
|
/// 做成一个显示网关信息的RowLayout(左边有个图标)
|
/// </summary>
|
/// <param name="listView">列表控件</param>
|
/// <param name="i_zbGateway">网关对象</param>
|
public GatewayViewRow(VerticalScrolViewLayout listView, ZbGateway i_zbGateway)
|
{
|
this.m_zbGateway = i_zbGateway;
|
|
listView.AddChidren(this);
|
//初始化内部控件之前
|
this.InitControlBefore(i_zbGateway);
|
//初始化内部控件
|
this.InitControl();
|
}
|
|
/// <summary>
|
/// 做成一个显示网关信息的RowLayout(左边有个图标),添加此控件到容器后,调用【InitControl()】完成初始化
|
/// </summary>
|
/// <param name="i_zbGateway">网关对象</param>
|
public GatewayViewRow(ZbGateway i_zbGateway)
|
{
|
this.m_zbGateway = i_zbGateway;
|
|
//初始化内部控件之前
|
this.InitControlBefore(i_zbGateway);
|
}
|
|
/// <summary>
|
/// 初始化内部控件
|
/// </summary>
|
public void InitControl()
|
{
|
//图标
|
this.AddChidren(this.btnIcon);
|
|
//显示文本
|
this.AddChidren(this.btnName);
|
|
//IP
|
this.AddChidren(this.btnIP);
|
|
//在线状态
|
this.AddChidren(this.btnOnline, ChidrenBindMode.BindEventOnly);
|
}
|
|
/// <summary>
|
/// 刷新控件
|
/// </summary>
|
/// <param name="online"></param>
|
public void RefreshControl(bool online)
|
{
|
this.IsOnline = online;
|
this.btnName.Text = Common.LocalGateway.Current.GetGatewayName(this.m_zbGateway);
|
|
this.SetbtnIpText();
|
}
|
|
/// <summary>
|
/// 初始化内部控件之前
|
/// </summary>
|
/// <param name="i_zbGateway">网关</param>
|
private void InitControlBefore(ZbGateway i_zbGateway)
|
{
|
this.btnIcon = new RowLeftIconView();
|
Common.LocalGateway.Current.SetGatewayIcon(btnIcon, i_zbGateway);
|
|
this.btnName = new RowTopBlackView();
|
this.btnName.Text = Common.LocalGateway.Current.GetGatewayName(i_zbGateway);
|
if (this.btnName.Text == string.Empty)
|
{
|
//无法识别的网关设备
|
this.btnName.TextID = R.MyInternationalizationString.uUnDistinguishTheGatewayDevice;
|
}
|
|
this.btnOnline = new RowSecondRightTextView();
|
this.btnOnline.Radius = 4;
|
|
ZbGateway realWay = null;
|
bool bonline = false;
|
if (Common.LocalGateway.Current.GetRealGateway(ref realWay, i_zbGateway) == true)
|
{
|
bonline = Common.LocalGateway.Current.CheckGatewayOnlineByFlag(realWay);
|
}
|
this.SetOnlineStatu(bonline);
|
|
this.btnIP = new RowBottomGrayView();
|
//设置IP的文本信息
|
this.SetbtnIpText();
|
}
|
|
/// <summary>
|
/// 设置IP的文本信息
|
/// </summary>
|
private void SetbtnIpText()
|
{
|
this.btnIP.Text = Common.LocalGateway.Current.GetGatewayBaseInfoAttribute(this.m_zbGateway, "IpAddress").ToString();
|
if (string.IsNullOrEmpty(this.btnIP.Text) == false && m_ShowMainGatewayTip == true && this.m_IsOnline == true)
|
{
|
int result = Common.LocalGateway.Current.IsMainGateway(this.m_zbGateway);
|
if (result == 1)
|
{
|
//主网关
|
this.btnIP.Text += " (" + Language.StringByID(R.MyInternationalizationString.uMainGateway) + ")";
|
}
|
else if (result == 0)
|
{
|
//子网关
|
this.btnIP.Text += " (" + Language.StringByID(R.MyInternationalizationString.uChidrenGateway) + ")";
|
}
|
}
|
}
|
|
/// <summary>
|
/// 设置在线状态
|
/// </summary>
|
/// <param name="online"></param>
|
private void SetOnlineStatu(bool online)
|
{
|
m_IsOnline = online;
|
if (btnOnline == null)
|
{
|
return;
|
}
|
if (online == false)
|
{
|
//初始值:离线
|
btnOnline.TextID = R.MyInternationalizationString.uOffLine;
|
//初始值:灰色
|
btnOnline.TextColor = UserCenterColor.Current.Gray;
|
}
|
else
|
{
|
//在线
|
btnOnline.TextID = R.MyInternationalizationString.uOnline;
|
//绿色
|
btnOnline.TextColor = UserCenterColor.Current.Green;
|
}
|
}
|
}
|
}
|