wxr
2023-06-06 592974441a4df95fffd9167c90192da1a390b1c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
using HDL_ON.UI.CSS;
using Shared;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace HDL_ON.Stan
{
    /// <summary>
    /// App手势验证界面
    /// </summary>
    public class AppGestureSecurityForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// <para>Action事件</para>   
        /// <para>1:密码输入结束,这个时候,第二个参数为输入的密码</para>
        /// <para>2:点击了底部的消息</para>
        /// </summary>
        public Action<int, string> ActionEvent = null;
        /// <summary>
        /// 手势控件
        /// </summary>
        private GestureLockView gestureLockView = null;
        /// <summary>
        /// 消息控件
        /// </summary>
        private NormalViewControl btnMsg = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="addTopFrame">是否添加头部Frame</param>
        /// <param name="i_title">标题信息</param>
        /// <param name="i_bottomMsg">底部显示的信息行</param>
        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);
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        /// <param name="i_title">标题信息</param>
        /// <param name="i_bottomMsg">底部显示的信息行</param>
        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 ■ 界面关闭___________________________
 
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseFormBefore()
        {
            base.CloseFormBefore();
 
            this.ActionEvent = null;
 
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 显示错误消息
        /// </summary>
        /// <param name="i_errorMsg">需要显示的错误消息</param>
        public void ShowErrorMsg(string i_errorMsg)
        {
            btnMsg.Text = i_errorMsg;
            btnMsg.TextColor = CSS_Color.WarningColor;
        }
 
        #endregion
    }
}