New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | { |
| | | /// <summary> |
| | | /// <para>手势密码输入控件(自制的手势输入类型,请实现【FinishInputEvent】事件)</para> |
| | | /// <para>标题控件的Y轴为0,也就是这个控件的上部没有空白区域</para> |
| | | /// </summary> |
| | | public class PswGestureInputControl : FrameLayout |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 密码输入完成的事件 value1:密码 value2:密码长度 |
| | | /// </summary> |
| | | public Action<string, int> FinishInputEvent = null; |
| | | /// <summary> |
| | | /// 标题控件 |
| | | /// </summary> |
| | | public NormalViewControl btnTitle = null; |
| | | /// <summary> |
| | | /// 错误信息提示控件 |
| | | /// </summary> |
| | | public NormalViewControl btnError = null; |
| | | /// <summary> |
| | | /// 手势控件(有可能需要调整它的未知) |
| | | /// </summary> |
| | | public GestureLockView gestureControl = null; |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// <para>手势密码输入控件(自制的手势输入类型,请实现【FinishInputEvent】事件)</para> |
| | | /// <para>标题控件的Y轴为0,也就是这个控件的上部没有空白区域</para> |
| | | /// </summary> |
| | | /// <param name="i_title">初始标题文本信息</param> |
| | | public PswGestureInputControl(string i_title) |
| | | { |
| | | //加间距 |
| | | this.Width = Application.GetRealWidth(965); |
| | | this.Height = Application.GetRealHeight(1290); |
| | | |
| | | this.btnTitle = new NormalViewControl(Application.CurrentWidth, Application.GetRealWidth(75), false); |
| | | btnTitle.Width = this.Width; |
| | | btnTitle.TextAlignment = TextAlignment.Center; |
| | | btnTitle.TextSize = 18; |
| | | btnTitle.Text = i_title; |
| | | btnTitle.IsBold = true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化控件 |
| | | /// </summary> |
| | | public void InitControl() |
| | | { |
| | | //标题 |
| | | this.AddChidren(btnTitle); |
| | | |
| | | //错误信息提示 |
| | | this.btnError = new NormalViewControl(this.Width, Application.GetRealHeight(60), false); |
| | | btnError.Y = btnTitle.Bottom + Application.GetRealHeight(98); |
| | | btnError.TextAlignment = TextAlignment.Center; |
| | | btnError.TextColor = 0xfff75858; |
| | | this.AddChidren(btnError); |
| | | |
| | | this.gestureControl = new GestureLockView(); |
| | | gestureControl.Gravity = Gravity.CenterHorizontal; |
| | | gestureControl.Y = btnError.Bottom + Application.GetRealHeight(104); |
| | | gestureControl.Width = Application.GetRealWidth(786); |
| | | gestureControl.Height = Application.GetRealWidth(786); |
| | | //默认和正确 时显示的颜色 |
| | | //gestureControl.LockViewCorrectColor = 0xfffc744b; |
| | | //错误时 显示的颜色 |
| | | //gestureControl.LockViewErrorColor = 0xfffc744b; |
| | | this.AddChidren(gestureControl); |
| | | |
| | | //滑动结束 回调密码结果和密码长度 |
| | | gestureControl.OnLockVerifyEvent += (selectNumStr, selectCount) => |
| | | { |
| | | btnError.Text = string.Empty; |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | this.FinishInputEvent?.Invoke(selectNumStr, selectCount); |
| | | }); |
| | | }); |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 重置控件___________________________ |
| | | |
| | | /// <summary> |
| | | /// 重置控件 |
| | | /// </summary> |
| | | /// <param name="i_title">标题信息</param> |
| | | /// <param name="clearError">是否清除错误信息</param> |
| | | public void ResetControlInfo(string i_title, bool clearError = true) |
| | | { |
| | | //标题 |
| | | btnTitle.Text = i_title; |
| | | if (clearError == true) |
| | | { |
| | | //错误信息 |
| | | btnError.Text = string.Empty; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 错误信息设置_______________________ |
| | | |
| | | /// <summary> |
| | | /// 显示错误的信息 |
| | | /// </summary> |
| | | /// <param name="i_msg"></param> |
| | | public void SetErrorMsg(string i_msg) |
| | | { |
| | | //自行验证密码,提示正确或者错误 false为显示红色错误, 自行选择调用时机 |
| | | gestureControl.showCorrectStatus(false); |
| | | btnError.Text = i_msg; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 添加关闭按钮_______________________ |
| | | |
| | | /// <summary> |
| | | /// 添加关闭按钮 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public IconViewControl AddCloseButton() |
| | | { |
| | | //关闭按钮 |
| | | var btnClose = new IconViewControl(86); |
| | | btnClose.X = this.Width - btnClose.IconSize - Application.GetRealHeight(46); |
| | | btnClose.UnSelectedImagePath = "Item/CancelIcon.png"; |
| | | this.AddChidren(btnClose); |
| | | |
| | | return btnClose; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 控件摧毁___________________________ |
| | | |
| | | /// <summary> |
| | | /// 控件摧毁 |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | FinishInputEvent = null; |
| | | base.RemoveFromParent(); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |