From f17bb6c60db1f24ce05df96aa27d4680e2df0ce6 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期三, 15 一月 2020 17:16:13 +0800 Subject: [PATCH] 请合并最新代码,(优化代码格式,完成开会后的细节测试) --- ZigbeeApp20190114/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs | 136 ++++++++++++++++++++++++++++++++------------- 1 files changed, 97 insertions(+), 39 deletions(-) diff --git a/ZigbeeApp20190114/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs b/ZigbeeApp20190114/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs index 8a7f32d..25dfdee 100644 --- a/ZigbeeApp20190114/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs +++ b/ZigbeeApp20190114/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs @@ -60,19 +60,58 @@ ZigBee.Device.ZbGateway.StatusList.Add(this); } - #region 鈼� 鍙橀噺鐢虫槑__________________________ + #region 鍙橀噺鐢虫槑 + /// <summary> + /// 褰撳墠闂ㄩ攣 + /// </summary> ZigBee.Device.DoorLock doorLock; + /// <summary> + /// 璁剧疆鏃堕棿绫诲瀷 + /// </summary> string setTimeType = ""; + /// <summary> + /// 褰撳墠闂ㄩ攣鏃堕棿 + /// </summary> DateTime CurentDoorLockTime; + /// <summary> + /// 鏄剧ず鏃ユ湡鐨勬枃鏈� + /// </summary> Button textDisplayDate; + /// <summary> + /// 鏄剧ず鏃堕棿鐨勬枃鏈� + /// </summary> Button textDisplayTime; + /// <summary> + /// 鏈湴鍙橀噺鈥滃勾鈥� + /// </summary> int curYear = 0; + /// <summary> + /// 鏈湴鍙橀噺鈥滄湀鈥� + /// </summary> int curMonth = 0; + /// <summary> + /// 鏈湴鍙橀噺鈥滄棩鈥� + /// </summary> int curDay = 0; + /// <summary> + /// 鏈湴鍙橀噺鈥滄椂鈥� + /// </summary> int curHour = 0; + /// <summary> + /// 鏈湴鍙橀噺鈥滃垎鈥� + /// </summary> int curMin = 0; + /// <summary> + /// 鏈湴鍙橀噺鈥滅鈥� + /// </summary> int curSec = 0; + /// <summary> + /// 璁剧疆鏃堕棿鐨凙ction + /// </summary> public Action timeSetAction; + /// <summary> + /// 绛夊緟鑾峰彇闂ㄩ攣鏃剁殑绛夊緟鏃堕棿 + /// </summary> DateTime waitGetDoorLockTime = DateTime.MaxValue; #endregion @@ -111,8 +150,10 @@ this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; this.MidFrameLayout(this); MidFrameLayoutContent(); - } - + } + /// <summary> + /// 涓儴甯冨眬 + /// </summary> public void MidFrameLayoutContent() { if (setTimeType == "DoorLockTime") @@ -139,8 +180,8 @@ } }) { IsBackground = true }.Start(); - } - + } + var MidTopFrameLayout = new FrameLayout() { }; @@ -149,6 +190,7 @@ var dtNow = DateTime.Now; for (int i = 0; i < 2; i++) { + #region MidTopFrameLayout UI var rowLayout = new FrameLayout() { Height = Application.GetRealHeight(127 + 23), @@ -199,8 +241,10 @@ X = Application.GetRealWidth(58), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, }; - MidTopFrameLayout.AddChidren(btnLine); + MidTopFrameLayout.AddChidren(btnLine); + #endregion + #region 鏄剧ず澶勭悊 if (i == 0) { btnDateTime.Y = textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = Application.GetRealHeight(50); @@ -277,7 +321,10 @@ btnDateTime.Text = Language.StringByID(R.MyInternationalizationString.CurrentTime); } btnLine.Visible = false; - } + } + #endregion + + #region 浜嬩欢澶勭悊 int curIndex = i; EventHandler<MouseEventArgs> hander = (sender, e) => { @@ -571,12 +618,13 @@ }; } } - }; + }; rowLayout.MouseDownEventHandler += hander; btnDateTime.MouseDownEventHandler += hander; textDisplayDateFrameLayout.MouseDownEventHandler += hander; btnNextFrameLayout.MouseDownEventHandler += hander; - btnNext.MouseDownEventHandler += hander; + btnNext.MouseDownEventHandler += hander; + if (curIndex == 0) { textDisplayDate.MouseDownEventHandler += hander; @@ -585,44 +633,54 @@ { textDisplayTime.MouseDownEventHandler += hander; } + #endregion } btnCancel.MouseUpEventHandler += (sender1, e1) => { this.shadowRadiusFrameLayout.RemoveFromParent(); }; - btnFinish.MouseUpEventHandler += async (sender1, e1) => + btnFinish.MouseUpEventHandler += (sender1, e1) => { if (setTimeType == "DoorLockTime") - { - var curDateTime = new DateTime(curYear, curMonth, curDay, curHour, curMin, curSec); - var setTimestamp = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetUnixTimeStamp(curDateTime); - try - { - CommonPage.Loading.Start(""); - var rectifyResult = await doorLock.RectifyDoorLockTimeAsync(int.Parse(setTimestamp)); - if (rectifyResult != null && rectifyResult.setWritableValueResponData != null) - { - if (rectifyResult.setWritableValueResponData.Status == 0) - { - this.shadowRadiusFrameLayout.RemoveFromParent(); - } - else - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RectifyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); - } + { + System.Threading.Tasks.Task.Run(async () => { + try + { + var curDateTime = new DateTime(curYear, curMonth, curDay, curHour, curMin, curSec); + var setTimestamp = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetUnixTimeStamp(curDateTime); + Application.RunOnMainThread(() => { + CommonPage.Loading.Start(""); + }); + var rectifyResult = await doorLock.RectifyDoorLockTimeAsync(int.Parse(setTimestamp)); + if (rectifyResult != null && rectifyResult.setWritableValueResponData != null) + { + Application.RunOnMainThread(() => { + if (rectifyResult.setWritableValueResponData.Status == 0) + { + doorLock.ReadAttri(ZigBee.Device.Cluster_ID.DoorLock, ZigBee.Device.AttriButeId.DoorLock); + System.Threading.Thread.Sleep(1000); + this.shadowRadiusFrameLayout.RemoveFromParent(); + } + else + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RectifyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); + } + }); + } + else + { + Application.RunOnMainThread(() => { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); + }); + } + } + catch { } + finally + { + Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); }); } - else - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); - } - } - catch { } - finally - { - System.Threading.Thread.Sleep(3000); - CommonPage.Loading.Hide(); - } + }); } }; this.shadowRadiusFrameLayout.MouseUpEventHandler += (sender1, e1) => @@ -640,7 +698,7 @@ } } - #region 鈼� 鎺ュ彛瀹炵幇__________________________ + #region 鎺ュ彛瀹炵幇 /// <summary> /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange() /// </summary> -- Gitblit v1.8.0