From 9904031f5291daaf56985146bb671f25e18ebbdf Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 02 四月 2020 19:51:31 +0800
Subject: [PATCH] 最新代码

---
 ZigbeeApp/Shared/Phone/UserCenter/DoorLock/ShowDoorLockMsgControl.cs |   95 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 84 insertions(+), 11 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/ShowDoorLockMsgControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/ShowDoorLockMsgControl.cs
index 366e7e6..d1de6cc 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/ShowDoorLockMsgControl.cs
+++ b/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>

--
Gitblit v1.8.0