黄学彪
2019-12-30 3dcbd186c42c598c0c08d1cd37034cf2baa09e54
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs
@@ -29,6 +29,7 @@
                                CurentDoorLockTime = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetLocalTime(dataReport.AttriButeData);
                                Application.RunOnMainThread(() =>
                                {
                                    waitGetDoorLockTime = DateTime.MaxValue;
                                    textDisplayDate.Text = CurentDoorLockTime.Year + Language.StringByID(R.MyInternationalizationString.Year) + CurentDoorLockTime.Month + Language.StringByID(R.MyInternationalizationString.Month) + CurentDoorLockTime.Day + Language.StringByID(R.MyInternationalizationString.Day);
                                    if (CurentDoorLockTime.Minute < 10)
                                    {
@@ -38,6 +39,7 @@
                                    {
                                        textDisplayTime.Text = CurentDoorLockTime.Hour + ":" + CurentDoorLockTime.Minute;
                                    }
                                    CommonPage.Loading.Hide();
                                });
                            }
                        }
@@ -71,6 +73,7 @@
        int curMin = 0;
        int curSec = 0;
        public Action timeSetAction;
        DateTime waitGetDoorLockTime = DateTime.MaxValue;
        #endregion
        /// <summary>
@@ -114,12 +117,23 @@
        {
            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);
                    }
@@ -149,7 +163,7 @@
                    X = Application.GetRealWidth(58),
                    TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextSize = 12,
                    TextSize = 14,
                };
                rowLayout.AddChidren(btnDateTime);
@@ -173,7 +187,7 @@
                {
                    Width = Application.GetRealWidth(58),
                    Height = Application.GetRealHeight(58),
                    UnSelectedImagePath = "Item/Next.png",
                    UnSelectedImagePath = "Item/RightNext.png",
                    SelectedImagePath = "Item/Down.png",
                };
                btnNextFrameLayout.AddChidren(btnNext);
@@ -187,11 +201,6 @@
                };
                MidTopFrameLayout.AddChidren(btnLine);
                if (setTimeType != "DoorLockTime")
                {
                    textDisplayDateFrameLayout.Width = 0;
                }
                if (i == 0)
                {
                    btnDateTime.Y = textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = Application.GetRealHeight(50);
@@ -201,15 +210,22 @@
                    {
                        TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                        TextAlignment = TextAlignment.CenterRight,
                        TextSize = 12,
                        TextSize = 14,
                        Text = "_" + Language.StringByID(R.MyInternationalizationString.Year) + "_" + Language.StringByID(R.MyInternationalizationString.Month) + "_" + Language.StringByID(R.MyInternationalizationString.Day),
                    };
                    textDisplayDateFrameLayout.AddChidren(textDisplayDate);
                    //textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = btnDateTime.Y;
                    if (setTimeType != "DoorLockTime")
                    {
                        btnDateTime.Text = Language.StringByID(R.MyInternationalizationString.Date);
                        if (setTimeType == "ValidTime")
                        {
                            textDisplayDate.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMonth + Language.StringByID(R.MyInternationalizationString.Month) + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateDay + Language.StringByID(R.MyInternationalizationString.Day);
                        }
                        else if (setTimeType == "InValidTime")
                        {
                            textDisplayDate.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMonth + Language.StringByID(R.MyInternationalizationString.Month) + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateDay + Language.StringByID(R.MyInternationalizationString.Day);
                        }
                    }
                    else
                    {
@@ -225,15 +241,36 @@
                    {
                        TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                        TextAlignment = TextAlignment.CenterRight,
                        TextSize = 12,
                        TextSize = 14,
                        Text = "00:00",
                    };
                    textDisplayDateFrameLayout.AddChidren(textDisplayTime);
                    //textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = btnDateTime.Y;
                    if (setTimeType != "DoorLockTime")
                    {
                        btnDateTime.Text = Language.StringByID(R.MyInternationalizationString.Time);
                        if (setTimeType == "ValidTime")
                        {
                            if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute < 10)
                            {
                                textDisplayTime.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour + ":" + "0" + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute;
                            }
                            else
                            {
                                textDisplayTime.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour + ":" + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute;
                            }
                        }
                        else if (setTimeType == "InValidTime")
                        {
                            if (Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute < 10)
                            {
                                textDisplayTime.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour + ":" + "0" + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute;
                            }
                            else
                            {
                                textDisplayTime.Text = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour + ":" + Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute;
                            }
                        }
                    }
                    else
                    {
@@ -245,13 +282,72 @@
                EventHandler<MouseEventArgs> hander = (sender, e) =>
                {
                    this.midFrameLayout.AddChidren(this.shadowRadiusFrameLayout);
                    this.bottomRadiusFrameLayout.RemoveAll();
                    this.BottomRadiusFrameLayout(this);
                    var mUIPickerView = new UIPickerView()
                    {
                        X = Application.GetRealWidth(0),
                    };
                    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)
                    {
@@ -281,15 +377,56 @@
                        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);
                                }
                            }
                            else
                            {
                                btnTextM.Width = Application.GetRealWidth(0);
                            }
                        }
                        for (int d = 1; d < days; d++)
                        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);
                                }
                            }
                            else
                            {
                                btnTextD.Width = Application.GetRealWidth(0);
                            }
                        }
                        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;
