黄学彪
2020-04-02 9904031f5291daaf56985146bb671f25e18ebbdf
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/ShowDoorLockMsgControl.cs
@@ -11,27 +11,38 @@
    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>
@@ -96,9 +107,17 @@
                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();
@@ -117,7 +136,7 @@
                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);
@@ -163,12 +182,12 @@
            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);
            }
        }
@@ -243,8 +262,10 @@
                TextSize = 14,
                Text = DoorLockCommonInfo.NormallyOpenModeInvalidTime.ToString(),
                PlaceholderTextColor = ZigbeeColor.Current.XMGray3,
                IsNumberKeyboardType = true,
            };
            editTextFrameLayout.AddChidren(editInvalidTime);
            var btnMsg2 = new Button()
            {
@@ -325,13 +346,22 @@
            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
@@ -343,6 +373,49 @@
            };
        }
        /// <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>