From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs | 86 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 83 insertions(+), 3 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs index dd06c58..1ee238d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs @@ -7,7 +7,7 @@ /// <summary> /// 楠岃瘉鐮佹帶浠� /// </summary> - public class VerificationCodeControl : FrameLayout + public class VerificationCodeControl : NormalFrameLayout { #region 鈻� 鍙橀噺澹版槑___________________________ @@ -20,9 +20,13 @@ /// </summary> public Action<string> FinishInputEvent = null; /// <summary> - /// 瀵嗙爜杈撳叆绫诲瀷 + /// 瀵嗙爜杈撳叆绫诲瀷(瀹冧笌NumberInputOnly涓嶅叡瀛�) /// </summary> public bool SecureTextEntry = false; + /// <summary> + /// 杈撳叆閿洏鎸囧畾涓烘暟瀛楅敭鐩�(榛樿涓簍rue,瀹冧笌SecureTextEntry涓嶅叡瀛�) + /// </summary> + public bool NumberInputOnly = true; /// <summary> /// 楠岃瘉鐮侀暱搴� /// </summary> @@ -64,7 +68,7 @@ frameCode.X = i * Application.GetRealWidth(115 + 49); frameCode.Width = Application.GetRealWidth(115); frameCode.Height = Application.GetRealHeight(104); - frameCode.Radius = (uint)Application.GetMinRealAverage(6); + frameCode.Radius = (uint)Application.GetRealHeight(17); frameCode.BorderWidth = 1; frameCode.BorderColor = UserCenterColor.Current.TextFrameColor; this.AddChidren(frameCode); @@ -73,6 +77,10 @@ if (SecureTextEntry == true) { txtCode.SecureTextEntry = true; + } + else if (NumberInputOnly == true) + { + txtCode.IsNumberKeyboardType = true; } txtCode.Name = i.ToString(); txtCode.TextAlignment = TextAlignment.Center; @@ -84,6 +92,8 @@ txtCode.FoucsChanged += this.TxtCode_FoucsChangedEvent; //鍊兼敼鍙樹簨浠� txtCode.TextChangeEventHandler += this.TxtCode_TextChangeEvent; + //閿洏浜嬩欢 + txtCode.KeyEventAction += this.TxtCode_KeyEvent; } } @@ -105,7 +115,25 @@ } if (e.Focus == true) { + //鑷姩鐒︾偣閫夋嫨鍓嶉潰鐨勭┖鐧戒綅缃� + //if (txtCode.Text == string.Empty) + //{ + // for (int i = 0; i < this.CodeLenth; i++) + // { + // if (dicCodeControls[i].Text == string.Empty) + // { + // dicCodeControls[i].FoucsChanged -= this.TxtCode_FoucsChangedEvent; + // dicCodeControls[i].Parent.BorderColor = UserCenterColor.Current.TextFrameSelectColor; + // dicCodeControls[i].Foucs = true; + // dicCodeControls[i].FoucsChanged += this.TxtCode_FoucsChangedEvent; + // return; + // } + // } + //} txtCode.Parent.BorderColor = UserCenterColor.Current.TextFrameSelectColor; +#if Android + txtCode.SetSelectionEnd(); +#endif } else { @@ -130,6 +158,10 @@ if (textValue.Length == this.CodeLenth) { dicCodeControls[this.CodeLenth - 1].Foucs = true; +#if Android + //鍏夋爣鑷充簬鏈�鍚� + dicCodeControls[this.CodeLenth - 1].SetSelectionEnd(); +#endif for (int i = 0; i < this.CodeLenth; i++) { //鍏堢Щ闄や簨浠� @@ -158,9 +190,17 @@ if (dicCodeControls.ContainsKey(index + 1) == true) { dicCodeControls[index + 1].Foucs = true; +#if Android + //鍏夋爣鑷充簬鏈�鍚� + dicCodeControls[index + 1].SetSelectionEnd(); +#endif } else { +#if Android + //鍏夋爣鑷充簬鏈�鍚� + txtCode.SetSelectionEnd(); +#endif //鏈�鍚庝竴浣嶈緭鍏ュ畬鎴�,鏍¢獙楠岃瘉鐮� string code = string.Empty; for (int i = 0; i < this.CodeLenth; i++) @@ -168,6 +208,30 @@ code += dicCodeControls[i].Text; } this.FinishInputEvent?.Invoke(code); + } + } + } + + /// <summary> + /// 閿洏浜嬩欢 + /// </summary> + /// <param name="keysCode"></param> + private void TxtCode_KeyEvent(object sender, string keysCode) + { + if (keysCode == "Del") + { + var txtCode = (TextInputControl)sender; + if (txtCode.Text == string.Empty) + { + int index = Convert.ToInt32(txtCode.Name); + if (dicCodeControls.ContainsKey(index - 1) == true) + { + dicCodeControls[index - 1].Foucs = true; +#if Android + //鍏夋爣鑷充簬鏈�鍚� + dicCodeControls[index - 1].SetSelectionEnd(); +#endif + } } } } @@ -187,6 +251,22 @@ } } + /// <summary> + /// 娓呯┖杈撳叆鐨勫�� + /// </summary> + public void ClearInputValue() + { + foreach (var inputText in this.dicCodeControls.Values) + { + //鍏堢Щ闄や簨浠� + inputText.TextChangeEventHandler -= TxtCode_TextChangeEvent; + //璧嬪�� + inputText.Text = string.Empty; + inputText.TextChangeEventHandler += TxtCode_TextChangeEvent; + } + dicCodeControls[0].Foucs = true; + } + #endregion #region 鈻� 鎺т欢鎽ф瘉___________________________ -- Gitblit v1.8.0