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/UserCenter/DoorLock/TimeSettignPage.cs | 943 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 564 insertions(+), 379 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs index 424eb2f..3ba7016 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs @@ -7,6 +7,7 @@ { public class TimeSettignPage : DoorLockCommonLayout, ZigBee.Common.IStatus { + #region 涓婃姤鏁版嵁澶勭悊 /// <summary> /// 澶勭悊鍙樺寲浜嬩欢 /// </summary> @@ -47,7 +48,9 @@ } } } + #endregion + #region 鏋勯�犲嚱鏁� /// <summary> /// 鏋勯�犲嚱鏁� /// </summary> @@ -59,7 +62,9 @@ BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor; ZigBee.Device.ZbGateway.StatusList.Add(this); } + #endregion + #region UI鍐呭 #region 鍙橀噺鐢虫槑 /// <summary> /// 褰撳墠闂ㄩ攣 @@ -116,16 +121,7 @@ #endregion /// <summary> - /// 閲嶅啓绉婚櫎鏂规硶 - /// </summary> - public override void RemoveFromParent() - { - ZbGateway.StatusList.Remove(this); - base.RemoveFromParent(); - } - - /// <summary> - /// UI鏄剧ず + /// UI鏄剧ず /// </summary> public void Show() { @@ -151,6 +147,7 @@ this.MidFrameLayout(this); MidFrameLayoutContent(); } + /// <summary> /// 涓儴甯冨眬 /// </summary> @@ -158,34 +155,30 @@ { if (setTimeType == "DoorLockTime") { - CommonPage.Loading.Start(""); - // 鍙湁閲嶆柊鍚姩鏃朵細鎱紝鐒跺悗鍏朵粬鏃跺埢閮芥槸鏈夊�肩殑 - new System.Threading.Thread(() => - { - while (this.Parent != null) - { - if (DateTime.Now > waitGetDoorLockTime) - { - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 2 }.Show(CommonPage.Instance); - CommonPage.Loading.Hide(); - }); - } - //璇婚棬閿佹椂闂� - //绛夊緟10绉掞紝娌℃湁鏀跺埌鎻愮ず瓒呮椂閫�鍑� - waitGetDoorLockTime = DateTime.Now.AddSeconds(+5); - doorLock.ReadAttri(ZigBee.Device.Cluster_ID.DoorLock, ZigBee.Device.AttriButeId.DoorLock); - System.Threading.Thread.Sleep(5 * 1000); - } - }) - { IsBackground = true }.Start(); + ReadDoorlockTime(); } - var MidTopFrameLayout = new FrameLayout() + var zoneFrameLayout = new FrameLayout() { + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, }; - this.midFrameLayout.AddChidren(MidTopFrameLayout); + this.midFrameLayout.AddChidren(zoneFrameLayout); + + if (setTimeType == "DoorLockTime") + { + zoneFrameLayout.Height = Application.GetRealHeight(150) + 1; + AddDoorLocksTimeRow(zoneFrameLayout); + } + else + { + zoneFrameLayout.Height = Application.GetRealHeight(0); + } + + var midTopFrameLayout = new FrameLayout() + { + Y = zoneFrameLayout.Bottom, + }; + this.midFrameLayout.AddChidren(midTopFrameLayout); var dtNow = DateTime.Now; for (int i = 0; i < 2; i++) @@ -196,7 +189,7 @@ Height = Application.GetRealHeight(127 + 23), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, }; - MidTopFrameLayout.AddChidren(rowLayout); + midTopFrameLayout.AddChidren(rowLayout); var btnDateTime = new Button() { @@ -241,7 +234,7 @@ X = Application.GetRealWidth(58), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, }; - MidTopFrameLayout.AddChidren(btnLine); + midTopFrameLayout.AddChidren(btnLine); #endregion #region 鏄剧ず澶勭悊 @@ -322,302 +315,13 @@ } btnLine.Visible = false; } - #endregion + #endregion #region 浜嬩欢澶勭悊 int curIndex = i; EventHandler<MouseEventArgs> hander = (sender, e) => { - this.midFrameLayout.AddChidren(this.shadowRadiusFrameLayout); - this.bottomRadiusFrameLayout.RemoveAll(); - this.BottomRadiusFrameLayout(this); - var mUIPickerView = new UIPickerView() - { - X = Application.GetRealWidth(0), - Height = Application.GetRealHeight(440), - }; - this.bottomRadiusFrameLayout.AddChidren(mUIPickerView); - - if (curIndex == 0) - { - //鏃ユ湡 - if (setTimeType != "DoorLockTime") - { - this.btnBottomTitle.TextID = R.MyInternationalizationString.Date; - } - else - { - this.btnBottomTitle.TextID = R.MyInternationalizationString.CurrentDate; - } - - mUIPickerView.Y = Application.GetRealWidth(245); - var mList1 = new List<string>(); - var mList2 = new List<string>(); - var mList3 = new List<string>(); - var oldMonth = dtNow.Month; - - int year = dtNow.Year + 1; - int days = DateTime.DaysInMonth(dtNow.Year, dtNow.Month); - - for (int y = dtNow.Year - 9; y < dtNow.Year + 1; y++) - { - mList1.Add(y.ToString()); - } - for (int m = 1; m < 13; m++) - { - if (Language.CurrentLanguage == "Chinese") - { - mList2.Add(m.ToString() + "鏈�"); - } - else - { - mList2.Add(m.ToString()); - } - } - for (int d = 1; d < days + 1; d++) - { - if (Language.CurrentLanguage == "Chinese") - { - mList3.Add(d.ToString() + "鏃�"); - } - else - { - mList3.Add(d.ToString()); - } - } - - if (setTimeType != "DoorLockTime") - { - mUIPickerView.setNPicker(mList2, mList3, null); - mUIPickerView.setCurrentItems(dtNow.Month - 1, dtNow.Day - 1, 0); - curMonth = dtNow.Month; - curDay = dtNow.Day; - - if (setTimeType == "ValidTime") - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateYear = dtNow.Year; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMonth = curMonth; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateDay = curDay; - } - else - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateYear = dtNow.Year; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth = curMonth; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateDay = curDay; - } - var btnOk = new Button - { - X = Application.GetRealWidth(919), - Y = Application.GetRealHeight(40), - Height = Application.GetRealHeight(58), - Width = Application.GetRealWidth(101), - Text = Language.StringByID(R.MyInternationalizationString.Complete), - TextColor = Shared.Common.ZigbeeColor.Current.XMOrange, - TextSize = 14, - }; - this.bottomRadiusFrameLayout.AddChidren(btnOk); - btnOk.MouseUpEventHandler += (sender1, e1) => - { - if (setTimeType == "ValidTime") - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateYear = dtNow.Year; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMonth = curMonth; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateDay = curDay; - } - else - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateYear = dtNow.Year; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth = curMonth; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateDay = curDay; - } - if (timeSetAction != null) - { - timeSetAction(); - } - this.shadowRadiusFrameLayout.RemoveFromParent(); - MidFrameLayoutContent(); - }; - } - else - { - mUIPickerView.setNPicker(mList1, mList2, mList3); - mUIPickerView.setCurrentItems(9, dtNow.Month - 1, dtNow.Day - 1); - curYear = dtNow.Year; - curMonth = dtNow.Month; - curDay = dtNow.Day; - if (CurentDoorLockTime != null) - { - curHour = CurentDoorLockTime.Hour; - curMin = CurentDoorLockTime.Minute; - curSec = CurentDoorLockTime.Second; - } - else - { - curHour = dtNow.Hour; - curMin = dtNow.Minute; - curSec = dtNow.Second; - } - } - - Action dAction = () => - { - if (curMonth != oldMonth) - { - oldMonth = curMonth; - days = DateTime.DaysInMonth(curYear, curMonth); - mList3.Clear(); - - for (int d = 1; d < days + 1; d++) - { - if (Language.CurrentLanguage == "Chinese") - { - mList3.Add(d.ToString() + "鏃�"); - } - else - { - mList3.Add(d.ToString()); - } - } - - if (setTimeType != "DoorLockTime") - { - mUIPickerView.setNPicker(mList2, mList3, null); - mUIPickerView.setCurrentItems(curMonth - 1, curDay - 1, 0); - } - else - { - mUIPickerView.setNPicker(mList1, mList2, mList3); - mUIPickerView.setCurrentItems(9, curMonth - 1, curDay - 1); - } - } - }; - mUIPickerView.OnSelectChangeEvent += (y, m, d) => - { - if (setTimeType != "DoorLockTime") - { - curYear = dtNow.Year; - curMonth = y + 1; - curDay = m + 1; - } - else - { - curYear = y + 2009; - curMonth = m + 1; - curDay = d + 1; - } - dAction(); - }; - } - if (curIndex == 1) - { - //鏃堕棿 - if (setTimeType != "DoorLockTime") - { - this.btnBottomTitle.TextID = R.MyInternationalizationString.Time; - } - else - { - this.btnBottomTitle.TextID = R.MyInternationalizationString.CurrentTime; - } - - mUIPickerView.Y = Application.GetRealWidth(245); - var mList1 = new List<string>(); - var mList2 = new List<string>(); - for (int h = 0; h < 24; h++) - { - if (h < 10) - { - mList1.Add("0" + h.ToString()); - } - else - { - mList1.Add(h.ToString()); - } - } - for (int m = 0; m < 60; m++) - { - if (m < 10) - { - mList2.Add("0" + m.ToString()); - } - else - { - mList2.Add(m.ToString()); - } - } - mUIPickerView.setNPicker(mList1, mList2, null); - mUIPickerView.setCurrentItems(dtNow.Hour, dtNow.Minute, 0); - if (CurentDoorLockTime != null) - { - curYear = CurentDoorLockTime.Year; - curMonth = CurentDoorLockTime.Month; - curDay = CurentDoorLockTime.Day; - } - else - { - curYear = dtNow.Year; - curMonth = dtNow.Month; - curDay = dtNow.Day; - } - curHour = dtNow.Hour; - curMin = dtNow.Minute; - curSec = dtNow.Second; - mUIPickerView.OnSelectChangeEvent += (h, m, s) => - { - curHour = h; - curMin = m; - curSec = dtNow.Second; - }; - - if (setTimeType == "ValidTime") - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour = curHour; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute = curMin; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateSecond = curSec; - } - else - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour = curHour; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute = curMin; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateSecond = curSec; - } - - if (setTimeType != "DoorLockTime") - { - var btnOk = new Button - { - X = Application.GetRealWidth(919), - Y = Application.GetRealHeight(40), - Height = Application.GetRealHeight(58), - Width = Application.GetRealWidth(101), - Text = Language.StringByID(R.MyInternationalizationString.Complete), - TextColor = Shared.Common.ZigbeeColor.Current.XMOrange, - TextSize = 14, - }; - this.bottomRadiusFrameLayout.AddChidren(btnOk); - btnOk.MouseUpEventHandler += (sender1, e1) => - { - if (setTimeType == "ValidTime") - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour = curHour; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute = curMin; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateSecond = curSec; - } - else - { - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour = curHour; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute = curMin; - Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateSecond = curSec; - } - if (timeSetAction != null) - { - timeSetAction(); - } - this.shadowRadiusFrameLayout.RemoveFromParent(); - MidFrameLayoutContent(); - }; - } - } + ClickHandle(curIndex, dtNow); }; rowLayout.MouseDownEventHandler += hander; btnDateTime.MouseDownEventHandler += hander; @@ -633,61 +337,24 @@ { textDisplayTime.MouseDownEventHandler += hander; } - #endregion + #endregion } btnCancel.MouseUpEventHandler += (sender1, e1) => { this.shadowRadiusFrameLayout.RemoveFromParent(); }; - btnFinish.MouseUpEventHandler += (sender1, e1) => + btnFinish.MouseUpEventHandler += (sender1, e1) => { if (setTimeType == "DoorLockTime") - { - 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(); }); - } - }); + { + DoorLockTimeFinishHandle(); } }; this.shadowRadiusFrameLayout.MouseUpEventHandler += (sender1, e1) => { this.shadowRadiusFrameLayout.RemoveFromParent(); }; - if (setTimeType == "DoorLockTime") { if (CurentDoorLockTime != null && CurentDoorLockTime.Year != 1) @@ -697,30 +364,548 @@ } } } + #endregion - #region 鎺ュ彛瀹炵幇 + #region 鏃跺尯 /// <summary> - /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange() + /// 娣诲姞銆愰棬閿佹椂闂淬�戣锛堥棬閿佷笓鐢級 /// </summary> - /// <returns>The changed.</returns> - /// <param name="common">Common.</param> - public void Changed(CommonDevice common) + private void AddDoorLocksTimeRow(FrameLayout zoneFrameLayout) { + //闂ㄩ攣鏃堕棿 + var rowLayout = new FrameLayout() + { + Height = Application.GetRealHeight(150), + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, + }; + zoneFrameLayout.AddChidren(rowLayout); + + //褰撳墠鏃跺尯 + var btnCurZone = new Button() + { + Width = Application.GetRealWidth(560), + Height = Application.GetRealHeight(58), + X = Application.GetRealWidth(58), + TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, + TextAlignment = TextAlignment.CenterLeft, + TextSize = 12, + Y = Application.GetRealHeight(46), + Text = Language.StringByID(R.MyInternationalizationString.CurZone), + }; + rowLayout.AddChidren(btnCurZone); + + //鍝釜鏃跺尯 + var textZone = new Button() + { + Width = Application.GetRealWidth(333), + Height = Application.GetRealHeight(58), + X = Application.GetRealWidth(689), + Y = Application.GetRealHeight(46), + TextAlignment = TextAlignment.CenterRight, + TextColor = Shared.Common.ZigbeeColor.Current.XMGray4, + TextSize = 14, + }; + rowLayout.AddChidren(textZone); + textZone.Text = zoneData(); + textZone.MouseDownEventHandler += (sender, e) => + { + GetSpecificZoneNowDate(); + }; + + var btnLine = new FrameLayout() + { + Width = Application.GetRealWidth(965), + Height = 1, + X = Application.GetRealWidth(58), + Y = Application.GetRealHeight(150), + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, + }; + zoneFrameLayout.AddChidren(btnLine); + } + + /// <summary> + /// 鏃跺尯鏁版嵁 + /// </summary> + /// <returns></returns> + private string zoneData() + { + string zoneText = ""; + var gwZone = caculateTimeZone(Common.Config.Instance.Home.Longitude); + if (gwZone.Contains('+')) + { + zoneText = Language.StringByID(R.MyInternationalizationString.East); + } + else + { + zoneText = Language.StringByID(R.MyInternationalizationString.West); + } + var num = ToNum(int.Parse(gwZone)); + return zoneText += num + Language.StringByID(R.MyInternationalizationString.CurZoneText); + } + + /// <summary> + /// 鑾峰彇鏃跺尯 + /// <para>currentLon:"+"涓轰笢鍖猴紝鈥�-鈥濅负瑗垮尯</para> + /// </summary> + public static String caculateTimeZone(double currentLon) + { + int timeZone; + int shangValue = (int)(currentLon / 15); + double yushuValue = Math.Abs(currentLon % 15); + if (yushuValue <= 7.5) + { + timeZone = shangValue; + } + else + { + timeZone = shangValue + (currentLon > 0 ? 1 : -1); + } + return timeZone >= 0 ? "+" + Math.Abs(timeZone) : "-" + Math.Abs(timeZone); + } + + /// <summary> + /// 杞崲鏁板瓧 + /// </summary> + private string ToNum(int x) + { + var numString = new string[] { "闆�", "涓�", "浜�", "涓�", "鍥�", "浜�", "鍏�", "涓�", "鍏�", "涔�", "鍗�", "鍗佷竴", "鍗佷簩" }; + var strChnNamesList = new List<string>(numString); + return strChnNamesList[x]; + } + + //濡備綍鏄剧ず鏃跺尯鎵�鍦ㄧ殑鏃堕棿 + public DateTime GetSpecificZoneNowDate(string zoneName = "") + { + DateTime curZoneDateTime; + + //聽鍒椾妇鎵�鏈夋敮鎸佺殑鏃跺尯鍒楄〃 + System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo> lst = TimeZoneInfo.GetSystemTimeZones(); + foreach (TimeZoneInfo tzi in lst) + { + var aa = tzi; + var aa1 = tzi.Id; + } + GetSpecificZoneNowDate1(); + zoneName = "Central聽America聽Standard聽Time";//缇庡浗 + //灏嗘湰鍦版椂闂磋浆鎹负缇庡浗鏍囧噯涓儴鏃堕棿 + DateTime dt = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now, TimeZoneInfo.Local); + curZoneDateTime = TimeZoneInfo.ConvertTimeFromUtc(dt, TimeZoneInfo.FindSystemTimeZoneById(zoneName)); + + zoneName = "China Standard Time";//涓浗 + //棣栧厛灏嗘湇鍔″櫒鐨勬椂闂磋浆鍖栦负utc鏃堕棿锛� + var utcdate = DateTime.Now.ToUniversalTime(); + //鐒跺悗杞崲鎴愭寚瀹氭椂鍖虹殑鏃ユ湡 + TimeZoneInfo beiJingZone = TimeZoneInfo.FindSystemTimeZoneById(zoneName); + curZoneDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcdate, beiJingZone); + + return curZoneDateTime; + } + + public void GetSpecificZoneNowDate1() + { + // Get time in local time zone + DateTime thisTime = DateTime.Now; + Console.WriteLine("Time in {0} zone: {1}", TimeZoneInfo.Local.IsDaylightSavingTime(thisTime) ? + TimeZoneInfo.Local.DaylightName : TimeZoneInfo.Local.StandardName, thisTime); + Console.WriteLine(" UTC Time: {0}", TimeZoneInfo.ConvertTimeToUtc(thisTime, TimeZoneInfo.Local)); + // Get Tokyo Standard Time zone + TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time"); + DateTime tstTime = TimeZoneInfo.ConvertTime(thisTime, TimeZoneInfo.Local, tst); + Console.WriteLine("Time in {0} zone: {1}", TimeZoneInfo.Local.IsDaylightSavingTime(tstTime) ? + tst.DaylightName : tst.StandardName, tstTime); + Console.WriteLine(" UTC Time: {0}", TimeZoneInfo.ConvertTimeToUtc(tstTime, tst)); + } + + + #endregion + + #region 闂ㄩ攣鏃堕棿 + /// <summary> + /// 璇诲彇闂ㄩ攣鏃堕棿 + /// </summary> + private void ReadDoorlockTime() + { + CommonPage.Loading.Start(""); + // 鍙湁閲嶆柊鍚姩鏃朵細鎱紝鐒跺悗鍏朵粬鏃跺埢閮芥槸鏈夊�肩殑 + new System.Threading.Thread(() => + { + while (this.Parent != null) + { + if (DateTime.Now > waitGetDoorLockTime) + { + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 2 }.Show(CommonPage.Instance); + CommonPage.Loading.Hide(); + }); + } + //璇婚棬閿佹椂闂� + //绛夊緟10绉掞紝娌℃湁鏀跺埌鎻愮ず瓒呮椂閫�鍑� + waitGetDoorLockTime = DateTime.Now.AddSeconds(+5); + doorLock.ReadAttri(ZigBee.Device.Cluster_ID.DoorLock, ZigBee.Device.AttriButeId.DoorLock); + System.Threading.Thread.Sleep(5 * 1000); + } + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// 闂ㄩ攣鏃堕棿纭鎸夐挳澶勭悊 + /// </summary> + private void DoorLockTimeFinishHandle() + { + 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(); }); + } + }); } + #endregion + + #region 鍏叡浜嬩欢澶勭悊 /// <summary> - /// Changeds the IL ogic status. + /// 浜嬩欢澶勭悊 /// </summary> - /// <param name="logic">Logic.</param> - public void ChangedILogicStatus(ZigBee.Device.Logic logic) + private void ClickHandle(int curIndex, DateTime dtNow) { + this.midFrameLayout.AddChidren(this.shadowRadiusFrameLayout); + this.bottomRadiusFrameLayout.RemoveAll(); + this.BottomRadiusFrameLayout(this); + var mUIPickerView = new UIPickerView() + { + X = Application.GetRealWidth(0), + Height = Application.GetRealHeight(440), + }; + this.bottomRadiusFrameLayout.AddChidren(mUIPickerView); + + if (curIndex == 0) + { + //鏃ユ湡 + if (setTimeType != "DoorLockTime") + { + this.btnBottomTitle.TextID = R.MyInternationalizationString.Date; + } + else + { + this.btnBottomTitle.TextID = R.MyInternationalizationString.CurrentDate; + } + + mUIPickerView.Y = Application.GetRealWidth(245); + var mList1 = new List<string>(); + var mList2 = new List<string>(); + var mList3 = new List<string>(); + var oldMonth = dtNow.Month; + + int year = dtNow.Year + 1; + int days = DateTime.DaysInMonth(dtNow.Year, dtNow.Month); + + for (int y = dtNow.Year - 9; y < dtNow.Year + 1; y++) + { + mList1.Add(y.ToString()); + } + for (int m = 1; m < 13; m++) + { + if (Language.CurrentLanguage == "Chinese") + { + mList2.Add(m.ToString() + "鏈�"); + } + else + { + mList2.Add(m.ToString()); + } + } + for (int d = 1; d < days + 1; d++) + { + if (Language.CurrentLanguage == "Chinese") + { + mList3.Add(d.ToString() + "鏃�"); + } + else + { + mList3.Add(d.ToString()); + } + } + + if (setTimeType != "DoorLockTime") + { + mUIPickerView.setNPicker(mList2, mList3, null); + mUIPickerView.setCurrentItems(dtNow.Month - 1, dtNow.Day - 1, 0); + curMonth = dtNow.Month; + curDay = dtNow.Day; + + if (setTimeType == "ValidTime") + { + DoorLockCommonInfo.ValidDateYear = dtNow.Year; + DoorLockCommonInfo.ValidDateMonth = curMonth; + DoorLockCommonInfo.ValidDateDay = curDay; + } + else + { + DoorLockCommonInfo.InValidDateYear = dtNow.Year; + DoorLockCommonInfo.InValidDateMonth = curMonth; + DoorLockCommonInfo.InValidDateDay = curDay; + } + var btnOk = new Button + { + X = Application.GetRealWidth(919), + Y = Application.GetRealHeight(40), + Height = Application.GetRealHeight(58), + Width = Application.GetRealWidth(101), + Text = Language.StringByID(R.MyInternationalizationString.Complete), + TextColor = Shared.Common.ZigbeeColor.Current.XMOrange, + TextSize = 14, + }; + this.bottomRadiusFrameLayout.AddChidren(btnOk); + btnOk.MouseUpEventHandler += (sender1, e1) => + { + if (setTimeType == "ValidTime") + { + DoorLockCommonInfo.ValidDateYear = dtNow.Year; + DoorLockCommonInfo.ValidDateMonth = curMonth; + DoorLockCommonInfo.ValidDateDay = curDay; + } + else + { + DoorLockCommonInfo.InValidDateYear = dtNow.Year; + DoorLockCommonInfo.InValidDateMonth = curMonth; + DoorLockCommonInfo.InValidDateDay = curDay; + } + if (timeSetAction != null) + { + timeSetAction(); + } + this.shadowRadiusFrameLayout.RemoveFromParent(); + MidFrameLayoutContent(); + }; + } + else + { + mUIPickerView.setNPicker(mList1, mList2, mList3); + mUIPickerView.setCurrentItems(9, dtNow.Month - 1, dtNow.Day - 1); + curYear = dtNow.Year; + curMonth = dtNow.Month; + curDay = dtNow.Day; + if (CurentDoorLockTime != null) + { + curHour = CurentDoorLockTime.Hour; + curMin = CurentDoorLockTime.Minute; + curSec = CurentDoorLockTime.Second; + } + else + { + curHour = dtNow.Hour; + curMin = dtNow.Minute; + curSec = dtNow.Second; + } + } + + Action dAction = () => + { + if (curMonth != oldMonth) + { + oldMonth = curMonth; + days = DateTime.DaysInMonth(curYear, curMonth); + mList3.Clear(); + + for (int d = 1; d < days + 1; d++) + { + if (Language.CurrentLanguage == "Chinese") + { + mList3.Add(d.ToString() + "鏃�"); + } + else + { + mList3.Add(d.ToString()); + } + } + + if (setTimeType != "DoorLockTime") + { + mUIPickerView.setNPicker(mList2, mList3, null); + mUIPickerView.setCurrentItems(curMonth - 1, curDay - 1, 0); + } + else + { + mUIPickerView.setNPicker(mList1, mList2, mList3); + mUIPickerView.setCurrentItems(9, curMonth - 1, curDay - 1); + } + } + }; + mUIPickerView.OnSelectChangeEvent += (y, m, d) => + { + if (setTimeType != "DoorLockTime") + { + curYear = dtNow.Year; + curMonth = y + 1; + curDay = m + 1; + } + else + { + curYear = y + 2009; + curMonth = m + 1; + curDay = d + 1; + } + dAction(); + }; + } + if (curIndex == 1) + { + //鏃堕棿 + if (setTimeType != "DoorLockTime") + { + this.btnBottomTitle.TextID = R.MyInternationalizationString.Time; + } + else + { + this.btnBottomTitle.TextID = R.MyInternationalizationString.CurrentTime; + } + + mUIPickerView.Y = Application.GetRealWidth(245); + var mList1 = new List<string>(); + var mList2 = new List<string>(); + for (int h = 0; h < 24; h++) + { + if (h < 10) + { + mList1.Add("0" + h.ToString()); + } + else + { + mList1.Add(h.ToString()); + } + } + for (int m = 0; m < 60; m++) + { + if (m < 10) + { + mList2.Add("0" + m.ToString()); + } + else + { + mList2.Add(m.ToString()); + } + } + mUIPickerView.setNPicker(mList1, mList2, null); + mUIPickerView.setCurrentItems(dtNow.Hour, dtNow.Minute, 0); + if (CurentDoorLockTime != null) + { + curYear = CurentDoorLockTime.Year; + curMonth = CurentDoorLockTime.Month; + curDay = CurentDoorLockTime.Day; + } + else + { + curYear = dtNow.Year; + curMonth = dtNow.Month; + curDay = dtNow.Day; + } + curHour = dtNow.Hour; + curMin = dtNow.Minute; + curSec = dtNow.Second; + mUIPickerView.OnSelectChangeEvent += (h, m, s) => + { + curHour = h; + curMin = m; + curSec = dtNow.Second; + }; + + if (setTimeType == "ValidTime") + { + DoorLockCommonInfo.ValidDateHour = curHour; + DoorLockCommonInfo.ValidDateMinute = curMin; + DoorLockCommonInfo.ValidDateSecond = curSec; + } + else + { + DoorLockCommonInfo.InValidDateHour = curHour; + DoorLockCommonInfo.InValidDateMinute = curMin; + DoorLockCommonInfo.InValidDateSecond = curSec; + } + + if (setTimeType != "DoorLockTime") + { + var btnOk = new Button + { + X = Application.GetRealWidth(919), + Y = Application.GetRealHeight(40), + Height = Application.GetRealHeight(58), + Width = Application.GetRealWidth(101), + Text = Language.StringByID(R.MyInternationalizationString.Complete), + TextColor = Shared.Common.ZigbeeColor.Current.XMOrange, + TextSize = 14, + }; + this.bottomRadiusFrameLayout.AddChidren(btnOk); + btnOk.MouseUpEventHandler += (sender1, e1) => + { + if (setTimeType == "ValidTime") + { + DoorLockCommonInfo.ValidDateHour = curHour; + DoorLockCommonInfo.ValidDateMinute = curMin; + DoorLockCommonInfo.ValidDateSecond = curSec; + } + else + { + DoorLockCommonInfo.InValidDateHour = curHour; + DoorLockCommonInfo.InValidDateMinute = curMin; + DoorLockCommonInfo.InValidDateSecond = curSec; + } + if (timeSetAction != null) + { + timeSetAction(); + } + this.shadowRadiusFrameLayout.RemoveFromParent(); + MidFrameLayoutContent(); + }; + } + } } + #endregion + + #region 绉婚櫎鏂规硶 /// <summary> - /// Changeds the IS cene status. + /// 閲嶅啓绉婚櫎鏂规硶 /// </summary> - /// <param name="scene">Scene.</param> - public void ChangedISceneStatus(Scene scene) + public override void RemoveFromParent() { + ZbGateway.StatusList.Remove(this); + base.RemoveFromParent(); } #endregion } -- Gitblit v1.8.0