JLChen
2020-05-28 04bd96cbf5d12a4e4b116d2b05fd0d05ea81ee23
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
using System;
using System.Text.RegularExpressions;
 
namespace Shared.SimpleControl.Phone
{
    public class RemoteUnlockPasswordSet : FrameLayout
    {
 
        DoorLock doorLock;
        public RemoteUnlockPasswordSet (DoorLock dl)
        {
            this.doorLock = dl;
            BackgroundColor = SkinStyle.Current.MainColor;
        }
 
        public void ShowDoorLockRemoteSetPassword ()
        {
            #region 标题
            FrameLayout topView = new FrameLayout () {
                Y = Application.GetRealHeight (36),
                Height = Application.GetRealHeight (90),
                BackgroundColor = SkinStyle.Current.MainColor,
            };
            AddChidren (topView);
 
            Button title = new Button () {
                TextAlignment = TextAlignment.Center,
                TextID = R.MyInternationalizationString.ResetPassword,
                TextSize = 19,
                TextColor = SkinStyle.Current.TextColor1,
            };
            topView.AddChidren (title);
 
            Button logo = new Button () {
                Width = Application.GetRealWidth (154),
                Height = Application.GetRealHeight (90),
                X = Application.GetRealWidth (486),
                UnSelectedImagePath = MainPage.LogoString,
                Gravity = Gravity.CenterVertical,
            };
            topView.AddChidren (logo);
            Button back = new Button () {
                Height = Application.GetRealHeight (90),
                Width = Application.GetRealWidth (85),
                UnSelectedImagePath = "Item/Back.png",
                SelectedImagePath = "Item/BackSelected.png",
                Gravity = Gravity.CenterVertical,
            };
            topView.AddChidren (back);
            back.MouseUpEventHandler += (sender, e) => {
                this.RemoveFromParent ();
            };
            #endregion
 
            var bodyView = new FrameLayout () {
                Y = topView.Bottom,
                Height = Application.GetRealHeight (Application.DesignHeight - 126),
                BackgroundColor = SkinStyle.Current.ViewColor,
            };
            AddChidren (bodyView);
 
            var btnpassword = new Button () {
                Width = Application.GetRealWidth (500),
                Height = Application.GetRealHeight (85),
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight (150),
                TextID = R.MyInternationalizationString.SetTheSixDigitPassword,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
                TextColor = SkinStyle.Current.TextColor1,
            };
            bodyView.AddChidren (btnpassword);
 
            var etPassword = new EditText () {
                Width = Application.GetRealWidth (500),
                Height = Application.GetRealHeight (85),
                Gravity = Gravity.CenterHorizontal,
                Y = btnpassword.Bottom,
                TextAlignment = TextAlignment.Center,
                Radius = (uint)Application.GetRealHeight (3),
                BorderColor = (uint)Application.GetMinRealAverage (3),
                UnSelectedImagePath = "Register/Register_Password_kuang.png",
                TextColor = SkinStyle.Current.TextColor1,
                SecureTextEntry = true,
            };
            bodyView.AddChidren (etPassword);
 
            var btnConfirmPassword = new Button () {
                Width = Application.GetRealWidth (500),
                Height = Application.GetRealHeight (85),
                Gravity = Gravity.CenterHorizontal,
                Y = etPassword.Bottom + Application.GetRealHeight (70),
                TextID = R.MyInternationalizationString.ConfirmPassword,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
                TextColor = SkinStyle.Current.TextColor1,
            };
            bodyView.AddChidren (btnConfirmPassword);
 
            var etConfirmPasswrod = new EditText () {
                Width = Application.GetRealWidth (500),
                Height = Application.GetRealHeight (85),
                Gravity = Gravity.CenterHorizontal,
                Y = btnConfirmPassword.Bottom,
                UnSelectedImagePath = "Register/Register_Password_kuang.png",
                TextAlignment = TextAlignment.Center,
                Radius = (uint)Application.GetRealHeight (0),
                TextColor = SkinStyle.Current.TextColor1,
                SecureTextEntry = true,
                //Text = "123456"
            };
            bodyView.AddChidren (etConfirmPasswrod);
 
            var btnOK = new Button () {
                Width = Application.GetRealWidth (247),
                Height = Application.GetRealHeight (89),
                X = Application.GetRealWidth ((640 - 247) / 2),
                Y = Application.GetRealHeight (700),
                BackgroundColor = SkinStyle.Current.ButtonColor,
                SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
                TextID = R.MyInternationalizationString.OK,
                Radius = 5,
                BorderColor = SkinStyle.Current.Transparent,
                TextColor = SkinStyle.Current.TextColor1,
                BorderWidth = 0,
                TextSize = 18,
            };
            bodyView.AddChidren (btnOK);
            btnOK.MouseDownEventHandler += (sender, e) => {
                btnOK.IsSelected = true;
            };
            btnOK.MouseUpEventHandler += (sender, e) => {
                btnOK.IsSelected = false;
            };
 
            btnOK.MouseUpEventHandler += (sender, e) => {
                if (etPassword.Text == "" && etConfirmPasswrod.Text == "") {
                    new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseWriteTheCompleteContent), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                    return;
                }
 
                if (etPassword.Text.Trim ().Length != 6) {
                    new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.PasswordNotFormedFromSixDigitalCodes), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
                    return;
                }
 
 
                if (etPassword.Text.Trim () != etConfirmPasswrod.Text.Trim ()) {
                    new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.RepeatPasswordsDidNotmatch),
                               Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                    return;
                }
 
                //string SuID = textButton.Text;
                //Regex reg = new Regex ("^[0-9]+$"); //判断是不是数据,要不是就表示没有选择,则从隐藏域里读出来
                //Match ma = reg.Match (SuID);
                //if (ma.Success) {
                //    //是数字时的操作
                //} else {
                //    return;
                //}
 
                doorLock.AddDoorLockPassword (etPassword.Text.Trim ());
 
                IO.FileUtils.SaveEquipmentMessage (doorLock);
                new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.SetSuccessfully), Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show ((View)sender);
                this.RemoveFromParent ();
 
                RemotelyUnlock unlockView = new RemotelyUnlock (doorLock);
                UserMiddle.DevicePageView.AddChidren (unlockView);
                unlockView.ShowUserRemoteUnLock ();
                UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
 
            };
 
        }
    }
}