From bd46c57c77c276014db3192a4e2cc96e23c93202 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 21 二月 2020 13:08:47 +0800 Subject: [PATCH] 先上传个版本吧 --- ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs | 259 +++++++++++++++++++++------------------------------ 1 files changed, 109 insertions(+), 150 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs index 38ceff3..424eb2f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs +++ b/ZigbeeApp/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 @@ -112,7 +151,9 @@ this.MidFrameLayout(this); MidFrameLayoutContent(); } - + /// <summary> + /// 涓儴甯冨眬 + /// </summary> public void MidFrameLayoutContent() { if (setTimeType == "DoorLockTime") @@ -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), @@ -163,7 +205,7 @@ X = Application.GetRealWidth(58), TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, TextAlignment = TextAlignment.CenterLeft, - TextSize = 14, + TextSize = 12, }; rowLayout.AddChidren(btnDateTime); @@ -200,7 +242,9 @@ BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, }; MidTopFrameLayout.AddChidren(btnLine); + #endregion + #region 鏄剧ず澶勭悊 if (i == 0) { btnDateTime.Y = textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = Application.GetRealHeight(50); @@ -210,7 +254,7 @@ { TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, TextAlignment = TextAlignment.CenterRight, - TextSize = 14, + TextSize = 12, Text = "_" + Language.StringByID(R.MyInternationalizationString.Year) + "_" + Language.StringByID(R.MyInternationalizationString.Month) + "_" + Language.StringByID(R.MyInternationalizationString.Day), }; textDisplayDateFrameLayout.AddChidren(textDisplayDate); @@ -241,7 +285,7 @@ { TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, TextAlignment = TextAlignment.CenterRight, - TextSize = 14, + TextSize = 12, Text = "00:00", }; textDisplayDateFrameLayout.AddChidren(textDisplayTime); @@ -278,6 +322,9 @@ } btnLine.Visible = false; } + #endregion + + #region 浜嬩欢澶勭悊 int curIndex = i; EventHandler<MouseEventArgs> hander = (sender, e) => { @@ -287,67 +334,9 @@ var mUIPickerView = new UIPickerView() { X = Application.GetRealWidth(0), + Height = Application.GetRealHeight(440), }; this.bottomRadiusFrameLayout.AddChidren(mUIPickerView); - - var btnTextM = new Button() - { - Width = Application.GetRealWidth(0), - Height = Application.GetRealHeight(58), - Y = Application.GetRealHeight(372), - Text= "鏈�", - TextSize=14, - TextColor=ZigbeeColor.Current.XMBlack, - }; - this.bottomRadiusFrameLayout.AddChidren(btnTextM); - var btnTextD = new Button() - { - Width = Application.GetRealWidth(0), - Height = Application.GetRealHeight(58), - Y = Application.GetRealHeight(372), - Text = "鏃�", - TextColor = ZigbeeColor.Current.XMBlack, - TextSize = 14, - }; - this.bottomRadiusFrameLayout.AddChidren(btnTextD); - - var btnLine1 = new FrameLayout() - { - Width = Application.GetRealWidth(0), - Height = 2, - Y = Application.GetRealHeight(161 + 177), - BackgroundColor =Shared.Common.ZigbeeColor.Current.XMRowLine, - }; - this.bottomRadiusFrameLayout.AddChidren(btnLine1); - - var btnLine2 = new FrameLayout() - { - Width = Application.GetRealWidth(0), - Height = btnLine1.Height, - X = Application.GetRealWidth(246+588), - Y = btnLine1.Y, - BackgroundColor =Shared.Common.ZigbeeColor.Current.XMRowLine, - }; - this.bottomRadiusFrameLayout.AddChidren(btnLine2); - - var btnLine3 = new FrameLayout() - { - Width = Application.GetRealWidth(0), - Height = 2, - Y = Application.GetRealHeight(161 + 269), - BackgroundColor =Shared.Common.ZigbeeColor.Current.XMRowLine, - }; - this.bottomRadiusFrameLayout.AddChidren(btnLine3); - - var btnLine4 = new FrameLayout() - { - Width = Application.GetRealWidth(0), - Height = btnLine3.Height, - X = btnLine2.X, - Y = btnLine3.Y, - BackgroundColor =Shared.Common.ZigbeeColor.Current.XMRowLine, - }; - this.bottomRadiusFrameLayout.AddChidren(btnLine4); if (curIndex == 0) { @@ -361,7 +350,7 @@ this.btnBottomTitle.TextID = R.MyInternationalizationString.CurrentDate; } - mUIPickerView.Y = Application.GetRealWidth(110); + mUIPickerView.Y = Application.GetRealWidth(245); var mList1 = new List<string>(); var mList2 = new List<string>(); var mList3 = new List<string>(); @@ -370,63 +359,36 @@ int year = dtNow.Year + 1; int days = DateTime.DaysInMonth(dtNow.Year, dtNow.Month); - for (int y = dtNow.Year - 10; y < dtNow.Year + 1; y++) + for (int y = dtNow.Year - 9; y < dtNow.Year + 1; y++) { mList1.Add(y.ToString()); } for (int m = 1; m < 13; m++) { - mList2.Add(m.ToString()); if (Language.CurrentLanguage == "Chinese") { - btnTextM.Width = Application.GetRealWidth(100); - if (setTimeType != "DoorLockTime") - { - btnTextM.X = Application.GetRealWidth(418); - } - else - { - btnTextM.X = Application.GetRealWidth(566); - } - + mList2.Add(m.ToString() + "鏈�"); } else { - btnTextM.Width = Application.GetRealWidth(0); + mList2.Add(m.ToString()); } - } for (int d = 1; d < days + 1; d++) { - mList3.Add(d.ToString()); if (Language.CurrentLanguage == "Chinese") - { - btnTextD.Width = Application.GetRealWidth(100); - if (setTimeType != "DoorLockTime") - { - btnTextD.X = Application.GetRealWidth(710); - } - else - { - btnTextD.X = Application.GetRealWidth(922); - } + { + mList3.Add(d.ToString() + "鏃�"); } else { - btnTextD.Width = Application.GetRealWidth(0); + mList3.Add(d.ToString()); } } if (setTimeType != "DoorLockTime") { mUIPickerView.setNPicker(mList2, mList3, null); - mUIPickerView.Width = Application.GetRealWidth(588); - mUIPickerView.X = Application.GetRealWidth(246); - btnLine1.Width=btnLine2.Width= btnLine3.Width = btnLine4.Width = Application.GetRealWidth(250); - btnLine1.Y = Application.GetRealHeight(161 + 177+15); - btnLine2.Y = Application.GetRealHeight(161 + 177 + 15); - btnLine3.Y = Application.GetRealHeight(161 + 269+15); - btnLine4.Y = Application.GetRealHeight(161 + 269 + 15); mUIPickerView.setCurrentItems(dtNow.Month - 1, dtNow.Day - 1, 0); curMonth = dtNow.Month; curDay = dtNow.Day; @@ -473,17 +435,13 @@ timeSetAction(); } this.shadowRadiusFrameLayout.RemoveFromParent(); - this.bottomRadiusFrameLayout.RemoveFromParent(); MidFrameLayoutContent(); }; } else { mUIPickerView.setNPicker(mList1, mList2, mList3); - mUIPickerView.Width = Application.GetRealWidth(1080); - mUIPickerView.X = Application.GetRealWidth(0); - btnLine1.Width = btnLine2.Width = btnLine3.Width = btnLine4.Width = Application.GetRealWidth(0); - mUIPickerView.setCurrentItems(dtNow.Year, dtNow.Month - 1, dtNow.Day - 1); + mUIPickerView.setCurrentItems(9, dtNow.Month - 1, dtNow.Day - 1); curYear = dtNow.Year; curMonth = dtNow.Month; curDay = dtNow.Day; @@ -498,7 +456,7 @@ curHour = dtNow.Hour; curMin = dtNow.Minute; curSec = dtNow.Second; - } + } } Action dAction = () => @@ -511,39 +469,25 @@ for (int d = 1; d < days + 1; d++) { - mList3.Add(d.ToString()); if (Language.CurrentLanguage == "Chinese") { - btnTextD.Width = Application.GetRealWidth(100); - if (setTimeType != "DoorLockTime") - { - btnTextD.X = Application.GetRealWidth(710); - } - else - { - btnTextD.X = Application.GetRealWidth(922); - } + mList3.Add(d.ToString() + "鏃�"); } else { - btnTextD.Width = Application.GetRealWidth(0); + mList3.Add(d.ToString()); } } + if (setTimeType != "DoorLockTime") { mUIPickerView.setNPicker(mList2, mList3, null); - mUIPickerView.Width = Application.GetRealWidth(588); - mUIPickerView.X = Application.GetRealWidth(246); - btnLine1.Width = btnLine2.Width = btnLine3.Width = btnLine4.Width = Application.GetRealWidth(250); mUIPickerView.setCurrentItems(curMonth - 1, curDay - 1, 0); } else { mUIPickerView.setNPicker(mList1, mList2, mList3); - mUIPickerView.Width = Application.GetRealWidth(1080); - mUIPickerView.X = Application.GetRealWidth(0); - btnLine1.Width = btnLine2.Width = btnLine3.Width = btnLine4.Width = Application.GetRealWidth(0); - mUIPickerView.setCurrentItems(curYear, curMonth - 1, curDay - 1); + mUIPickerView.setCurrentItems(9, curMonth - 1, curDay - 1); } } }; @@ -576,7 +520,7 @@ this.btnBottomTitle.TextID = R.MyInternationalizationString.CurrentTime; } - mUIPickerView.Y = Application.GetRealWidth(95); + mUIPickerView.Y = Application.GetRealWidth(245); var mList1 = new List<string>(); var mList2 = new List<string>(); for (int h = 0; h < 24; h++) @@ -602,9 +546,6 @@ } } mUIPickerView.setNPicker(mList1, mList2, null); - mUIPickerView.Width = Application.GetRealWidth(588); - mUIPickerView.X = Application.GetRealWidth(246); - btnLine1.Width = btnLine2.Width = btnLine3.Width = btnLine4.Width = Application.GetRealWidth(250); mUIPickerView.setCurrentItems(dtNow.Hour, dtNow.Minute, 0); if (CurentDoorLockTime != null) { @@ -673,7 +614,6 @@ timeSetAction(); } this.shadowRadiusFrameLayout.RemoveFromParent(); - this.bottomRadiusFrameLayout.RemoveFromParent(); MidFrameLayoutContent(); }; } @@ -684,44 +624,63 @@ textDisplayDateFrameLayout.MouseDownEventHandler += hander; btnNextFrameLayout.MouseDownEventHandler += hander; btnNext.MouseDownEventHandler += hander; + + if (curIndex == 0) + { + textDisplayDate.MouseDownEventHandler += hander; + } + else + { + 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) + { + System.Threading.Tasks.Task.Run(async () => { + try { - if (rectifyResult.setWritableValueResponData.Status == 0) + 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) { - this.shadowRadiusFrameLayout.RemoveFromParent(); + 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 { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RectifyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); + Application.RunOnMainThread(() => { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); + }); } } - else - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish); + catch { } + finally + { + Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); }); } - } - catch { } - finally - { - System.Threading.Thread.Sleep(3000); - CommonPage.Loading.Hide(); - } + }); } }; this.shadowRadiusFrameLayout.MouseUpEventHandler += (sender1, e1) => @@ -739,7 +698,7 @@ } } - #region 鈼� 鎺ュ彛瀹炵幇__________________________ + #region 鎺ュ彛瀹炵幇 /// <summary> /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange() /// </summary> -- Gitblit v1.8.0