HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-09-18 c7df85937f73fb347ee0b19e9c052d2d00a6df6c
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/VerificationCodeControl.cs
@@ -7,7 +7,7 @@
    /// <summary>
    /// 验证码控件
    /// </summary>
    public class VerificationCodeControl : FrameLayout
    public class VerificationCodeControl : NormalFrameLayout
    {
        #region ■ 变量声明___________________________
@@ -115,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
            {
@@ -140,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++)
                {
                    //先移除事件
@@ -168,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++)
@@ -197,6 +227,10 @@
                    if (dicCodeControls.ContainsKey(index - 1) == true)
                    {
                        dicCodeControls[index - 1].Foucs = true;
#if Android
                        //光标至于最后
                        dicCodeControls[index - 1].SetSelectionEnd();
#endif
                    }
                }
            }
@@ -217,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 ■ 控件摧毁___________________________