lss
2020-06-12 9c16d3614d9b88c637f967518a329f239fcd3aaf
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/PswNumberInputControl.cs
@@ -5,9 +5,9 @@
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 密码输入控件(自制的手动按键输入类型,请实现【ActionPswFinish】事件)
    /// 数字按键密码输入控件(自制的手动按键输入类型,请实现【ActionPswFinish】事件)
    /// </summary>
    public class PswNumberInputControl : FrameLayout
    public class PswNumberInputControl : FrameLayoutBase
    {
        #region ■ 变量声明___________________________
@@ -38,11 +38,23 @@
        /// <summary>
        /// 标题控件
        /// </summary>
        private NormalViewControl btnTitle = null;
        public NormalViewControl btnTitle = null;
        /// <summary>
        /// 错误信息提示控件
        /// </summary>
        private NormalViewControl btnError = null;
        public NormalViewControl btnError = null;
        /// <summary>
        /// 显示密码黑点的Frame(有可能需要调整它的位置)
        /// </summary>
        public FrameLayout framePswIcon = null;
        /// <summary>
        /// 数字表盘的Frame(有可能需要调整它的位置)
        /// </summary>
        public FrameLayout frameNumberIcon = null;
        /// <summary>
        /// 数字表盘按键的背景色
        /// </summary>
        public uint NumberIconBackColor = 0xfff5f6fa;
        /// <summary>
        /// 删除控件
        /// </summary>
@@ -67,10 +79,11 @@
        {
            this.passwordLength = i_passwordLength;
            //加间距
            this.Width = Application.GetMinRealAverage(NumberSize * 3 + NumberLeftRightSpace * 2 + 80);
            this.Height = Application.GetMinRealAverage(NumberSize * 4 + NumberTopButtomSpace * 3) + Application.GetRealHeight(368);
            this.btnTitle = new NormalViewControl(Application.CurrentWidth, Application.GetRealWidth(63), false);
            this.Width = this.GetPictrueRealSize(NumberSize * 3 + NumberLeftRightSpace * 2 + 80);
            this.Height = this.GetPictrueRealSize(NumberSize * 4 + NumberTopButtomSpace * 3) + Application.GetRealHeight(368);
            this.btnTitle = new NormalViewControl(Application.CurrentWidth, Application.GetRealWidth(75), false);
            btnTitle.Text = i_title;
            btnTitle.IsBold = true;
        }
        /// <summary>
@@ -81,7 +94,7 @@
            //标题
            btnTitle.Width = this.Width;
            btnTitle.TextAlignment = TextAlignment.Center;
            btnTitle.TextSize = 16;
            btnTitle.TextSize = 18;
            this.AddChidren(btnTitle);
            //初始化密码图标
@@ -91,17 +104,16 @@
            this.InitNumberTableControl();
            //错误信息提示
            this.btnError = new NormalViewControl(this.Width, Application.GetRealHeight(58), false);
            btnError.Y = Application.GetRealHeight(224);
            this.btnError = new NormalViewControl(this.Width, Application.GetRealHeight(60), false);
            btnError.Y = Application.GetRealHeight(222);
            btnError.TextAlignment = TextAlignment.Center;
            btnError.TextColor = 0xfff75858;
            btnError.TextSize = 12;
            this.AddChidren(btnError);
            //删除控件
            this.btnDelete = new NormalViewControl(200, 58, true);
            btnDelete.X = this.Width - Application.GetRealWidth(200) - Application.GetMinRealAverage(40);
            btnDelete.Y = this.Height - Application.GetRealHeight(58);
            this.btnDelete = new NormalViewControl(200, 60, true);
            btnDelete.X = this.Width - Application.GetRealWidth(200) - this.GetPictrueRealSize(40);
            btnDelete.Y = this.Height - Application.GetRealHeight(60);
            btnDelete.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnDelete.TextAlignment = TextAlignment.Center;
            btnDelete.TextID = R.MyInternationalizationString.uDelete;
@@ -132,9 +144,9 @@
        private void InitPswIconControl()
        {
            //图标大小
            int iconSize = Application.GetMinRealAverage(36);
            int iconSize = this.GetPictrueRealSize(36);
            //图标间的间隔
            int space = Application.GetMinRealAverage(100);
            int space = this.GetPictrueRealSize(100);
            //计算密码个数是否越界
            int value = Application.CurrentWidth - iconSize * passwordLength;
            if (passwordLength > 1)
@@ -147,12 +159,12 @@
                space = value;
            }
            var frameBack = new FrameLayout();
            frameBack.Height = iconSize;
            frameBack.Width = iconSize * passwordLength + space * (passwordLength - 1);
            frameBack.Y = Application.GetRealHeight(149);
            frameBack.Gravity = Gravity.CenterHorizontal;
            this.AddChidren(frameBack);
            this.framePswIcon = new FrameLayout();
            framePswIcon.Height = iconSize;
            framePswIcon.Width = iconSize * passwordLength + space * (passwordLength - 1);
            framePswIcon.Y = Application.GetRealHeight(149);
            framePswIcon.Gravity = Gravity.CenterHorizontal;
            this.AddChidren(framePswIcon);
            for (int i = 0; i < passwordLength; i++)
            {
@@ -164,7 +176,7 @@
                {
                    btnIcon.X = listPswIcon[listPswIcon.Count - 1].Right + space;
                }
                frameBack.AddChidren(btnIcon);
                framePswIcon.AddChidren(btnIcon);
                listPswIcon.Add(btnIcon);
            }
        }
