using Shared;
|
using HDL_ON.UI.CSS;
|
using HDL_ON.Stan;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace HDL_ON.UI
|
{
|
/// <summary>
|
/// 门锁常开模式失效时间设置界面(不需要添加到父控件)
|
/// </summary>
|
public class DoorLockExpireTimeSettionPage
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 结束事件(参数为,输入的小时)
|
/// </summary>
|
public Action<int> FinishEvent = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 界面显示
|
/// </summary>
|
public void ShowForm()
|
{
|
var dialogForm = new Dialog();
|
dialogForm.BackgroundColor = CSS_Color.DialogTransparentColor1;
|
//主控件
|
var frameMain = new NormalFrameLayout();
|
dialogForm.AddChidren(frameMain);
|
dialogForm.Show();
|
frameMain.ButtonClickEvent += (sender, e) =>
|
{
|
dialogForm.Close();
|
this.FinishEvent = null;
|
};
|
|
//中间区域
|
var frameCenter = new NormalFrameLayout();
|
frameCenter.Y = Application.GetRealHeight(239);
|
frameCenter.Gravity = Gravity.CenterHorizontal;
|
frameCenter.Width = Application.GetRealWidth(270);
|
frameCenter.Height = Application.GetRealHeight(172);
|
frameCenter.BackgroundColor = CSS_Color.MainBackgroundColor;
|
frameCenter.BorderColor = 0x00000000;
|
frameCenter.BorderWidth = 0;
|
frameCenter.Radius = (uint)Application.GetMinRealAverage(10);
|
frameMain.AddChidren(frameCenter);
|
|
//失效设置
|
var btnTitle = new NormalViewControl(frameCenter.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(22), false);
|
btnTitle.Y = Application.GetRealHeight(20);
|
btnTitle.Gravity = Gravity.CenterHorizontal;
|
btnTitle.TextColor = CSS_Color.MainColor;
|
btnTitle.TextSize = CSS_FontSize.SubheadingFontSize;
|
btnTitle.TextAlignment = TextAlignment.Center;
|
btnTitle.IsBold = true;
|
btnTitle.Text = Language.StringByID(StringId.FailTimeSeetion);
|
frameCenter.AddChidren(btnTitle);
|
|
//常开模式将于{0}小时后失效
|
string[] strArryMsg = Language.StringByID(StringId.AlwayOnWillCloseAtTimeMsg).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
|
|
//常开模式将于
|
var btnMsg1 = new NormalViewControl(Application.GetRealWidth(76), Application.GetRealHeight(32), false);
|
btnMsg1.X = Application.GetRealWidth(20);
|
btnMsg1.Y = btnTitle.Bottom + Application.GetRealHeight(20);
|
btnMsg1.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnMsg1.IsMoreLines = true;
|
btnMsg1.Text = strArryMsg[0].Trim();
|
frameCenter.AddChidren(btnMsg1);
|
|
//失效时间的背景容器
|
var frameTime = new FrameLayout();
|
frameTime.X = btnMsg1.Right + Application.GetRealWidth(12);
|
frameTime.Y = btnMsg1.Y;
|
frameTime.Width = Application.GetRealWidth(62);
|
frameTime.Height = Application.GetRealHeight(32);
|
frameTime.Radius = (uint)Application.GetRealWidth(4);
|
frameTime.BackgroundColor = CSS_Color.BackgroundColor;
|
frameCenter.AddChidren(frameTime);
|
//失效时间输入控件
|
var txtInput = new TextInputControl(frameTime.Width - Application.GetRealWidth(10 * 2), frameTime.Height, false);
|
txtInput.TextColor = CSS_Color.FirstLevelTitleColor;
|
txtInput.Gravity = Gravity.CenterHorizontal;
|
txtInput.TextAlignment = TextAlignment.Center;
|
txtInput.Text = "12";
|
txtInput.MaxByte = 2;
|
txtInput.IsNumberKeyboardType = true;
|
frameTime.AddChidren(txtInput);
|
|
//小时后失效
|
var btnMsg2 = new NormalViewControl(btnMsg1.Width, btnMsg1.Height, false);
|
btnMsg2.X = frameTime.Right + Application.GetRealWidth(12);
|
btnMsg2.Y = btnMsg1.Y;
|
btnMsg2.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnMsg2.IsMoreLines = true;
|
btnMsg2.Text = strArryMsg.Length > 1 ? strArryMsg[1].Trim() : string.Empty;
|
frameCenter.AddChidren(btnMsg2);
|
|
//错误显示消息
|
var btnErrorMsg = new NormalViewControl(frameCenter.Width - Application.GetRealWidth(20) * 2, Application.GetRealHeight(21), false);
|
btnErrorMsg.Y = btnMsg1.Bottom;
|
btnErrorMsg.Gravity = Gravity.CenterHorizontal;
|
btnErrorMsg.TextColor = CSS_Color.WarningColor;
|
btnErrorMsg.IsMoreLines = true;
|
btnErrorMsg.TextAlignment = TextAlignment.TopLeft;
|
//btnErrorMsg.Height = Application.GetRealHeight(21) * btnErrorMsg.GetRealRowCountByText();
|
btnErrorMsg.Visible = false;
|
frameCenter.AddChidren(btnErrorMsg);
|
|
//确认
|
var btnConfirm = new NormalViewControl(frameCenter.Width, Application.GetRealHeight(45), false);
|
btnConfirm.Gravity = Gravity.BottomCenter;
|
btnConfirm.TextAlignment = TextAlignment.Center;
|
btnConfirm.TextSize = CSS_FontSize.SubheadingFontSize;
|
btnConfirm.TextColor = CSS_Color.MainBackgroundColor;
|
btnConfirm.BackgroundColor = CSS_Color.MainColor;
|
btnConfirm.Text = Language.StringByID(StringId.Confirm);
|
frameCenter.AddChidren(btnConfirm);
|
btnConfirm.SetCornerWithSameRadius((uint)Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
|
btnConfirm.ButtonClickEvent += (sender, e) =>
|
{
|
//检测输入的时间是否正确
|
var errorMsg = this.CheckInputTime(txtInput.Text.Trim());
|
if (errorMsg != string.Empty)
|
{
|
//看看消息显示的控件有没有大于34,大于的话,则算出它增加的宽度(34是输入框到底部按钮Y轴的空白区域)
|
int value = 0;
|
if (btnErrorMsg.Height > Application.GetRealHeight(34))
|
{
|
//5是与底部按钮Y轴的间距
|
value = btnErrorMsg.Height - Application.GetRealHeight(34) + Application.GetRealHeight(5);
|
}
|
//调整白色桌布的高度和坐标
|
frameCenter.Height = frameTime.Bottom + Application.GetRealHeight(34) + btnConfirm.Height + value;
|
//白色背景在蓝湖上的坐标为239,高度为172 然后让它按这个比例置于桌布
|
frameCenter.Y = Application.GetRealHeight(239) - (frameCenter.Height - Application.GetRealHeight(172)) / 2;
|
btnConfirm.Gravity = Gravity.BottomCenter;
|
//按钮置底
|
return;
|
}
|
//关闭界面
|
dialogForm.Close();
|
//回调函数
|
FinishEvent?.Invoke(Convert.ToInt32(txtInput.Text.Trim()));
|
FinishEvent = null;
|
};
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 检测输入的时间是否正确
|
/// </summary>
|
/// <param name="i_value">输入的时间</param>
|
/// <returns></returns>
|
private string CheckInputTime(string i_value)
|
{
|
if (i_value == string.Empty)
|
{
|
//请输入失效时间
|
return Language.StringByID(StringId.PleaseInputFailTime);
|
}
|
int value = Convert.ToInt32(i_value);
|
if (value < 1)
|
{
|
//失效时间不能小于1小时
|
return Language.StringByID(StringId.InvalidTimeLessThan1);
|
}
|
if (value > 72)
|
{
|
//失效时间不能大于72小时
|
return Language.StringByID(StringId.InvalidTimeMoreThan72);
|
}
|
return string.Empty;
|
}
|
|
#endregion
|
}
|
}
|