| | |
| | | public class ShowDoorLockMsgControl
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | | /// <summary>
|
| | | /// 点击失效回调的事件
|
| | | /// </summary>
|
| | | public Action<string> InvalidTimeAction = null;
|
| | | /// <summary>
|
| | | /// 点击取消的事件
|
| | | /// 点击取消的回调事件
|
| | | /// </summary>
|
| | | public Action CancelClickEvent = null; |
| | | /// <summary>
|
| | | /// 点击自动化的事件
|
| | | /// 点击自动化的回调事件
|
| | | /// </summary>
|
| | | public Action LogicClickEvent = null; |
| | | /// <summary>
|
| | | /// 点击确认的事件
|
| | | /// 点击确认的回调事件
|
| | | /// </summary>
|
| | | public Action InvalidClickEvent = null;
|
| | | /// <summary>
|
| | | /// 点击确认的事件
|
| | | /// 点击确认的回调事件
|
| | | /// </summary>
|
| | | public Action ConfirmClickEvent = null;
|
| | | /// <summary>
|
| | | /// 点击弹窗背景回调事件
|
| | | /// </summary>
|
| | | public Action MsgControlClickEvent = null;
|
| | | /// <summary>
|
| | | /// 信息类型
|
| | | /// </summary>
|
| | | private DoorLockMsgType msgType = DoorLockMsgType.Confirm;
|
| | | /// <summary>
|
| | | /// 弹窗背景
|
| | | /// </summary>
|
| | | public FrameLayout MsgControlFrameLayout = null;
|
| | | /// <summary>
|
| | | /// 消息
|
| | | /// </summary>
|
| | |
| | | return;
|
| | | }
|
| | | //主控件
|
| | | var frameMain = new FrameLayout();
|
| | | frameMain.BackgroundColor = UserCenterColor.Current.DialogBackColor;
|
| | | ((ViewGroup)nowForm).AddChidren(frameMain);
|
| | | MsgControlFrameLayout = new FrameLayout();
|
| | | MsgControlFrameLayout.BackgroundColor = UserCenterColor.Current.DialogBackColor;
|
| | | ((ViewGroup)nowForm).AddChidren(MsgControlFrameLayout);
|
| | | MsgControlFrameLayout.MouseDownEventHandler += (sender, e) =>
|
| | | {
|
| | | //移除界面
|
| | | MsgControlFrameLayout.RemoveFromParent();
|
| | | //回调函数
|
| | | this.MsgControlClickEvent?.Invoke();
|
| | | this.MsgControlClickEvent = null;
|
| | | };
|
| | |
|
| | | //白色背景框
|
| | | var frameBack = new FrameLayout();
|
| | |
| | | frameBack.Width = Application.GetRealWidth(792); |
| | | frameBack.Y = Application.GetRealHeight(706); |
| | | }
|
| | | frameMain.AddChidren(frameBack); |
| | | MsgControlFrameLayout.AddChidren(frameBack); |
| | | |
| | | //标题 |
| | | var btnTitle = new NormalViewControl(frameBack.Width, Application.GetRealHeight(65), false);
|
| | |
| | | if (msgType == DoorLockMsgType.Confirm || msgType == DoorLockMsgType.InValid || msgType == DoorLockMsgType.NomallyOpenMode)
|
| | | {
|
| | | //初始化确认类型的底部按钮
|
| | | this.InitBottomConfirmButton(frameMain, frameBack);
|
| | | this.InitBottomConfirmButton(MsgControlFrameLayout, frameBack);
|
| | | } |
| | | else if (msgType == DoorLockMsgType.DoorLockLogic || msgType == DoorLockMsgType.CancelNomallyOpenModeWithLogic)
|
| | | {
|
| | | //失效设置的底部按钮
|
| | | this.InitBottomLogicButton(frameMain, frameBack);
|
| | | this.InitBottomLogicButton(MsgControlFrameLayout, frameBack);
|
| | | }
|
| | | } |
| | | |
| | |
| | | TextSize = 14, |
| | | Text = DoorLockCommonInfo.NormallyOpenModeInvalidTime.ToString(), |
| | | PlaceholderTextColor = ZigbeeColor.Current.XMGray3, |
| | | IsNumberKeyboardType = true, |
| | | }; |
| | | editTextFrameLayout.AddChidren(editInvalidTime); |
| | | |
| | | |
| | | var btnMsg2 = new Button() |
| | | { |
| | |
| | | btnConfirm.InitControl(buttonOkText);
|
| | | btnConfirm.ButtonClickEvent += (sender, e) =>
|
| | | { |
| | | string textValue = string.Empty; |
| | | if (editInvalidTime != null)
|
| | | {
|
| | | textValue = editInvalidTime.Text.Trim();
|
| | | if (this.CheckInvalidTime(textValue.TrimStart('0')) == false)
|
| | | {
|
| | | return;
|
| | | } |
| | | } |
| | | //移除界面 |
| | | frameMain.RemoveFromParent();
|
| | | if (msgType == DoorLockMsgType.InValid) |
| | | { |
| | | if (InvalidTimeAction != null) |
| | | { |
| | | InvalidTimeAction(editInvalidTime.Text); |
| | | InvalidTimeAction(textValue); |
| | | } |
| | | } |
| | | else |
| | |
| | | };
|
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 检测失效时间
|
| | | /// </summary>
|
| | | /// <param name="tetxValue"></param>
|
| | | /// <returns></returns> |
| | | private bool CheckInvalidTime(string tetxValue)
|
| | | {
|
| | | if (tetxValue == string.Empty) |
| | | {
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Error, "失效时间不能省略");
|
| | | msgContr.Show();
|
| | | return false; |
| | | }
|
| | | foreach (var c in tetxValue)
|
| | | {
|
| | | if (char.IsNumber(c) == false)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | if (tetxValue.Length >= 3)
|
| | | {
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Error, "失效时间不能大于36小时");
|
| | | msgContr.Show();
|
| | | return false;
|
| | | }
|
| | |
|
| | | int value = Convert.ToInt32(tetxValue);
|
| | | if (value <= 0)
|
| | | {
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Error, "失效时间不能小于1小时");
|
| | | msgContr.Show();
|
| | | return false;
|
| | | }
|
| | | if (value > 36)
|
| | | {
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Error, "失效时间不能大于36小时");
|
| | | msgContr.Show();
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | } |
| | | |
| | | #endregion
|
| | | |
| | | /// <summary>
|