wxr
2022-07-22 d9feb1d52963982a89a6e6d741a9b841042ce0b6
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
using System;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
    public class DoorLockUnlockPage : FrameLayout
    {
        /// <summary>
        /// 当前界面
        /// </summary>
        FrameLayout bodyView;
 
        Function device;
 
        public DoorLockUnlockPage(Function function)
        {
            bodyView = this;
            device = function;
        }
 
        /// <summary>
        /// 加载视图
        /// </summary>
        public void LoadView()
        {
 
            new TopViewDiv(bodyView, Language.StringByID(StringId.PlsEntryPassword)).LoadTopView();
            bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
 
 
            var btnMsg = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(100),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(100),
                TextAlignment = TextAlignment.TopCenter,
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.TextFontSize,
                TextID = StringId.DoorLockEntryPasswordTip,
                IsMoreLines = true,
            };
            bodyView.AddChidren(btnMsg);
 
            #region 密码填写
            var passwordView = new FrameLayout()
            {
                X = Application.GetRealWidth(28),
                Y = Application.GetRealHeight(200),
                Width = Application.GetRealWidth(319),
                Height = Application.GetRealHeight(44),
            };
            bodyView.AddChidren(passwordView);
 
 
            var etPassword = new EditText()
            {
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                PlaceholderTextColor = CSS_Color.PromptingColor1,
                PlaceholderText = Language.StringByID(StringId.PlsEntryPassword),
                SecureTextEntry = true,
                TextAlignment = TextAlignment.Center,
                BackgroundColor = CSS_Color.BackgroundColor,
                IsNumberKeyboardType = true
            };
            passwordView.AddChidren(etPassword);
 
            //var btnVisiblePassword = new Button()
            //{
            //    X = Application.GetRealWidth(273),
            //    Gravity = Gravity.CenterVertical,
            //    Width = Application.GetMinRealAverage(20),
            //    Height = Application.GetMinRealAverage(20),
            //    UnSelectedImagePath = "LoginIcon/HidePasswordIcon.png",
            //    SelectedImagePath = "LoginIcon/ShowPasswordIcon.png",
            //};
            //passwordView.AddChidren(btnVisiblePassword);
 
            #endregion
 
 
 
            var frameRow = new FrameLayout()
            {
                Height = Application.GetRealHeight(28),
                Y = Application.GetRealHeight(258),//375 // 667
            };
            bodyView.AddChidren(frameRow);
 
            //同意按钮背景
            var agreeView = new FrameLayout()
            {
                Height = Application.GetRealHeight(28),
                Width = Application.GetRealWidth(28),
                X = Application.GetRealWidth(22),
            };
            frameRow.AddChidren(agreeView);
   
            //同意图标按钮
            var agreeBtn = new Button()
            {
                Width = Application.GetMinRealAverage(28),
                Height = Application.GetMinRealAverage(28),
                UnSelectedImagePath = "Public/ChooseIcon.png",
                SelectedImagePath = "Public/ChooseOnIcon.png",
                IsSelected = false,
                Gravity = Gravity.Center,
            };
            agreeView.AddChidren(agreeBtn);
 
            var agreeTextBtn = new TextButton()
            {
                X = agreeView.Right,
                Width = Application.GetRealWidth(28),
                Height = Application.GetRealHeight(28),
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextID = StringId.DoorLock5minTip
            };
            frameRow.AddChidren(agreeTextBtn);
            agreeTextBtn.Width = Utlis.GetRealWidthByTextButton(agreeTextBtn);
 
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                agreeBtn.IsSelected = !agreeBtn.IsSelected;
            };
 
            agreeBtn.MouseUpEventHandler = eventHandler;
            agreeView.MouseUpEventHandler = eventHandler;
            agreeTextBtn.MouseUpEventHandler = eventHandler;
 
 
            Button btnLine = new Button()
            {
                Y = Application.GetRealHeight(607),
                Height = Application.GetRealHeight(1),
                BackgroundColor = CSS.CSS_Color.DividingLineColor,
            };
            bodyView.AddChidren(btnLine);
 
            Button btnCancel = new Button()
            {
                Y = btnLine.Bottom,
                Width = Application.GetRealWidth(374/2),
                Height = Application.GetRealHeight(60),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.Cancel,
            };
            bodyView.AddChidren(btnCancel);
            btnCancel.MouseUpEventHandler = (sender, e) => {
                this.RemoveFromParent();
            };
 
            Button btnConfirm = new Button()
            {
                X = btnCancel.Right,
                Y = btnLine.Y,
                Width = Application.GetRealWidth(376 / 2),
                Height = Application.GetRealHeight(60),
                TextAlignment = TextAlignment.Center,
                //TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.MainBackgroundColor,
                BackgroundColor = CSS_Color.MainColor,
                TextID = StringId.Confirm,
            };
            bodyView.AddChidren(btnConfirm);
            btnConfirm.MouseUpEventHandler = (sender, e) => {
                var password = etPassword.Text.Trim();
                if (password.Length == 0)
                {
                    //设备不在线
                    HdlMessageLogic.Current.ShowMassage(ShowMsgType.TipRemind, Language.StringByID(StringId.PlsEntryPassword), null, null, null, 2);
                    return;
                }
                if (agreeBtn.IsSelected)
                {
                    UserInfo.Current.doorPasswordString = password;
                    UserInfo.Current.LastTimeOpenDoor = DateTime.Now;
                }
                Control.Ins.OneKeyUnlocking(this.device, etPassword.Text.Trim());
                this.RemoveFromParent();
            };
 
        }
 
    }
}