using Shared.Phone.UserCenter; using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.Category.Controls { /// /// 分类界面的窗帘设备行控件 /// public class DeviceCurtainRowControl : DeviceRowCommon { #region ■ 变量声明___________________________ /// /// 打开控件 /// private MostRightIconControl btnOpen = null; /// /// 停止控件 /// private MostRightIconControl btnStop = null; /// /// 关闭控件 /// private MostRightIconControl btnClose = null; /// /// 窗帘类型 4:开合帘 0:卷帘 /// private int WcdType = -2; #endregion #region ■ 初始化_____________________________ /// /// 初始化控件 /// /// public override void InitControl(CommonDevice i_device, Common.Room i_nowSelectRoom) { base.InitControl(i_device, i_nowSelectRoom); //添加跳转深度卡片信息事件 this.AddDetailInfoEvent(i_device); //打开控件 this.btnOpen = new MostRightIconControl(69, 69); btnOpen.btnIcon.UseClickStatu = true; this.frameTable.AddChidren(btnOpen, ChidrenBindMode.NotBind); btnOpen.InitControl(); btnOpen.X = Application.GetRealWidth(625) - btnOpen.XOffset; btnOpen.ButtonClickEvent += (sender, e) => { //如果住宅为虚拟住宅,直接修改缓存 if (Common.Config.Instance.Home.IsVirtually == true) { ((Rollershade)i_device).WcdCurrentPositionLiftPercentage = 100; base.RefreshControlInfo(i_device); return; } ((Rollershade)i_device).CurtainUpDownStopControl(0); }; //停止控件 this.btnStop = new MostRightIconControl(69, 69); btnStop.btnIcon.UseClickStatu = true; btnStop.UnSelectedImagePath = "RollerShade/Stop.png"; btnStop.SelectedImagePath = "RollerShade/StopSelected.png"; this.frameTable.AddChidren(btnStop, ChidrenBindMode.NotBind); btnStop.InitControl(); btnStop.X = Application.GetRealWidth(769) - btnOpen.XOffset; btnStop.ButtonClickEvent += (sender, e) => { //如果住宅为虚拟住宅,此功能无效 if (Common.Config.Instance.Home.IsVirtually == false) { ((Rollershade)i_device).CurtainUpDownStopControl(2); } }; //关闭 this.btnClose = new MostRightIconControl(69, 69); btnClose.btnIcon.UseClickStatu = true; this.frameTable.AddChidren(btnClose, ChidrenBindMode.NotBind); btnClose.InitControl(); btnClose.X = Application.GetRealWidth(896) - btnOpen.XOffset; btnClose.ButtonClickEvent += (sender, e) => { //如果住宅为虚拟住宅,直接修改缓存 if (Common.Config.Instance.Home.IsVirtually == true) { ((Rollershade)i_device).WcdCurrentPositionLiftPercentage = 0; base.RefreshControlInfo(i_device); return; } ((Rollershade)i_device).CurtainUpDownStopControl(1); }; //刷新图标控件的图标 this.RefreshIconControlImage(i_device); } #endregion #region ■ 深度卡片信息_______________________ /// /// 添加跳转深度卡片信息事件 /// private void AddDetailInfoEvent(CommonDevice i_device) { //深度卡片信息 this.frameTable.ButtonClickEvent += (sender, e) => { //窗帘类型的深度卡片界面 var form = new MainPage.ControlForm.DeviceCurtainDetailCardForm(); form.RowOrCardControl = this; form.AddForm(i_device, this.nowSelectRoom, 965, 1316); form.FormCloseEvent += this.CardDetailInfoBackEvent; }; } #endregion #region ■ 检测设备打开状态___________________ /// /// 检测设备打开状态 /// /// /// public override bool CheckIsOpenStatu(CommonDevice i_device) { return ((Rollershade)i_device).WcdCurrentPositionLiftPercentage > 0; } #endregion #region ■ 发送获取状态命令___________________ /// /// 发送获取状态命令 /// public override void SendStatuComand() { //如果住宅为虚拟住宅,此功能无效 if (Common.Config.Instance.Home.IsVirtually == true) { return; } //检测能否发送获取状态命令 if (this.CheckCanSendStatuComand() == true) { HdlDeviceAttributeLogic.Current.SendCurtainStatuComand(this.device); } if (((Rollershade)this.device).WcdType == -1) { //读取窗帘类型 ((Rollershade)this.device).ReadWcdType(); } } #endregion #region ■ 刷新控件状态_______________________ /// /// 刷新控件状态 /// /// public override void RefreshControlInfo(CommonDevice i_device) { //刷新图标控件的图标 this.RefreshIconControlImage(i_device); base.RefreshControlInfo(i_device); } #endregion #region ■ 一般方法___________________________ /// /// 刷新图标控件的图标 /// /// private void RefreshIconControlImage(CommonDevice i_device) { //还没有初始化完成 if (btnOpen == null) { return; } int wcdType = ((Rollershade)i_device).WcdType; if (this.WcdType == wcdType) { //无需变更 return; } this.WcdType = wcdType; if (this.WcdType == 0) { btnOpen.UnSelectedImagePath = "RollerShade/Up.png"; btnOpen.SelectedImagePath = "RollerShade/UpSelected.png"; btnClose.UnSelectedImagePath = "RollerShade/Down.png"; btnClose.SelectedImagePath = "RollerShade/DownSelected.png"; } else { btnOpen.UnSelectedImagePath = "RollerShade/Open.png"; btnOpen.SelectedImagePath = "RollerShade/OpenSelected.png"; btnClose.UnSelectedImagePath = "RollerShade/Close.png"; btnClose.SelectedImagePath = "RollerShade/CloseSelected.png"; } } #endregion } }