using Shared; using HDL_ON.UI.CSS; using HDL_ON.Stan; using System; using System.Collections.Generic; using System.Text; namespace HDL_ON.UI { /// /// 门锁的选择日期时间界面 /// public class DoorLockSelectTimePage : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 选择结束的事件 /// public Action SelectFinshEvent = null; /// /// 选择的时间 /// private DateTime selectDateTime; /// /// 时间校验 /// 是否需要校验时间大于当前时间 /// public bool TimeCheck = false; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// 一个时间 public void ShowForm(DateTime i_dateTime) { this.selectDateTime = i_dateTime; //选择时间 base.SetTitleText(Language.StringByID(StringId.SelectTime)); //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); //选择日期 var rowDate = new FrameLayout() { Height = Application.GetRealHeight(50), }; rowDate.BackgroundColor = CSS_Color.MainBackgroundColor; bodyFrameLayout.AddChidren(rowDate); var btnDateLeft = new Button() { TextID = StringId.SelectDate, TextAlignment = TextAlignment.CenterLeft, Width = Application.GetRealWidth(300), X = Application.GetRealWidth(16), TextColor = CSS_Color.FirstLevelTitleColor, }; rowDate.AddChidren(btnDateLeft); var btnDateRight = new Button() { X = Application.GetRealWidth(339), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/Right.png", }; rowDate.AddChidren(btnDateRight); rowDate.AddChidren(new Button() { X = Application.GetRealWidth(16),Y = Application.GetRealHeight(49), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor }); var btnDay = new Button() { Width = Application.GetRealWidth(327), TextAlignment = TextAlignment.CenterRight, Text = selectDateTime.ToString("yyyy.MM.dd"), TextColor = CSS_Color.FirstLevelTitleColor, }; rowDate.AddChidren(btnDay); EventHandler dateEvent = (sender, e) => { //显示日期选择的底部弹窗 var contr = new BottomDateSelectControl(); contr.InitControl(this.selectDateTime.Year, this.selectDateTime.Month, this.selectDateTime.Day, 0, 1); contr.FinishEvent += (div, year, month, day) => { //覆盖时间 if (div == 1) { this.selectDateTime = new DateTime(year, month, day, this.selectDateTime.Hour, this.selectDateTime.Minute, 0); btnDay.Text = this.selectDateTime.ToString("yyyy.MM.dd"); } }; }; btnDateLeft.MouseUpEventHandler = dateEvent; btnDateRight.MouseUpEventHandler = dateEvent; btnDay.MouseUpEventHandler = dateEvent; //选择时间 var rowTime = new FrameLayout() { Y = rowDate.Bottom, Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; bodyFrameLayout.AddChidren(rowTime); rowTime.AddChidren(new Button() { X = Application.GetRealWidth(16),Y = Application.GetRealHeight(49), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor }); var btnTimeLeft = new Button() { TextID = StringId.SelectTime, TextAlignment = TextAlignment.CenterLeft, Width = Application.GetRealWidth(300), X = Application.GetRealWidth(16), TextColor = CSS_Color.FirstLevelTitleColor, }; rowTime.AddChidren(btnTimeLeft); var btnTimeRight = new Button() { X = Application.GetRealWidth(339), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/Right.png", }; rowTime.AddChidren(btnTimeRight); var btnTime = new Button() { Width = Application.GetRealWidth(327), TextAlignment = TextAlignment.CenterRight, Text = selectDateTime.ToString("HH:mm"), TextColor = CSS_Color.FirstLevelTitleColor, }; rowTime.AddChidren(btnTime); EventHandler timeEvent = (sender, e) => { //显示日期选择的底部弹窗 var contr = new BottomTimeSelectControl(); contr.RowCount = 4; contr.InitControl(this.selectDateTime.Hour, this.selectDateTime.Minute,250); contr.FinishEvent += (div, hour, minute) => { //覆盖时间 if (div == 1) { this.selectDateTime = new DateTime(this.selectDateTime.Year, this.selectDateTime.Month, this.selectDateTime.Day, hour, minute, 0); btnTime.Text = this.selectDateTime.ToString("HH:mm"); } }; }; btnTimeLeft.MouseUpEventHandler = timeEvent; btnTimeRight.MouseUpEventHandler = timeEvent; btnTime.MouseUpEventHandler = timeEvent; } #endregion #region ■ 界面关闭___________________________ /// /// 界面关闭 /// public override void CloseFormBefore() { if (TimeCheck) { if (DateTime.Now > this.selectDateTime.AddMinutes(1)) { new PublicAssmebly().TipMsg(StringId.Tip, StringId.TempPwdSettingTip); throw new Exception("stop"); } } base.CloseFormBefore(); //调用回调事件 this.SelectFinshEvent?.Invoke(this.selectDateTime); this.SelectFinshEvent = null; } #endregion } }