From bba578c2f0acf2eca747edcb69426771e0cadd32 Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期一, 23 三月 2020 18:20:50 +0800 Subject: [PATCH] 2020-03-23-3 --- ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/Base/DeviceCardCommon.cs | 124 ++++++++++++++++++++++++++++++++-------- 1 files changed, 98 insertions(+), 26 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/Base/DeviceCardCommon.cs b/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/Base/DeviceCardCommon.cs index ecd5188..9ecbb97 100755 --- a/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/Base/DeviceCardCommon.cs +++ b/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/Base/DeviceCardCommon.cs @@ -14,6 +14,10 @@ #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> + /// 璁惧瀵硅薄 + /// </summary> + public CommonDevice device = null; + /// <summary> /// 鍗$墖闇�瑕佽绉婚櫎鐨勪簨浠� /// </summary> public Action CardNeedRemoveEvent = null; @@ -28,7 +32,7 @@ /// <summary> /// 璁惧鐨勮儗鏅渾鍦堝浘鎺т欢 /// </summary> - private NormalViewControl btnDeviceRound = null; + private FrameLayout fraDeviceRound = null; /// <summary> /// 璁惧鍥炬爣鎺т欢 /// </summary> @@ -42,9 +46,17 @@ /// </summary> private PicViewControl btnSwitch = null; /// <summary> + /// 鏀堕泦鎺т欢 + /// </summary> + private IconViewControl btnCollect = null; + /// <summary> /// 鏄惁鑾峰彇缃戝叧鍙嶉鐨勭粨鏋� 0:娌℃湁鑾峰彇寰楀埌 1:宸茬粡鑾峰彇寰楀埌 /// </summary> private int ResponeResult = 0; + /// <summary> + /// 鍒ゆ柇鏄惁鏈夊紑鍏冲姛鑳� + /// </summary> + private bool isHadOpenSwitch = true; #endregion @@ -69,6 +81,7 @@ /// <param name="i_device">鎸囧畾璁惧</param> public virtual void InitControl(CommonDevice i_device) { + this.device = i_device; //鑳屾櫙鍥剧墖 this.btnBackGroud = new PicViewControl(this.Width, this.Height, false); btnBackGroud.UnSelectedImagePath = "Item/FunctionCardView.png"; @@ -87,7 +100,7 @@ this.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly); //鏀堕泦鎺т欢 - var btnCollect = new IconViewControl(107); + this.btnCollect = new IconViewControl(107); btnCollect.X = Application.GetMinRealAverage(350); btnCollect.Y = Application.GetMinRealAverage(12); btnCollect.UnSelectedImagePath = "Item/Collection1.png"; @@ -116,19 +129,20 @@ }; //璁惧鐨勮儗鏅渾鍦堝浘 - this.btnDeviceRound = new NormalViewControl(Application.GetMinRealAverage(124), Application.GetMinRealAverage(124), false); - btnDeviceRound.Radius = (uint)Application.GetMinRealAverage(124) / 2; - btnDeviceRound.X = Application.GetMinRealAverage(44); - btnDeviceRound.Y = Application.GetMinRealAverage(101); - btnDeviceRound.BackgroundColor = Common.ZigbeeColor.Current.GXCForFunctionUnSelectedBackgroundColor; - btnDeviceRound.SelectedBackgroundColor = Common.ZigbeeColor.Current.GXCForFunctionBackgroundColor; - this.AddChidren(btnDeviceRound, ChidrenBindMode.BindEventOnly); + this.fraDeviceRound = new FrameLayout(); + fraDeviceRound.Width = Application.GetMinRealAverage(124); + fraDeviceRound.Height = Application.GetMinRealAverage(124); + fraDeviceRound.Radius = (uint)Application.GetMinRealAverage(124) / 2; + fraDeviceRound.X = Application.GetMinRealAverage(44); + fraDeviceRound.Y = Application.GetMinRealAverage(101); + fraDeviceRound.BackgroundColor = Common.ZigbeeColor.Current.GXCForFunctionUnSelectedBackgroundColor; + this.AddChidren(fraDeviceRound, ChidrenBindMode.BindEventOnly); //璁惧鍥炬爣鎺т欢 this.btnDeviceIcon = new IconViewControl(86); - btnDeviceIcon.X = Application.GetMinRealAverage(63); - btnDeviceIcon.Y = Application.GetMinRealAverage(121); - this.AddChidren(btnDeviceIcon, ChidrenBindMode.BindEventOnly); + btnDeviceIcon.Gravity = Gravity.Center; + fraDeviceRound.AddChidren(btnDeviceIcon); + this.ChangedChidrenBindMode(fraDeviceRound, ChidrenBindMode.BindEventOnly); //鐘舵�佹枃鏈帶浠� this.btnStatu = new NormalViewControl(Application.GetMinRealAverage(280), Application.GetMinRealAverage(63), false); @@ -145,8 +159,6 @@ btnSwitch.Y = Application.GetMinRealAverage(202); btnSwitch.UnSelectedImagePath = "Item/Switch1.png"; btnSwitch.SelectedImagePath = "Item/SwitchSelected1.png"; - this.AddChidren(this.btnSwitch, ChidrenBindMode.NotBind); - btnSwitch.Visible = false; //鍒锋柊淇℃伅 this.RefreshControlInfo(i_device); @@ -162,7 +174,7 @@ /// <returns></returns> public PicViewControl AddSwitchControl() { - btnSwitch.Visible = true; + this.AddChidren(this.btnSwitch, ChidrenBindMode.NotBind); return btnSwitch; } @@ -176,21 +188,27 @@ /// <param name="i_device">璁惧瀵硅薄,涓嶆槸鎺ㄩ�佺殑閭d釜</param> public void RefreshControlInfo(CommonDevice i_device) { - //璁惧鐘舵�佸繀椤诲埛鏂� - this.btnStatu.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(i_device); + bool collect = HdlRoomLogic.Current.IsCollectInRoom(i_device); + if (btnCollect.IsSelected != collect) + { + btnCollect.IsSelected = collect; + } //璁惧鍥炬爣涔熷埛鏂� - Common.LocalDevice.Current.SetDeviceIconToControl(btnDeviceIcon, i_device); + Common.LocalDevice.Current.SetDeviceIconToControl2(btnDeviceIcon, i_device); //妫�娴嬭澶囨槸鍚︽槸鎵撳紑鐘舵�� bool isOpen = this.CheckIsOpenStatu(i_device); - this.SetCardStatu(isOpen); + this.SetCardOpenStatu(isOpen); } /// <summary> /// 璁剧疆鍗$墖鐘舵�� /// </summary> /// <param name="isOpen"></param> - public void SetCardStatu(bool isOpen) + public void SetCardOpenStatu(bool isOpen) { + //璁惧鐘舵�佸繀椤诲埛鏂� + this.btnStatu.Text = HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device); + if (this.btnBackGroud.IsSelected == isOpen) { //鐘舵�佷竴鏍�,鍒欎笉闇�瑕佸鐞� @@ -202,13 +220,37 @@ this.btnDeviceName.IsSelected = isOpen; this.btnDeviceName.IsBold = isOpen; //璁惧鐨勮儗鏅渾鍦堝浘 - this.btnDeviceRound.IsSelected = isOpen; + if (isOpen == true) + { + fraDeviceRound.BackgroundColor = Common.ZigbeeColor.Current.GXCForFunctionBackgroundColor; + } + else + { + fraDeviceRound.BackgroundColor = Common.ZigbeeColor.Current.GXCForFunctionUnSelectedBackgroundColor; + } //璁惧鍥炬爣鎺т欢 this.btnDeviceIcon.IsSelected = isOpen; //鐘舵�佹枃鏈帶浠� this.btnStatu.IsSelected = isOpen; //寮�鍏虫帶浠� - this.btnSwitch.IsSelected = isOpen; + if (btnSwitch != null) + { + this.btnSwitch.IsSelected = isOpen; + } + } + + /// <summary> + /// 璁剧疆鍗$墖鐨勫湪绾跨姸鎬� + /// </summary> + /// <param name="isOnline">鍦ㄧ嚎</param> + public void SetCardOnlineStatu(bool isOnline) + { + if (this.isHadOpenSwitch == true) + { + //濡傛灉杩欎釜璁惧鏈夊紑鍏冲姛鑳�,鍒欏湪绾跨姸鎬佷笉浼氭敼鍙樼姸鎬� + return; + } + this.SetCardOpenStatu(isOnline); } /// <summary> @@ -227,8 +269,7 @@ /// <summary> /// 鍙戦�佽幏鍙栫姸鎬佸懡浠� /// </summary> - /// <param name="i_device"></param> - public virtual void SendStatuComand(CommonDevice i_device) + public virtual void SendStatuComand() { return; } @@ -244,6 +285,8 @@ /// <returns></returns> public virtual bool CheckIsOpenStatu(CommonDevice i_device) { + //濡傛灉杩欎釜鍑芥暟琚噸鍐欑殑璇�,鍒欎唬琛ㄨ繖涓澶囨湁寮�鍏冲姛鑳� + this.isHadOpenSwitch = false; //榛樿鐢ㄥ湪绾跨姸鎬佹潵鍒ゆ柇 return i_device.IsOnline == 1; } @@ -290,9 +333,12 @@ public void StartCheckResponeResult(bool oldOpenStatu) { this.ResponeResult = 0; + //寮�鍏虫寜閽笉鑳藉啀鐐瑰嚮 + if (btnSwitch != null) { this.btnSwitch.CanClick = false; } + HdlThreadLogic.Current.RunThread(() => { - int waitime = 30 * 100; + int waitime = 30; while (waitime > 0) { System.Threading.Thread.Sleep(100); @@ -301,6 +347,7 @@ //宸茬粡鑾峰彇寰楀埌鏁版嵁 break; } + waitime--; } if (waitime <= 0) { @@ -310,9 +357,11 @@ var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.FAIL)); msgContr.Show(); //鍙樻洿鍥炲師鏉ョ殑鐘舵�� - this.SetCardStatu(oldOpenStatu); + this.SetCardOpenStatu(oldOpenStatu); }); } + //寮�鍏虫寜閽笉鑳藉啀鐐瑰嚮 + if (btnSwitch != null) { this.btnSwitch.CanClick = true; } }); } @@ -326,6 +375,29 @@ #endregion + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 妫�娴嬭兘鍚﹀彂閫佽幏鍙栫姸鎬佸懡浠� + /// </summary> + /// <returns></returns> + public bool CheckCanSendStatuComand() + { + if (this.device.HadReadDeviceStatu == false) + { + //杩樻病鏈夎鍙栬繃鏁版嵁 + return true; + } + if ((DateTime.Now - this.device.LastDateTime).TotalMinutes >= 10) + { + //10鍒嗛挓鍚庡彲浠ュ啀娆¤幏鍙� + return true; + } + return false; + } + + #endregion + #region 鈻� 鎺т欢鎽ф瘉___________________________ /// <summary> -- Gitblit v1.8.0