黄学彪
2020-04-02 9904031f5291daaf56985146bb671f25e18ebbdf
ZigbeeApp/Shared/Phone/Device/Category/SelectDelayTime.cs
@@ -15,7 +15,7 @@
        /// <summary>
        /// totalSecond
        /// </summary>
        private int totalSecond;
        public int totalSecond;
        /// <summary>
        /// selectedTimeAction
        /// </summary>
@@ -23,52 +23,38 @@
        #endregion
        /// <summary>
        /// SelectDelayTime
        /// </summary>
        public SelectDelayTime()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            Tag = "categoryAddScene";
            //Tag = "categoryAddScene";
        }
        /// <summary>
        /// RemoveFromParent
        /// </summary>
        public override void RemoveFromParent()
        {
            base.RemoveFromParent();
        }
        /// <summary>
        /// sceneTargetDevice
        /// </summary>
        public SceneTargetDeviceUI sceneTargetDevice;
        /// <summary>
        /// Show
        /// </summary>
        public void Show()
        {
            if (sceneTargetDevice == null)
            {
                sceneTargetDevice = new SceneTargetDeviceUI { Type = 1 };
                sceneTargetDevice = new SceneTargetDeviceUI { Type = 2 };
            }
            AddTop();
            AddBodyView();
            void selectTimeMouseUpEvent(object sender, MouseEventArgs e)
            {
                //if (!string.IsNullOrEmpty(targetDeviceID))
                //{
                //var targetDeviceUI = CategoryAddScene.sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == targetDeviceID);
                //    if (targetDeviceUI != null)
                //    {
                //        targetDeviceUI.DelayTime= SceneTargetDevice.DelayTime;
                //        targetDeviceUI.Type = SceneTargetDevice.Type;
                //    }
                //}
                //UserView.HomePage.Instance.RemoveViewByTag("categoryAddScene");
                //var categoryAddScene = new CategoryAddScene();
                //UserView.HomePage.Instance.AddChidren(categoryAddScene);
                //UserView.HomePage.Instance.PageIndex += 1;
                //categoryAddScene.Show();
            }
        }
@@ -81,7 +67,7 @@
            var top = new TopFrameLayout();
            AddChidren(top);
            top.InitTopview();
            top.SetTopTitle(R.MyInternationalizationString.AddScence);
            top.SetTopTitle(R.MyInternationalizationString.AddDelayTime);
            top.backButton.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
@@ -104,20 +90,20 @@
            var bg1 = new FrameLayout
            {
                Y = Application.GetRealHeight(118),
                Height = Application.GetRealHeight(207),
                Width = Application.GetRealWidth(207),
                Height = Application.GetMinRealAverage(207),
                Width = Application.GetMinRealAverage(207),
                Gravity = Gravity.CenterHorizontal,
                Radius = (uint)Application.GetRealHeight(207 / 2),
                Radius = (uint)Application.GetMinRealAverage(207 / 2),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            bodyFrameLayout.AddChidren(bg1);
            var bg2 = new FrameLayout
            {
                Height = Application.GetRealHeight(184),
                Width = Application.GetRealWidth(184),
                Height = Application.GetMinRealAverage(184),
                Width = Application.GetMinRealAverage(184),
                Gravity = Gravity.Center,
                Radius = (uint)Application.GetRealHeight(184 / 2),
                Radius = (uint)Application.GetMinRealAverage(184 / 2),
                BackgroundColor = ZigbeeColor.Current.GXCSelectedBackgroundColor,
            };
            bg1.AddChidren(bg2);
@@ -127,7 +113,7 @@
                Height = Application.GetMinRealAverage(124),
                Width = Application.GetMinRealAverage(124),
                Gravity = Gravity.Center,
                Radius = (uint)Application.GetRealHeight(124 / 2),
                Radius = (uint)Application.GetRealHeight(58),
                UnSelectedImagePath = "Item/Timer.png"
            };
            bg1.AddChidren(timeImg);
@@ -140,6 +126,7 @@
                Gravity = Gravity.CenterHorizontal,
                TextID = R.MyInternationalizationString.SelectTimeForAction,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextSize=15,
                IsMoreLines = true
            };
            bodyFrameLayout.AddChidren(tip);
@@ -149,7 +136,7 @@
                Y = Application.GetRealHeight(611),
                Height = Application.GetRealHeight(1126),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                Radius = (uint)Application.GetRealHeight(17),
                Radius = (uint)Application.GetRealHeight(58),
            };
            bodyFrameLayout.AddChidren(midFL);
@@ -167,23 +154,38 @@
            };
            timeFL.AddChidren(pickView);
            var minuList = new List<int> { };
            var secList = new List<int> { };
            var minuStrList = new List<string> { };
            var secStrList = new List<string> { };
            for (int i = 0; i < 60; i++)
            //分
            string strMinute = Language.StringByID(R.MyInternationalizationString.uMinute);
            //秒
            string strSecond = Language.StringByID(R.MyInternationalizationString.uSecond);
            var listfirst = new List<string>();
            var listSecond = new List<List<string>>();
            for (int i = 0; i <= 59; i++)
            {
                minuList.Add(i);
                minuStrList.Add($"{i}{Language.StringByID(R.MyInternationalizationString.Minute)}");
                secList.Add(i);
                secStrList.Add($"{i}{Language.StringByID(R.MyInternationalizationString.Second)}");
                listfirst.Add(i.ToString().PadLeft(2, '0') + strMinute);
                var listTemp = new List<string>();
                for (int j = 0; j <= 59; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        continue;
                    }
                    listTemp.Add(j.ToString().PadLeft(2, '0') + strSecond);
                }
                listSecond.Add(listTemp);
            }
            pickView.setNPicker(minuStrList, secStrList, null);
            pickView.OnSelectChangeEvent += (l1, l2, l3) =>
            {
                totalSecond = minuList[l1] * 60 + secList[l2];
            //加一个60分钟吧
            listfirst.Add("60" + strMinute);
            var listTemp2 = new List<string>() { "00" + strSecond };
            listSecond.Add(listTemp2);
            pickView.setPicker(listfirst, listSecond);
            pickView.setCurrentItems(totalSecond / 60, totalSecond % 60, 0);
            pickView.OnSelectChangeEvent += (value1, value2, value3) =>
            {
                int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2));
                int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
                totalSecond = minute * 60 + second;
            };
            var confirmBtn = new CommonForm.CompleteButton(1656, 907, 127);
@@ -191,9 +193,16 @@
            confirmBtn.SetTitle(R.MyInternationalizationString.Save);
            confirmBtn.MouseUpEventHandler += (sender, e) =>
            {
                sceneTargetDevice.DelayTime = totalSecond;
                selectedTimeAction?.Invoke(sceneTargetDevice);
                RemoveFromParent();
                if (totalSecond == 0)
                {
                    RemoveFromParent();
                }
                else
                {
                    sceneTargetDevice.DelayTime = totalSecond;
                    selectedTimeAction?.Invoke(sceneTargetDevice);
                    RemoveFromParent();
                }
            };
        }