using System;
|
namespace Shared.Phone.UserCenter
|
{
|
/// <summary>
|
/// 密码错误信息提示控件
|
/// </summary>
|
public class PswErrorRowLayout : RowLayout
|
{
|
/// <summary>
|
/// 现阶段是否错误
|
/// </summary>
|
public bool IsError = true;
|
/// <summary>
|
/// 密码长度不低于8位数
|
/// </summary>
|
private Button btnLength = null;
|
/// <summary>
|
/// 至少有一个大写字母
|
/// </summary>
|
private Button btnUpper = null;
|
/// <summary>
|
/// 至少有一个小写字母
|
/// </summary>
|
private Button btnLower = null;
|
/// <summary>
|
/// 至少有一个数字或符号
|
/// </summary>
|
private Button btnNumber = null;
|
/// <summary>
|
/// 其它
|
/// </summary>
|
private Button btnOther = null;
|
/// <summary>
|
/// 正确的图标
|
/// </summary>
|
private string rightIcon = "√ ";
|
/// <summary>
|
/// 错误的图标
|
/// </summary>
|
private string wrongIcon = "× ";
|
/// <summary>
|
/// 密码长度不低于8位数
|
/// </summary>
|
private string LengthMsg = Language.StringByID(R.MyInternationalizationString.PswLengthMsg);
|
/// <summary>
|
/// 至少有一个大写字母
|
/// </summary>
|
private string UpperMsg = Language.StringByID(R.MyInternationalizationString.PswLowerMsg);
|
/// <summary>
|
/// 至少有一个小写字母
|
/// </summary>
|
private string LowerMsg = Language.StringByID(R.MyInternationalizationString.PswLowerMsg);
|
/// <summary>
|
/// 至少有一个数字或符号
|
/// </summary>
|
private string NumberMsg = Language.StringByID(R.MyInternationalizationString.PswNumberMsg);
|
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
/// <param name="width">Width.</param>
|
/// <param name="height">Height.</param>
|
public void Init(int width = 300, int height = 35)
|
{
|
//X轴偏移量
|
//int XX = UserCenterResourse.XXLeft;
|
|
//btnLength = UserCenterControls.MakeViewButton(width, height, true);
|
//btnLength.X = XX;
|
//btnLength.Y = Application.GetRealHeight(6);
|
//btnLength.TextAlignment = TextAlignment.CenterLeft;
|
//btnLength.TextColor = UserCenterColor.Current.Red;
|
//btnLength.Text = wrongIcon + LengthMsg;
|
//this.AddChidren(btnLength);
|
|
//btnUpper = UserCenterControls.MakeViewButton(width, height, true);
|
//btnUpper.X = XX;
|
//btnUpper.Y = btnLength.Bottom + Application.GetRealHeight(6);
|
//btnUpper.TextAlignment = TextAlignment.CenterLeft;
|
//btnUpper.TextColor = UserCenterColor.Current.Red;
|
//btnUpper.Text = wrongIcon + UpperMsg;
|
//this.AddChidren(btnUpper);
|
|
//btnLower = UserCenterControls.MakeViewButton(width, height, true);
|
//btnLower.X = XX;
|
//btnLower.Y = btnUpper.Bottom + Application.GetRealHeight(6);
|
//btnLower.TextAlignment = TextAlignment.CenterLeft;
|
//btnLower.TextColor = UserCenterColor.Current.Red;
|
//btnLower.Text = wrongIcon + LowerMsg;
|
//this.AddChidren(btnLower);
|
|
//btnNumber = UserCenterControls.MakeViewButton(width, height, true);
|
//btnNumber.X = XX;
|
//btnNumber.Y = btnLower.Bottom + Application.GetRealHeight(6);
|
//btnNumber.TextAlignment = TextAlignment.CenterLeft;
|
//btnNumber.TextColor = UserCenterColor.Current.Red;
|
//btnNumber.Text = wrongIcon + NumberMsg;
|
//this.AddChidren(btnNumber);
|
|
//btnOther = UserCenterControls.MakeViewButton(width, height, true);
|
//btnOther.X = XX;
|
//btnOther.Y = btnNumber.Bottom + Application.GetRealHeight(6);
|
//btnOther.TextAlignment = TextAlignment.CenterLeft;
|
//btnOther.TextColor = UserCenterColor.Current.Red;
|
//this.AddChidren(btnOther);
|
}
|
|
/// <summary>
|
/// 密码检测
|
/// </summary>
|
/// <returns><c>true</c>, if password was checked, <c>false</c> otherwise.</returns>
|
/// <param name="password">Password.</param>
|
public bool CheckPassword(string password)
|
{
|
btnOther.Visible = false;
|
|
//判断密码长度
|
bool flag1 = password.Length >= 8;
|
if (flag1)
|
{
|
btnLength.TextColor = UserCenterColor.Current.Green;
|
btnLength.Text = rightIcon + LengthMsg;
|
}
|
else
|
{
|
btnLength.TextColor = UserCenterColor.Current.Red;
|
btnLength.Text = wrongIcon + LengthMsg;
|
}
|
|
//判断是否包含大写字母
|
bool flag2 = UserCenterLogic.CheckContainUpper(password);
|
if (flag2 == true)
|
{
|
btnUpper.TextColor = UserCenterColor.Current.Green;
|
btnUpper.Text = rightIcon + UpperMsg;
|
}
|
else
|
{
|
btnUpper.TextColor = UserCenterColor.Current.Red;
|
btnUpper.Text = wrongIcon + UpperMsg;
|
}
|
|
//判断是否包含小写字母
|
bool flag3 = UserCenterLogic.CheckContainLower(password);
|
if (flag3 == true)
|
{
|
btnLower.TextColor = UserCenterColor.Current.Green;
|
btnLower.Text = rightIcon + LowerMsg;
|
}
|
else
|
{
|
btnLower.TextColor = UserCenterColor.Current.Red;
|
btnLower.Text = wrongIcon + LowerMsg;
|
}
|
|
//判断是否包含数字或者符号
|
bool flag4 = UserCenterLogic.CheckContainNum(password);
|
bool flag5 = UserCenterLogic.CheckContainSymbol(password);
|
if (flag4 == true && flag5 == true)
|
{
|
btnNumber.TextColor = UserCenterColor.Current.Green;
|
btnNumber.Text = rightIcon + NumberMsg;
|
}
|
else
|
{
|
btnNumber.TextColor = UserCenterColor.Current.Red;
|
btnNumber.Text = wrongIcon + NumberMsg;
|
}
|
IsError = flag1 && flag2 && flag3 && flag4 && flag5;
|
|
return IsError;
|
}
|
|
/// <summary>
|
/// 在最后一行显示其它错误信息
|
/// </summary>
|
/// <param name="error">Error.</param>
|
public void ShowOtherError(string error)
|
{
|
IsError = true;
|
btnOther.Text = wrongIcon + error;
|
btnOther.Visible = true;
|
}
|
}
|
}
|