From 0bf9e65bc3ba98391e7835c922b15baab3c77876 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 01 六月 2020 14:59:39 +0800 Subject: [PATCH] 上传一个合并的版本 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 169 insertions(+), 3 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs index c825e64..dbf1a01 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs @@ -23,9 +23,66 @@ set { this.btnLineTemp = value; - //鍏夋爣浜嬩欢 - this.FoucsChanged -= this.TxtCode_FoucsChangedEvent; - this.FoucsChanged += this.TxtCode_FoucsChangedEvent; + } + } + + /// <summary> + /// 杈撳叆缁撴潫鐨勪簨浠� + /// </summary> + public Action FinishInputEvent = null; + /// <summary> + /// 鏈�澶ц緭鍏ラ暱搴�(鐩墠鍙拡瀵规寜涓嬪洖杞﹂敭鏃惰繘琛屾娴�,瓒呰繃鏃�,涓嶄細璋冪敤FinishInputEvent) + /// </summary> + public int MaxByte = 0; + /// <summary> + /// 鎸囧畾璇ヨ緭鍏ユ鏄惁涓轰笉鍙渷鐣�(榛樿涓篺alse) + /// </summary> + public bool MustInput = false; + + private bool m_UseFocusColor = false; + /// <summary> + /// 鍏夋爣杩涘叆鏂囨湰妗嗘椂,鏄惁璁╁瓧浣撻鑹插彉鏇�(榛樿涓嶄娇鐢�) + /// </summary> + public bool UseFocusColor + { + set + { + m_UseFocusColor = value; + if (m_UseFocusColor == true) + { + //鐏拌壊瀛椾綋 + this.TextColor = UserCenterColor.Current.TextGrayColor3; + } + } + } + + private bool m_OnError = false; + /// <summary> + /// 璁╄繖涓枃鏈鏄剧ず澶勪簬閿欒鐨勭壒鏁� + /// </summary> + public bool OnError + { + get { return m_OnError; } + set + { + if (value != m_OnError) + { + m_OnError = value; + //鏆傛椂灞忚斀姝ょ壒鏁� + //if (m_OnError == true) + //{ + // //绾㈣壊 + // this.BorderColor = UserCenterColor.Current.Red; + // this.Radius = (uint)Application.GetRealHeight(17); + // this.BorderWidth = 3; + //} + //else + //{ + // this.BorderColor = UserCenterColor.Current.Transparent; + // this.BorderWidth = 0; + // this.Radius = 0; + //} + } } } @@ -44,6 +101,11 @@ this.PlaceholderTextColor = UserCenterColor.Current.TextTipColor; this.TextColor = UserCenterColor.Current.TextColor1; this.TextAlignment = TextAlignment.CenterLeft; + + //鐒︾偣浜嬩欢 + this.FoucsChanged += this.TxtCode_FoucsChangedEvent; + //鎸変笅鍥炶溅閿簨浠� + this.EditorEnterAction += this.EditorEnterEvent; } /// <summary> @@ -115,6 +177,11 @@ { btnLineTemp.BackgroundColor = UserCenterColor.Current.ButtomLine; } + if (m_UseFocusColor == true) + { + //鐏拌壊瀛椾綋 + this.TextColor = UserCenterColor.Current.TextGrayColor3; + } } else { @@ -122,7 +189,94 @@ { btnLineTemp.BackgroundColor = UserCenterColor.Current.TextFrameSelectColor; } + if (m_UseFocusColor == true) + { + //姝e父瀛椾綋 + this.TextColor = UserCenterColor.Current.TextColor1; + } } + } + + /// <summary> + /// 杈撳叆瀹屾垚浜嬩欢 + /// </summary> + /// <param name="view"></param> + private void EditorEnterEvent(View view) + { + //妫�娴嬫渶澶ц緭鍑築yte + string msg = this.CheckMaxByte(); + if (msg != null) + { + var contr = new ShowMsgControl(ShowMsgType.Tip, msg); + contr.Show(); + return; + } + this.FinishInputEvent?.Invoke(); + } + + #endregion + + #region 鈻� 妫�娴嬮敊璇痏__________________________ + + /// <summary> + /// 妫�娴嬫纭��,瀛樺湪閿欒鏃�,杩斿洖閿欒鏂囨湰,鏃犻敊璇繑鍥瀗ull + /// </summary> + /// <returns></returns> + public string CheckError() + { + //鎵ц妫�娴嬮敊璇� + string error = this.DoCheckError(); + if (error != null) + { + //鐒︾偣鎺у埗 + this.Foucs = true; + return error; + } + return null; + } + + /// <summary> + /// 鎵ц妫�娴嬮敊璇� + /// </summary> + /// <returns></returns> + private string DoCheckError() + { + //妫�娴嬫渶澶ц緭鍑築yte + string msg = this.CheckMaxByte(); + if (msg != null) { return msg; } + + //妫�娴嬪繀椤昏緭鍏� + if (this.MustInput == true && this.Text.Trim() == string.Empty) + { + if (string.IsNullOrEmpty(this.PlaceholderText) == false) + { + return this.PlaceholderText; + } + //璇ュ唴瀹逛笉鑳界渷鐣� + return Language.StringByID(R.MyInternationalizationString.uThisContentCanNotOmitted); + } + + return null; + } + + /// <summary> + /// 妫�娴嬫渶澶ц緭鍏yte + /// </summary> + /// <returns></returns> + private string CheckMaxByte() + { + if (this.MaxByte != 0) + { + if (Encoding.UTF8.GetBytes(this.Text.Trim()).Length > this.MaxByte) + { + //杈撳叆鍐呭杩囬暱,鏈�澶0}瀛楄妭 + string msg = Language.StringByID(R.MyInternationalizationString.uInputContentIsOverLengthMsg); + msg.Replace("{0}", this.MaxByte.ToString()); + + return msg; + } + } + return null; } #endregion @@ -154,6 +308,18 @@ return HdlControlLogic.Current.GetPictrueRealSize(i_size); } + /// <summary> + /// 鎺т欢绉婚櫎 + /// </summary> + public override void RemoveFromParent() + { + this.FinishInputEvent = null; + if (this.Parent != null) + { + base.RemoveFromParent(); + } + } + #endregion } } -- Gitblit v1.8.0