From b02e8275a21dc06bf54b66273485d44e007a2616 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 20 七月 2020 14:50:17 +0800 Subject: [PATCH] 新代码 --- ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceCurtainRowControl.cs | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 219 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceCurtainRowControl.cs b/ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceCurtainRowControl.cs new file mode 100755 index 0000000..76535ea --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceCurtainRowControl.cs @@ -0,0 +1,219 @@ +锘縰sing Shared.Phone.UserCenter; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.Category.Controls +{ + /// <summary> + /// 鍒嗙被鐣岄潰鐨勭獥甯樿澶囪鎺т欢 + /// </summary> + public class DeviceCurtainRowControl : DeviceRowCommon + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鎵撳紑鎺т欢 + /// </summary> + private MostRightIconControl btnOpen = null; + /// <summary> + /// 鍋滄鎺т欢 + /// </summary> + private MostRightIconControl btnStop = null; + /// <summary> + /// 鍏抽棴鎺т欢 + /// </summary> + private MostRightIconControl btnClose = null; + /// <summary> + /// 绐楀笜绫诲瀷 4锛氬紑鍚堝笜 0锛氬嵎甯� + /// </summary> + private int WcdType = -2; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + /// <param name="i_device"></param> + 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 鈻� 娣卞害鍗$墖淇℃伅_______________________ + + /// <summary> + /// 娣诲姞璺宠浆娣卞害鍗$墖淇℃伅浜嬩欢 + /// </summary> + 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 鈻� 妫�娴嬭澶囨墦寮�鐘舵�乢__________________ + + /// <summary> + /// 妫�娴嬭澶囨墦寮�鐘舵�� + /// </summary> + /// <param name="i_device"></param> + /// <returns></returns> + public override bool CheckIsOpenStatu(CommonDevice i_device) + { + return ((Rollershade)i_device).WcdCurrentPositionLiftPercentage > 0; + } + + #endregion + + #region 鈻� 鍙戦�佽幏鍙栫姸鎬佸懡浠__________________ + + /// <summary> + /// 鍙戦�佽幏鍙栫姸鎬佸懡浠� + /// </summary> + 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 鈻� 鍒锋柊鎺т欢鐘舵�乢______________________ + + /// <summary> + /// 鍒锋柊鎺т欢鐘舵�� + /// </summary> + /// <param name="i_device"></param> + public override void RefreshControlInfo(CommonDevice i_device) + { + //鍒锋柊鍥炬爣鎺т欢鐨勫浘鏍� + this.RefreshIconControlImage(i_device); + + base.RefreshControlInfo(i_device); + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鍒锋柊鍥炬爣鎺т欢鐨勫浘鏍� + /// </summary> + /// <param name="i_device"></param> + 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 + } +} -- Gitblit v1.8.0