From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001 From: chenqiyang <1406175257@qq.com> Date: 星期三, 22 六月 2022 11:22:18 +0800 Subject: [PATCH] 修改引用路径 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs | 576 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 288 insertions(+), 288 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs old mode 100755 new mode 100644 index 1ee238d..d112104 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs @@ -1,288 +1,288 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Text; - -namespace Shared.Phone.UserCenter -{ - /// <summary> - /// 楠岃瘉鐮佹帶浠� - /// </summary> - public class VerificationCodeControl : NormalFrameLayout - { - #region 鈻� 鍙橀噺澹版槑___________________________ - - /// <summary> - /// 姣忎竴涓緭鍏ユ鍊兼敼鍙樹簨浠� - /// </summary> - public Action<TextInputControl, string> TxtCodeChangeEvent = null; - /// <summary> - /// 缁撴潫杈撳叆鐨勪簨浠� - /// </summary> - public Action<string> FinishInputEvent = null; - /// <summary> - /// 瀵嗙爜杈撳叆绫诲瀷(瀹冧笌NumberInputOnly涓嶅叡瀛�) - /// </summary> - public bool SecureTextEntry = false; - /// <summary> - /// 杈撳叆閿洏鎸囧畾涓烘暟瀛楅敭鐩�(榛樿涓簍rue,瀹冧笌SecureTextEntry涓嶅叡瀛�) - /// </summary> - public bool NumberInputOnly = true; - /// <summary> - /// 楠岃瘉鐮侀暱搴� - /// </summary> - private int CodeLenth = 0; - /// <summary> - /// 楠岃瘉鐮佽緭鍏ユ帶浠� - /// </summary> - private Dictionary<int, TextInputControl> dicCodeControls = new Dictionary<int, TextInputControl>(); - - #endregion - - #region 鈻� 鍒濆鍖朹____________________________ - - /// <summary> - /// 楠岃瘉鐮佹帶浠� - /// </summary> - /// <param name="i_CodeLenth">楠岃瘉鐮侀暱搴�</param> - public VerificationCodeControl(int i_CodeLenth) - { - this.CodeLenth = i_CodeLenth; - - this.Height = Application.GetRealHeight(104); - this.Width = Application.GetRealWidth(i_CodeLenth * 115 + (i_CodeLenth - 1) * 49); - this.Gravity = Gravity.CenterHorizontal; - } - - #endregion - - #region 鈻� 楠岃瘉鐮佹帶浠禵________________________ - - /// <summary> - /// 鍒濆鍖栨帶浠� - /// </summary> - public void InitControl() - { - for (int i = 0; i < this.CodeLenth; i++) - { - var frameCode = new FrameLayout(); - frameCode.X = i * Application.GetRealWidth(115 + 49); - frameCode.Width = Application.GetRealWidth(115); - frameCode.Height = Application.GetRealHeight(104); - frameCode.Radius = (uint)Application.GetRealHeight(17); - frameCode.BorderWidth = 1; - frameCode.BorderColor = UserCenterColor.Current.TextFrameColor; - this.AddChidren(frameCode); - - var txtCode = new TextInputControl(frameCode.Width, frameCode.Height, false); - if (SecureTextEntry == true) - { - txtCode.SecureTextEntry = true; - } - else if (NumberInputOnly == true) - { - txtCode.IsNumberKeyboardType = true; - } - txtCode.Name = i.ToString(); - txtCode.TextAlignment = TextAlignment.Center; - frameCode.AddChidren(txtCode); - - dicCodeControls[i] = txtCode; - - //鍏夋爣浜嬩欢 - txtCode.FoucsChanged += this.TxtCode_FoucsChangedEvent; - //鍊兼敼鍙樹簨浠� - txtCode.TextChangeEventHandler += this.TxtCode_TextChangeEvent; - //閿洏浜嬩欢 - txtCode.KeyEventAction += this.TxtCode_KeyEvent; - } - } - - #endregion - - #region 鈻� 楠岃瘉鐮佷簨浠禵________________________ - - /// <summary> - /// 楠岃瘉鐮佺劍鐐瑰彉鏇翠簨浠� - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void TxtCode_FoucsChangedEvent(object sender, FocusEventArgs e) - { - var txtCode = (TextInputControl)sender; - if (txtCode.Parent == null) - { - return; - } - 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 - { - txtCode.Parent.BorderColor = UserCenterColor.Current.TextFrameColor; - } - } - - /// <summary> - /// 楠岃瘉鐮佸�兼敼鍙樹簨浠� - /// </summary> - /// <param name="sender"></param> - /// <param name="textValue"></param> - private void TxtCode_TextChangeEvent(object sender, string textValue) - { - this.TxtCodeChangeEvent?.Invoke((TextInputControl)sender, textValue); - - if (textValue == string.Empty) - { - return; - } - //杩欎釜鏄嚜宸卞鍒剁矘璐磋繃鏉ョ殑 - 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++) - { - //鍏堢Щ闄や簨浠� - dicCodeControls[i].TextChangeEventHandler -= TxtCode_TextChangeEvent; - //璧嬪�� - dicCodeControls[i].Text = textValue[i].ToString(); - dicCodeControls[i].TextChangeEventHandler += TxtCode_TextChangeEvent; - } - //鏍¢獙楠岃瘉鐮� - this.FinishInputEvent?.Invoke(textValue); - } - else - { - //鍏夋爣绉诲姩 - var txtCode = (TextInputControl)sender; - //鍙兘涓�涓�� - if (textValue.Length > 1) - { - //鍏堢Щ闄や簨浠� - txtCode.TextChangeEventHandler -= TxtCode_TextChangeEvent; - txtCode.Text = txtCode.Text.Substring(0, 1); - txtCode.TextChangeEventHandler += TxtCode_TextChangeEvent; - } - - int index = Convert.ToInt32(txtCode.Name); - 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++) - { - 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 - } - } - } - } - - #endregion - - #region 鈻� 涓�鑸柟娉昣__________________________ - - /// <summary> - /// 璁剧疆鐒︾偣 - /// </summary> - public void SetFocus() - { - if (dicCodeControls.Count > 0) - { - dicCodeControls[0].Foucs = true; - } - } - - /// <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 鈻� 鎺т欢鎽ф瘉___________________________ - - /// <summary> - /// 鎺т欢鎽ф瘉 - /// </summary> - public override void RemoveAll() - { - this.dicCodeControls.Clear(); - this.TxtCodeChangeEvent = null; - this.FinishInputEvent = null; - - base.RemoveAll(); - } - - #endregion - } -} +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 楠岃瘉鐮佹帶浠� + /// </summary> + public class VerificationCodeControl : NormalFrameLayout + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 姣忎竴涓緭鍏ユ鍊兼敼鍙樹簨浠� + /// </summary> + public Action<TextInputControl, string> TxtCodeChangeEvent = null; + /// <summary> + /// 缁撴潫杈撳叆鐨勪簨浠� + /// </summary> + public Action<string> FinishInputEvent = null; + /// <summary> + /// 瀵嗙爜杈撳叆绫诲瀷(瀹冧笌NumberInputOnly涓嶅叡瀛�) + /// </summary> + public bool SecureTextEntry = false; + /// <summary> + /// 杈撳叆閿洏鎸囧畾涓烘暟瀛楅敭鐩�(榛樿涓簍rue,瀹冧笌SecureTextEntry涓嶅叡瀛�) + /// </summary> + public bool NumberInputOnly = true; + /// <summary> + /// 楠岃瘉鐮侀暱搴� + /// </summary> + private int CodeLenth = 0; + /// <summary> + /// 楠岃瘉鐮佽緭鍏ユ帶浠� + /// </summary> + private Dictionary<int, TextInputControl> dicCodeControls = new Dictionary<int, TextInputControl>(); + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 楠岃瘉鐮佹帶浠� + /// </summary> + /// <param name="i_CodeLenth">楠岃瘉鐮侀暱搴�</param> + public VerificationCodeControl(int i_CodeLenth) + { + this.CodeLenth = i_CodeLenth; + + this.Height = Application.GetRealHeight(104); + this.Width = Application.GetRealWidth(i_CodeLenth * 115 + (i_CodeLenth - 1) * 49); + this.Gravity = Gravity.CenterHorizontal; + } + + #endregion + + #region 鈻� 楠岃瘉鐮佹帶浠禵________________________ + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + for (int i = 0; i < this.CodeLenth; i++) + { + var frameCode = new FrameLayout(); + frameCode.X = i * Application.GetRealWidth(115 + 49); + frameCode.Width = Application.GetRealWidth(115); + frameCode.Height = Application.GetRealHeight(104); + frameCode.Radius = (uint)Application.GetRealHeight(17); + frameCode.BorderWidth = 1; + frameCode.BorderColor = UserCenterColor.Current.TextFrameColor; + this.AddChidren(frameCode); + + var txtCode = new TextInputControl(frameCode.Width, frameCode.Height, false); + if (SecureTextEntry == true) + { + txtCode.SecureTextEntry = true; + } + else if (NumberInputOnly == true) + { + txtCode.IsNumberKeyboardType = true; + } + txtCode.Name = i.ToString(); + txtCode.TextAlignment = TextAlignment.Center; + frameCode.AddChidren(txtCode); + + dicCodeControls[i] = txtCode; + + //鍏夋爣浜嬩欢 + txtCode.FoucsChanged += this.TxtCode_FoucsChangedEvent; + //鍊兼敼鍙樹簨浠� + txtCode.TextChangeEventHandler += this.TxtCode_TextChangeEvent; + //閿洏浜嬩欢 + txtCode.KeyEventAction += this.TxtCode_KeyEvent; + } + } + + #endregion + + #region 鈻� 楠岃瘉鐮佷簨浠禵________________________ + + /// <summary> + /// 楠岃瘉鐮佺劍鐐瑰彉鏇翠簨浠� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void TxtCode_FoucsChangedEvent(object sender, FocusEventArgs e) + { + var txtCode = (TextInputControl)sender; + if (txtCode.Parent == null) + { + return; + } + 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 + { + txtCode.Parent.BorderColor = UserCenterColor.Current.TextFrameColor; + } + } + + /// <summary> + /// 楠岃瘉鐮佸�兼敼鍙樹簨浠� + /// </summary> + /// <param name="sender"></param> + /// <param name="textValue"></param> + private void TxtCode_TextChangeEvent(object sender, string textValue) + { + this.TxtCodeChangeEvent?.Invoke((TextInputControl)sender, textValue); + + if (textValue == string.Empty) + { + return; + } + //杩欎釜鏄嚜宸卞鍒剁矘璐磋繃鏉ョ殑 + 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++) + { + //鍏堢Щ闄や簨浠� + dicCodeControls[i].TextChangeEventHandler -= TxtCode_TextChangeEvent; + //璧嬪�� + dicCodeControls[i].Text = textValue[i].ToString(); + dicCodeControls[i].TextChangeEventHandler += TxtCode_TextChangeEvent; + } + //鏍¢獙楠岃瘉鐮� + this.FinishInputEvent?.Invoke(textValue); + } + else + { + //鍏夋爣绉诲姩 + var txtCode = (TextInputControl)sender; + //鍙兘涓�涓�� + if (textValue.Length > 1) + { + //鍏堢Щ闄や簨浠� + txtCode.TextChangeEventHandler -= TxtCode_TextChangeEvent; + txtCode.Text = txtCode.Text.Substring(0, 1); + txtCode.TextChangeEventHandler += TxtCode_TextChangeEvent; + } + + int index = Convert.ToInt32(txtCode.Name); + 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++) + { + 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 + } + } + } + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 璁剧疆鐒︾偣 + /// </summary> + public void SetFocus() + { + if (dicCodeControls.Count > 0) + { + dicCodeControls[0].Foucs = true; + } + } + + /// <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 鈻� 鎺т欢鎽ф瘉___________________________ + + /// <summary> + /// 鎺т欢鎽ф瘉 + /// </summary> + public override void RemoveAll() + { + this.dicCodeControls.Clear(); + this.TxtCodeChangeEvent = null; + this.FinishInputEvent = null; + + base.RemoveAll(); + } + + #endregion + } +} -- Gitblit v1.8.0