黄学彪
2019-10-12 c6b35c3138b944830b5336bf610f918154dd47c7
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
using System;
using Shared.Common;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DoorLock
{
    public class TemporaryPassword : DoorLockCommonLayout, ZigBee.Common.IStatus
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="doorLock"></param>
        public TemporaryPassword(ZigBee.Device.DoorLock doorLock)
        {
            this.doorLock = doorLock;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
        }
 
        #region ◆ 变量申明__________________________
        ZigBee.Device.DoorLock doorLock;
        public System.Collections.Generic.List<Button> pawButtonList = new System.Collections.Generic.List<Button> { };//临时密码中的6位数字
        Button passwordText; //临时密码
        #endregion
 
        /// <summary>
        /// UI显示 
        /// </summary>
        public void Show()
        {
            this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.TemporaryPassword));
 
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
                RemoveFromParent();
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
 
            MidFrameLayoutContent();
 
        }
 
        /// <summary>
        /// 读门锁临时密码信息
        /// </summary>
        /// <param name="door_lock">Door lock.</param>
        void readStatus()
        {
            System.Threading.Tasks.Task.Run(() =>
            {
 
            });
        }
 
        public void MidFrameLayoutContent()
        {
            var MidTopFrameLayout = new FrameLayout()
            {
                X = Application.GetRealWidth(196),
                Y = Application.GetRealHeight(276),
                Width = Application.GetRealWidth(668),
                Height = Application.GetRealHeight(527),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            this.midFrameLayout.AddChidren(MidTopFrameLayout);
 
            var topPic = new Button()
            {
                Height = Application.GetRealHeight(184),
                Width = Application.GetRealWidth(184),
                X = Application.GetRealWidth(449),
                Y = Application.GetRealHeight(58),
                TextAlignment = TextAlignment.Center,
                Text = Language.StringByID(R.MyInternationalizationString.RandomPasword),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray1,
            };
            this.midFrameLayout.AddChidren(topPic);
 
            var randomPassword = new EditText()
            {
                Y = Application.GetRealHeight(153),
                Height = Application.GetRealHeight(84),
                TextAlignment = TextAlignment.Center,
                TextColor = Shared.Common.ZigbeeColor.Current.XMOrange,
                TextSize = 24,
                Text = GetTempPassword(),
            };
            MidTopFrameLayout.AddChidren(randomPassword);
 
            var validTime = new Button()
            {
                Height = Application.GetRealHeight(55),
                Width = Application.GetRealWidth(115),
                X = Application.GetRealWidth(78),
                Y = Application.GetRealHeight(386),
                Text = "12:00",
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
            };
            MidTopFrameLayout.AddChidren(validTime);
 
            var validTimeDate = new Button()
            {
                Height = Application.GetRealHeight(49),
                Width = Application.GetRealWidth(135),
                X = Application.GetRealWidth(69),
                Y = Application.GetRealHeight(441),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
                Text = "8" + Language.StringByID(R.MyInternationalizationString.Month) + "1" + Language.StringByID(R.MyInternationalizationString.Day),
            };
            MidTopFrameLayout.AddChidren(validTimeDate);
 
            var inValidTime = new Button()
            {
                Height = Application.GetRealHeight(55),
                Width = Application.GetRealWidth(115),
                X = Application.GetRealWidth(492),
                Y = Application.GetRealHeight(386),
                Text = "10:00",
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
            };
            MidTopFrameLayout.AddChidren(inValidTime);
 
            var inValidTimeDate = new Button()
            {
                Height = Application.GetRealHeight(49),
                Width = Application.GetRealWidth(135),
                X = Application.GetRealWidth(484),
                Y = Application.GetRealHeight(441),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "8" + Language.StringByID(R.MyInternationalizationString.Month) + "2" + Language.StringByID(R.MyInternationalizationString.Day),
            };
            MidTopFrameLayout.AddChidren(inValidTimeDate);
 
            //var inputCountText = new EditText()
            //{
            //    Width = Application.GetRealWidth(780),
            //    Height = Application.GetRealHeight(100),
            //    X = Application.GetRealWidth(80),
            //    Y = validCountText.Bottom + Application.GetRealHeight(10),
            //    PlaceholderText = doorLock.tempPasswordObj.times.ToString(),
            //    PlaceholderTextColor = 0xffc1c1c1,
            //    TextAlignment = TextAlignment.Center,
            //    //UnSelectedImagePah = "Register/Register_Kuang.png",
            //    BackgroundColor = 0xff00ff00,
            //};
            //this.midFrameLayout.AddChidren(inputCountText);
 
            //var unitCount = new Button()
            //{
            //    Height = Application.GetRealHeight(50),
            //    Width = Application.GetRealWidth(100),
            //    X = inputCountText.Right + Application.GetRealWidth(2),
            //    Y = Application.GetRealHeight(490),
            //    Text = Language.StringByID(R.MyInternationalizationString.Ci),
            //    TextAlignment = TextAlignment.CenterLeft,
            //    TextSize = 12,
            //    TextColor = 0xff000000,
            //};
            //this.midFrameLayout.AddChidren(unitCount);
 
            //var remindPic2 = new Button()
            //{
            //    Height = Application.GetRealHeight(40),
            //    Width = Application.GetRealWidth(40),
            //    X = Application.GetRealWidth(80),
            //    Y = inputCountText.Bottom + Application.GetRealHeight(18),
            //    //UnSelectedImagePath = "DoorLockPic/door_lock_alert.png",
            //    BackgroundColor = 0xff0000ff,
            //};
            //this.midFrameLayout.AddChidren(remindPic2);
 
            //var maxValidCount = new Button()
            //{
            //    Width = Application.GetRealWidth(550),
            //    Height = Application.GetRealHeight(80),
            //    X = remindPic2.Right + Application.GetRealWidth(8),
            //    Y = inputCountText.Bottom,
            //    Text = Language.StringByID(R.MyInternationalizationString.MaxValicCount),
            //    TextAlignment = TextAlignment.CenterLeft,
            //    TextSize = 10,
            //    TextColor = 0xff000000,
            //};
            //this.midFrameLayout.AddChidren(maxValidCount);
 
            //var remindFrameLayout = new FrameLayout()
            //{
            //    Height = Application.GetRealHeight(350),
            //    Y = remindPic2.Bottom + Application.GetRealHeight(90),
            //    BackgroundColor = 0xff00ffff,
            //};
            //this.midFrameLayout.AddChidren(remindFrameLayout);
 
            //var TempPasswordText = new Button()
            //{
            //    X = Application.GetRealWidth(80),
            //    Y = Application.GetRealHeight(10),
            //    Width = Application.GetRealWidth(300),
            //    Height = Application.GetRealHeight(80),
            //    TextAlignment = TextAlignment.CenterLeft,
            //    Text = Language.StringByID(R.MyInternationalizationString.DynamicTempPassword),
            //    TextColor = 0xffff0000,
            //};
            //remindFrameLayout.AddChidren(TempPasswordText);
 
            //for (int i = 0; i < 6; i++)
            //{
            //    passwordText = new Button()
            //    {
            //        Height = Application.GetRealHeight(150),
            //        Width = Application.GetRealWidth(80),
            //        TextAlignment = TextAlignment.Center,
            //        Y = TempPasswordText.Bottom + Application.GetRealHeight(10),
            //        TextSize = 28,
            //        BackgroundColor = 0xff0000ff,
            //    };
            //    remindFrameLayout.AddChidren(passwordText);
            //    if (i == 0)
            //    {
            //        passwordText.X = Application.GetRealWidth(90);
            //    }
            //    else
            //    {
            //        passwordText.X = (i + 1) * Application.GetRealWidth(90) + (i + 1) * Application.GetRealWidth(10);
            //    }
            //    if (i == 1 || i == 3 || i == 5)
            //    {
            //        passwordText.BackgroundColor = 0xff00ff00;
            //    }
            //    pawButtonList.Add(passwordText);
            //}
 
            BottomFrameLayoutContent();
        }
 
        public void BottomFrameLayoutContent()
        {
            var bottomFrameLayout = new FrameLayout()
            {
                Height = Application.GetRealHeight(1025),
                Y = Application.GetRealHeight(896),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout);
 
            var informationEdit = new Button()
            {
                Height = Application.GetRealHeight(60),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(81),
                Text = Language.StringByID(R.MyInternationalizationString.InformationEdit),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
            };
            bottomFrameLayout.AddChidren(informationEdit);
            for (int i = 0; i < 3; i++)
            {
                var btnValidTime = new Button()
                {
                    Width = Application.GetRealWidth(743),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(58),
                    Text = Language.StringByID(R.MyInternationalizationString.ValidTime),
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextSize = 12,
                };
                bottomFrameLayout.AddChidren(btnValidTime);
 
                var btnNext = new Button()
                {
                    Width = Application.GetRealWidth(58),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(956),
                    Y = Application.GetRealHeight(204),
                    BackgroundColor = ZigbeeColor.Current.XMOrange,
                };
                bottomFrameLayout.AddChidren(btnNext);
 
                var btnLine = new FrameLayout()
                {
                    Width = Application.GetRealWidth(965),
                    Height = Application.GetRealHeight(5),
                    X = Application.GetRealWidth(58),
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                };
                bottomFrameLayout.AddChidren(btnLine);
 
                if (i == 0)
                {
                    btnValidTime.Y = Application.GetRealHeight(204);
                    btnValidTime.Text = Language.StringByID(R.MyInternationalizationString.ValidTime);
                    btnNext.Y = btnValidTime.Y;
                    btnLine.Y = Application.GetRealHeight(308);
                    btnNext.MouseDownEventHandler += (sender, e) =>
                      {
                          var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "ValidTime");
                          Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
                          Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                          tempPage.Show();
                      };
                }
                else if (i == 1)
                {
                    btnValidTime.Y = Application.GetRealHeight(343);
                    btnValidTime.Text = Language.StringByID(R.MyInternationalizationString.InValidTime);
                    btnNext.Y = btnValidTime.Y;
                    btnLine.Y = Application.GetRealHeight(446);
                    btnNext.MouseDownEventHandler += (sender, e) =>
                    {
                        var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "InValidTime");
                        Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
                        Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                        tempPage.Show();
                    };
                }
                else if (i == 2)
                {
                    btnValidTime.Y = Application.GetRealHeight(481);
                    btnValidTime.Text = Language.StringByID(R.MyInternationalizationString.ClearTempPassword);
                    btnNext.Y = btnValidTime.Y;
                    btnLine.Y = Application.GetRealHeight(1025 - 449);
                }
            }
 
 
            //var bottomLine = new Button()
            //{
            //    Height = Application.GetRealHeight(1),
            //    BackgroundColor = 0xff000000,
            //};
            //bottomFrameLayout.AddChidren(bottomLine);
 
            //var generateTempPassword = new Button()
            //{
            //    Y = bottomLine.Bottom,
            //    Height = Application.GetRealHeight(180),
            //    TextID = R.MyInternationalizationString.GenerateTemporaryPassword,
            //    TextSize = 15,
            //    BackgroundColor = 0xFF121212,
            //    SelectedBackgroundColor = 0xFFFC5806,
            //};
            //bottomFrameLayout.AddChidren(generateTempPassword);
            //string tempPaw = "";
            //generateTempPassword.MouseUpEventHandler += (sender, e) =>
            //{
            //    tempPaw = GetTempPassword();
            //    for (int i = 0; i < tempPaw.Length; i++)
            //    {
            //        for (int j = 0; j < pawButtonList.Count; j++)
            //        {
            //            if (i == j)
            //            {
            //                pawButtonList[j].Text = tempPaw[i].ToString();
            //            }
            //        }
            //    }
            //};
        }
 
        /// <summary>
        /// 生成6位临时密码
        /// </summary>
        /// <returns></returns>
        public string GetTempPassword()
        {
            string password = "";
            password = new Random().Next(100000, 999999).ToString();
            return password;
        }
 
        #region ◆ 接口实现__________________________
        /// <summary>
        /// 处理变化事件 --将弃用 改用DeviceInfoChange()
        /// </summary>
        /// <returns>The changed.</returns>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        {
 
        }
        /// <summary>
        /// 处理变化事件
        /// </summary>
        /// <param name="common"></param>
        /// <param name="typeTag"></param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
        }
        /// <summary>
        /// Changeds the IL ogic status.
        /// </summary>
        /// <param name="logic">Logic.</param>
        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
        {
        }
        /// <summary>
        /// Changeds the IS cene status.
        /// </summary>
        /// <param name="scene">Scene.</param>
        public void ChangedISceneStatus(Scene scene)
        {
        }
        #endregion
    }
}