@@ -178,17 +190,17 @@
        /// </summary>
        private void InitNumberTableControl()
        {
            var frameBack = new FrameLayout();
            frameBack.Y = Application.GetRealHeight(368);
            frameBack.Width = this.Width;
            frameBack.Gravity = Gravity.CenterHorizontal;
            frameBack.Height = Application.GetMinRealAverage(NumberSize * 4 + NumberTopButtomSpace * 3);
            this.AddChidren(frameBack);
            this.frameNumberIcon = new FrameLayout();
            frameNumberIcon.Y = Application.GetRealHeight(368);
            frameNumberIcon.Width = this.Width;
            frameNumberIcon.Gravity = Gravity.CenterHorizontal;
            frameNumberIcon.Height = this.GetPictrueRealSize(NumberSize * 4 + NumberTopButtomSpace * 3);
            this.AddChidren(frameNumberIcon);
            //前一个控件的右坐标
            int btnTempRight = 0;
            //间距
            int space = Application.GetMinRealAverage(NumberLeftRightSpace);
            int space = this.GetPictrueRealSize(NumberLeftRightSpace);
            //1到9的数字盘
            for (int i = 1; i <= 9; i++)
            {
@@ -199,8 +211,8 @@
                    btnNum.X = btnTempRight + space;
                }
                frameBack.AddChidren(btnNum);
                btnNum.Y = (i - 1) / 3 * (btnNum.Height + Application.GetMinRealAverage(NumberTopButtomSpace));
                frameNumberIcon.AddChidren(btnNum);
                btnNum.Y = (i - 1) / 3 * (btnNum.Height + this.GetPictrueRealSize(NumberTopButtomSpace));
                btnNum.ButtonClickEvent += (sender, e) =>
                {
                    //点击数字按键
@@ -216,11 +228,11 @@
            //0的数字盘
            var btnNum0 = this.InitNumberControl();
            btnNum0.X = Application.GetMinRealAverage(40) + frameBack.GetChildren(0).Height + space;
            btnNum0.X = this.GetPictrueRealSize(40) + frameNumberIcon.GetChildren(0).Height + space;
            btnNum0.Text = "0";
            frameBack.AddChidren(btnNum0);
            btnNum0.Y = 3 * (frameBack.GetChildren(0).Height + Application.GetMinRealAverage(NumberTopButtomSpace));
            frameNumberIcon.AddChidren(btnNum0);
            btnNum0.Y = 3 * (frameNumberIcon.GetChildren(0).Height + this.GetPictrueRealSize(NumberTopButtomSpace));
            btnNum0.ButtonClickEvent += (sender, e) =>
            {
                //点击数字按键
@@ -234,10 +246,10 @@
        /// <returns></returns>
        private NormalClickButton InitNumberControl()
        {
            int iconSize = Application.GetMinRealAverage(NumberSize);
            int iconSize = this.GetPictrueRealSize(NumberSize);
            var btnNum = new NormalClickButton(iconSize, iconSize, false);
            btnNum.X = Application.GetMinRealAverage(40);
            btnNum.BackgroundColor = 0xfff5f6fa;
            btnNum.X = this.GetPictrueRealSize(40);
            btnNum.BackgroundColor = this.NumberIconBackColor;
            btnNum.clickStatuColor = 0x7e656565;
            btnNum.Radius = (uint)iconSize / 2;
            btnNum.TextColor = UserCenterColor.Current.TextGrayColor3;
@@ -256,14 +268,13 @@
            {
                return;
            }
            if (btnError.Visible == true)
            {
                btnError.Visible = false;
            }
            //特效改变
            listPswIcon[inputPassword.Length].BackgroundColor = 0xff333333;
            inputPassword += strNum;
            if (inputPassword.Length == 1)
            {
                //将文字从取消变更为删除
                btnDelete.TextID = R.MyInternationalizationString.uDelete;
            }
            //输入结束
            if (FinishInputEvent != null && inputPassword.Length == passwordLength)
            {
@@ -310,6 +321,14 @@
                btnError.Visible = true;
            }
            btnError.Text = i_msg;
            //记录的密码
            inputPassword = string.Empty;
            //密码图标
            for (int i = 0; i < listPswIcon.Count; i++)
            {
                listPswIcon[i].BackgroundColor = UserCenterColor.Current.Transparent;
            }
        }
        #endregion
@@ -317,7 +336,7 @@
        #region ■ 变更删除按钮位置___________________
        /// <summary>
        /// 变更删除按钮位置(父控件的高度会自动调整)
        /// 变更删除按钮位置,它最初的默认位置是在最底部(父控件的高度会自动调整)
        /// </summary>
        /// <param name="XX">X轴(不变更请设置为-1)</param>
        /// <param name="YY">Y轴(不变更请设置为-1)</param>
@@ -345,7 +364,7 @@
            }
            //自动调整高度
            int minHeight = Application.GetMinRealAverage(NumberSize * 4 + NumberTopButtomSpace * 3) + Application.GetRealHeight(368);
            int minHeight = this.GetPictrueRealSize(NumberSize * 4 + NumberTopButtomSpace * 3) + Application.GetRealHeight(368);
            int realHeight = this.btnDelete.Bottom;
            if (realHeight < minHeight)
            {