wei
2020-12-19 d6aec3027ebec50e1096af7da19d03b1e5f5bea4
HDL_ON/Entity/Function/Scene.cs
@@ -64,36 +64,10 @@
        /// 延时
        /// </summary>
        public string delay = "0";
        ///// <summary>
        ///// 延时显示的文本
        ///// </summary>
        //[Newtonsoft.Json.JsonIgnore]
        //public string delayText
        //{
        //    get
        //    {
        //        string text = "";
        //        switch (delay)
        //        {
        //            case 0:
        //                text = Language.StringByID(StringId.NoDelay);
        //                break;
        //            case 30:
        //                text = "30s";
        //                break;
        //            case 60:
        //                text = "1min";
        //                break;
        //            case 120:
        //                text = "2min";
        //                break;
        //            case 300:
        //                text = "5min";
        //                break;
        //        }
        //        return text;
        //    }
        //}
        /// <summary>
        /// 场景的最好一次执行时间
        /// </summary>
        public string LastExecutionTime = "";
        /// <summary>
        /// 场景分组
@@ -239,6 +213,57 @@
                return "SceneData_" + sid;
            }
        }
        /// <summary>
        /// 场景执行\倒计时
        /// </summary>
        /// <param name="btnShowDelay"></param>
        public void SceneCountDown(Button btnShowDelay)
        {
            //场景正在倒计时执行中
            if (LastExecutionTime != "" && Convert.ToDouble(LastExecutionTime) + Convert.ToDouble(delay) > Convert.ToDouble(Utlis.GetTimestamp(false)))
            {
                int time = 0;
                int.TryParse(Convert.ToInt32(
                    Convert.ToDouble(LastExecutionTime) + Convert.ToDouble(delay) - Convert.ToDouble(Utlis.GetTimestamp(false))
                    ).ToString(), out time);
                if (time > 0)
                {
                    new System.Threading.Thread(() =>
                    {
                        if (time > 0)
                        {
                            while (time > 0)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    if (time / 60 > 1)
                                    {
                                        btnShowDelay.Text = (time / 60).ToString() + "min";
                                    }
                                    else
                                    {
                                        btnShowDelay.Text = (time--).ToString() + "s";
                                    }
                                });
                                if (time / 60 > 1)
                                {
                                    System.Threading.Thread.Sleep(time / 60 * 60000);
                                }
                                else
                                {
                                    System.Threading.Thread.Sleep(1000);
                                }
                            }
                            Application.RunOnMainThread(() =>
                            {
                                btnShowDelay.Text = "";
                            });
                        }
                    })
                    { IsBackground = true, Priority = System.Threading.ThreadPriority.BelowNormal }.Start();
                }
            }
        }
        /// <summary>
        /// 保存功能数据