using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 手势密码输入控件(自制的手势输入类型,请实现【FinishInputEvent】事件) /// 标题控件的Y轴为0,也就是这个控件的上部没有空白区域 /// public class PswGestureInputControl : FrameLayout { #region ■ 变量声明___________________________ /// /// 密码输入完成的事件 value1:密码 value2:密码长度 /// public Action FinishInputEvent = null; /// /// 标题控件 /// public NormalViewControl btnTitle = null; /// /// 错误信息提示控件 /// public NormalViewControl btnError = null; /// /// 手势控件(有可能需要调整它的未知) /// public GestureLockView gestureControl = null; #endregion #region ■ 初始化_____________________________ /// /// 手势密码输入控件(自制的手势输入类型,请实现【FinishInputEvent】事件) /// 标题控件的Y轴为0,也就是这个控件的上部没有空白区域 /// /// 初始标题文本信息 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; } /// /// 初始化控件 /// 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 ■ 重置控件___________________________ /// /// 重置控件 /// /// 标题信息 /// 是否清除错误信息 public void ResetControlInfo(string i_title, bool clearError = true) { //标题 btnTitle.Text = i_title; if (clearError == true) { //错误信息 btnError.Text = string.Empty; } } #endregion #region ■ 错误信息设置_______________________ /// /// 显示错误的信息 /// /// public void SetErrorMsg(string i_msg) { //自行验证密码,提示正确或者错误 false为显示红色错误, 自行选择调用时机 gestureControl.showCorrectStatus(false); btnError.Text = i_msg; } #endregion #region ■ 添加关闭按钮_______________________ /// /// 添加关闭按钮 /// /// 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 ■ 控件摧毁___________________________ /// /// 控件摧毁 /// public override void RemoveFromParent() { FinishInputEvent = null; base.RemoveFromParent(); } #endregion } }