using HDL_ON.UI.CSS;
using Shared;
using System;
using System.Collections.Generic;
using System.Text;
namespace HDL_ON.Stan
{
///
/// App手势验证界面
///
public class AppGestureSecurityForm : EditorCommonForm
{
#region ■ 变量声明___________________________
///
/// Action事件
/// 1:密码输入结束,这个时候,第二个参数为输入的密码
/// 2:点击了底部的消息
///
public Action ActionEvent = null;
///
/// 手势控件
///
private GestureLockView gestureLockView = null;
///
/// 消息控件
///
private NormalViewControl btnMsg = null;
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
/// 是否添加头部Frame
/// 标题信息
/// 底部显示的信息行
public void ShowForm(bool addTopFrame, string i_title, string i_bottomMsg)
{
//不允许左滑
this.ScrollLeftEnabled = false;
if (addTopFrame == false)
{
//清空头部全部控件
topFrameLayout.RemoveAll();
//然后让背景色一体化
topFrameLayout.BackgroundColor = bodyFrameLayout.BackgroundColor;
topMenuFrameLayout.BackgroundColor = bodyFrameLayout.BackgroundColor;
}
else
{
//验证手势密码
base.SetTitleText(Language.StringByID(StringId.VerifyGesturePassword));
}
//初始化中部信息
this.InitMiddleFrame(i_title, i_bottomMsg);
}
///
/// 初始化中部信息
///
/// 标题信息
/// 底部显示的信息行
private void InitMiddleFrame(string i_title, string i_bottomMsg)
{
//清空bodyFrame
this.ClearBodyFrame();
//标题
var btnTitle = new NormalViewControl(bodyFrameLayout.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(36), false);
btnTitle.Y = Application.GetRealHeight(164) - topFrameLayout.Bottom;
btnTitle.Gravity = Gravity.CenterHorizontal;
btnTitle.TextAlignment = TextAlignment.Center;
btnTitle.IsBold = true;
btnTitle.TextColor = CSS_Color.FirstLevelTitleColor;
btnTitle.TextSize = CSS_FontSize.EmphasisFontSize_Secondary;
btnTitle.Text = i_title;
bodyFrameLayout.AddChidren(btnTitle);
//请绘制图案
this.btnMsg = new NormalViewControl(bodyFrameLayout.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(72), false);
btnMsg.Y = btnTitle.Bottom;
btnMsg.Gravity = Gravity.CenterHorizontal;
btnMsg.TextAlignment = TextAlignment.TopCenter;
btnMsg.IsBold = true;
btnMsg.IsMoreLines = true;
btnMsg.SelectedTextColor = CSS_Color.WarningColor;
btnMsg.TextID = StringId.PleaseDrawPattern;
bodyFrameLayout.AddChidren(btnMsg);
//原始它与btnDrawMsg的间隔是14
this.gestureLockView = new GestureLockView();
gestureLockView.Y = btnMsg.Bottom;
gestureLockView.Gravity = Gravity.CenterHorizontal;
gestureLockView.Width = Application.GetRealWidth(215);
gestureLockView.Height = Application.GetRealWidth(215);
gestureLockView.LockViewCorrectColor = CSS_Color.MainColor;//0xFF00FF00,//默认和正确 时显示的颜色
gestureLockView.LockViewErrorColor = 0xFFFF0000; //错误时 显示的颜色
gestureLockView.BackgroundColor = CSS_Color.BackgroundColor;
bodyFrameLayout.AddChidren(gestureLockView);
gestureLockView.SetSolidType(true);
//滑动结束 回调密码结果和密码长度
gestureLockView.OnLockVerifyEvent += (selectNumStr, selectCount) =>
{
//自行验证密码,提示正确或者错误 false为显示红色错误, 自行选择调用时机
this.gestureLockView.showCorrectStatus(false);
if (selectCount < 4)
{
//至少连接4个点,请重新绘制
btnMsg.Text = Language.StringByID(StringId.DrawingLengthError);
btnMsg.TextColor = CSS_Color.WarningColor;
return;
}
this.ActionEvent?.Invoke(1, selectNumStr);
};
//底部消息
if (string.IsNullOrEmpty(i_bottomMsg) == false)
{
var btnBottomTip = new NormalViewControl(bodyFrameLayout.Width - HdlControlResourse.XXLeft * 2, 20, false);
btnBottomTip.Y = Application.GetRealHeight(517) - topFrameLayout.Bottom;
btnBottomTip.Gravity = Gravity.CenterHorizontal;
btnBottomTip.TextAlignment = TextAlignment.TopCenter;
btnBottomTip.TextColor = CSS_Color.MainColor;
btnBottomTip.Text = i_bottomMsg;
btnBottomTip.Height = btnBottomTip.GetRealRowCountByText() * Application.GetRealHeight(24);
btnBottomTip.IsMoreLines = true;
bodyFrameLayout.AddChidren(btnBottomTip);
btnBottomTip.ButtonClickEvent += (sender, e) =>
{
this.ActionEvent?.Invoke(2, null);
};
}
}
#endregion
#region ■ 界面关闭___________________________
///
/// 界面关闭
///
public override void CloseFormBefore()
{
base.CloseFormBefore();
this.ActionEvent = null;
}
#endregion
#region ■ 一般方法___________________________
///
/// 显示错误消息
///
/// 需要显示的错误消息
public void ShowErrorMsg(string i_errorMsg)
{
btnMsg.Text = i_errorMsg;
btnMsg.TextColor = CSS_Color.WarningColor;
}
#endregion
}
}