@@ -313,7 +450,7 @@
                                Height = Application.GetRealHeight(58),
                                Width = Application.GetRealWidth(101),
                                Text = Language.StringByID(R.MyInternationalizationString.Complete),
                                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                                TextColor = Shared.Common.ZigbeeColor.Current.XMOrange,
                                TextSize = 14,
                            };
                            this.bottomRadiusFrameLayout.AddChidren(btnOk);
@@ -336,11 +473,16 @@
                                    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);
                            curYear = dtNow.Year;
                            curMonth = dtNow.Month;
@@ -356,7 +498,7 @@
                                curHour = dtNow.Hour;
                                curMin = dtNow.Minute;
                                curSec = dtNow.Second;
                            }
                            }
                        }
                        Action dAction = () =>
@@ -370,16 +512,37 @@
                                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);
                                        }
                                    }
                                    else
                                    {
                                        btnTextD.Width = Application.GetRealWidth(0);
                                    }
                                }
                                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);
                                }
                            }
@@ -438,8 +601,10 @@
                                mList2.Add(m.ToString());
                            }
                        }
                        // mUIPickerView.setNPicker(mList1, mList2, new List<string> { });
                        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)
                        {
@@ -485,7 +650,7 @@
                                Height = Application.GetRealHeight(58),
                                Width = Application.GetRealWidth(101),
                                Text = Language.StringByID(R.MyInternationalizationString.Complete),
                                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                                TextColor = Shared.Common.ZigbeeColor.Current.XMOrange,
                                TextSize = 14,
                            };
                            this.bottomRadiusFrameLayout.AddChidren(btnOk);
@@ -508,6 +673,8 @@
                                    timeSetAction();
                                }
                                this.shadowRadiusFrameLayout.RemoveFromParent();
                                this.bottomRadiusFrameLayout.RemoveFromParent();
                                MidFrameLayoutContent();
                            };
                        }
                    }
@@ -562,10 +729,14 @@
                this.shadowRadiusFrameLayout.RemoveFromParent();
            };
            //等待从门锁上面加载出的时间
            //System.Threading.Thread.Sleep(1500);
            //CommonPage.Loading.Hide();
            if (setTimeType == "DoorLockTime")
            {
                if (CurentDoorLockTime != null && CurentDoorLockTime.Year != 1)
                {
                    waitGetDoorLockTime = DateTime.MaxValue;
                    CommonPage.Loading.Hide();
                }
            }
        }
        #region ◆ 接口实现__________________________