using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.Category.Controls
{
///
/// 分类界面的空气开关设备行控件
///
public class DeviceAirSwitchRowControl : DeviceRowCommon
{
#region ■ 初始化_____________________________
///
/// 分类界面的空气开关设备行控件
///
/// 子控件Y轴偏移量(真实值,有些界面需要这种特殊操作)
public DeviceAirSwitchRowControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
{
}
///
/// 初始化控件
///
///
public override void InitControl(CommonDevice i_device)
{
base.InitControl(i_device);
//添加跳转深度卡片信息事件
this.AddDetailInfoEvent(i_device);
//添加开关控件
var btnSwitch = this.AddSwitchControl();
btnSwitch.ButtonClickEvent += (sender, e) =>
{
bool setStatu = !btnSwitch.IsSelected;
//变更卡片状态
this.SetRowOpenStatu(setStatu);
//检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
this.StartCheckResponeResult(!setStatu);
if (setStatu == true)
{
//打开
this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.uOpen1));
i_device.SwitchControl(1);
}
else
{
//关闭
this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.Close));
i_device.SwitchControl(0);
}
};
}
#endregion
#region ■ 深度卡片信息_______________________
///
/// 添加跳转深度卡片信息事件
///
private void AddDetailInfoEvent(CommonDevice i_device)
{
//深度卡片信息
this.frameTable.ButtonClickEvent += (sender, e) =>
{
int backHeight = 0;
if (i_device.DfunctionType == DeviceFunctionType.A开关)
{
backHeight = 1290;
}
else if (i_device.DfunctionType == DeviceFunctionType.A插座)
{
backHeight = 1290;
}
else
{
backHeight = 1316;
}
//继电器类型的深度卡片界面(含空气开关)
var form = new MainPage.ControlForm.DeviceRelayDetailCardForm();
form.AddForm(i_device, UserCenter.HdlRoomLogic.Current.CurrentRoom, 965, backHeight);
form.FormCloseEvent += this.CardDetailInfoBackEvent;
};
}
#endregion
#region ■ 检测设备打开状态___________________
///
/// 检测设备打开状态
///
///
///
public override bool CheckIsOpenStatu(CommonDevice i_device)
{
return ((LightBase)i_device).OnOffStatus == 1;
}
#endregion
#region ■ 发送获取状态命令___________________
///
/// 发送获取状态命令
///
public override void SendStatuComand()
{
//检测能否发送获取状态命令
if (this.CheckCanSendStatuComand() == true)
{
HdlDeviceAttributeLogic.Current.SendLightStatuComand(this.device);
}
}
#endregion
}
}