From f14dcfd967404e197e7ec995ca8d6f2b090d3b7d Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期五, 11 九月 2020 09:16:59 +0800 Subject: [PATCH] 优化多功能面板:绑定温湿度传感器目标,和设备列表回路显示。优化数据矫正功能温湿度度不设置的情况。优化门锁时间设置最后一天和最后最后一个月的时间显示等 细节 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs | 64 ++++++++++++++++++++++++------- 1 files changed, 49 insertions(+), 15 deletions(-) diff --git a/ZigbeeApp20200825/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs similarity index 85% rename from ZigbeeApp20200825/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs rename to ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs index c4572c8..72ed6e8 100644 --- a/ZigbeeApp20200825/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs @@ -45,13 +45,27 @@ /// </summary> public Action FinishInputEvent = null; /// <summary> - /// 鏈�澶ц緭鍏ラ暱搴�(鐩墠鍙拡瀵规寜涓嬪洖杞﹂敭鏃惰繘琛屾娴�,瓒呰繃鏃�,涓嶄細璋冪敤FinishInputEvent) - /// </summary> - public int MaxByte = 0; - /// <summary> /// 鎸囧畾璇ヨ緭鍏ユ鏄惁涓轰笉鍙渷鐣�(榛樿涓篺alse) /// </summary> public bool MustInput = false; + + private int m_MaxByte = -1; + /// <summary> + /// 鏈�澶ц緭鍏yte闀垮害 + /// </summary> + public int MaxByte + { + get { return m_MaxByte; } + set + { + m_MaxByte = value; + this.TextChangeEventHandler -= this.TxtCode_TextChangedEvent; + if (m_MaxByte > 0) + { + this.TextChangeEventHandler += this.TxtCode_TextChangedEvent; + } + } + } private bool m_UseFocusColor = false; /// <summary> @@ -236,6 +250,37 @@ this.FinishInputEvent?.Invoke(); } + /// <summary> + /// 鍊兼敼鍙樹簨浠� + /// </summary> + /// <param name="sender"></param> + /// <param name="value"></param> + private void TxtCode_TextChangedEvent(object sender, string value) + { + var byteData = Encoding.UTF8.GetBytes(value); + + //濡傛灉杈撳叆鐨勫��,宸茬粡澶т簬鎸囧畾鐨刡yte鏁�,鍒欐埅鍙� + if (byteData.Length > this.m_MaxByte) + { + //鎴彇鎸囧畾鐨刡yte瀛楄妭 + var newValue = Encoding.UTF8.GetString(byteData, 0, this.m_MaxByte); + //鏈�鍚庝竴浣嶄笉瑕�,鍥犱负鎴彇鐨勬渶鍚庝竴浣嶅彲鑳芥槸涔辩爜 + newValue = newValue.Substring(0, newValue.Length - 1); + //鎷兼帴涓婂畠鐨勪笅涓�浣�,鐒跺悗妫�娴� + var checkValue = newValue + value[newValue.Length]; + if (Encoding.UTF8.GetBytes(checkValue).Length <= this.m_MaxByte) + { + //姝eソ鍖归厤byte鏁� + newValue = checkValue; + } + this.Text = newValue; +#if Android + //灏嗗厜鏍囪嚦浜庢渶鍚� + this.SetSelectionEnd(); +#endif + } + } + #endregion #region 鈻� 妫�娴嬮敊璇痏__________________________ @@ -287,17 +332,6 @@ /// <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; } -- Gitblit v1.8.0