黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Shared.Common;
using Shared.Phone.UserCenter.Device;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DoorLock
{
    public class EntryStatusPage : DoorLockCommonLayout
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="doorLock"></param>
        /// <param name="accountObj"></param>
        /// <param name="entryType"></param>
        public EntryStatusPage(ZigBee.Device.DoorLock doorLock, MemberInfoRes accountObj, string entryType)
        {
            this.doorLock = doorLock;
            this.curAccountObj = accountObj;
            this.currentType = entryType;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
        }
 
        #region 变量申明
        /// <summary>
        /// 当前门锁
        /// </summary>
        ZigBee.Device.DoorLock doorLock;
        /// <summary>
        /// 当前账户
        /// </summary>
        MemberInfoRes curAccountObj;
        /// <summary>
        /// 当前类型
        /// </summary>
        string currentType = string.Empty;
        /// <summary>
        /// 底部布局
        /// </summary>
        FrameLayout bottomFrameLayout;
        #endregion
 
        /// <summary>
        /// UI显示 
        /// </summary>
        public void Show()
        {
            this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.AddNewUnlockMethod));
 
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
                RemoveFromParent();
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
 
            MidFrameLayoutContent();
        }
        /// <summary>
        /// 中部布局
        /// </summary>
        public void MidFrameLayoutContent()
        {
            var entryStatusPic = new Button
            {
                X = Application.GetRealWidth(297),
                Y = Application.GetRealHeight(268),
                Height = Application.GetRealHeight(363),
                Width = Application.GetRealWidth(452),
                UnSelectedImagePath = "DoorLock/EntrySuccessIcon.png",
            };
            this.midFrameLayout.AddChidren(entryStatusPic);
 
            var btnPicTip = new Button
            {
                X = Application.GetRealWidth(372),
                Y = Application.GetRealHeight(634),
                Height = Application.GetRealHeight(81),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                Gravity = Gravity.CenterHorizontal,
                TextSize = 20,
                IsBold = true,
            };
            this.midFrameLayout.AddChidren(btnPicTip);
 
            if (currentType == "password")
            {
                btnPicTip.Text = Language.StringByID(R.MyInternationalizationString.EntryPasswordSuccess);
            }
            else if (currentType == "fingerprint")
            {
                btnPicTip.Text = Language.StringByID(R.MyInternationalizationString.EntryFingerprintSuccess);
            }
            else
            {
                btnPicTip.Text = Language.StringByID(R.MyInternationalizationString.EntryProximitySuccess);
            }
 
            BottomFrameLayoutContent();
        }
        /// <summary>
        /// 底部布局
        /// </summary>
        public void BottomFrameLayoutContent()
        {
            bottomFrameLayout = new FrameLayout()
            {
                Height = Application.GetRealHeight(737),
                Y = Application.GetRealHeight(999),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout);
 
            var passwordRemarkFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(965),
                Height = Application.GetRealHeight(127),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(81),
            };
            bottomFrameLayout.AddChidren(passwordRemarkFrameLayout);
 
            var btnPasswordRemark = new Button()
            {
                Width = Application.GetRealWidth(222),
                Height = Application.GetRealHeight(58),
                Y = Application.GetRealHeight(35),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 14,
            };
            passwordRemarkFrameLayout.AddChidren(btnPasswordRemark);
 
            var btnPasswordRemarkContent = new EditText()
            {
                Width = Application.GetRealWidth(965 - 222),
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(223),
                Y = Application.GetRealHeight(35),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 14,
                PlaceholderTextColor = ZigbeeColor.Current.XMGray3,
                TextColor = ZigbeeColor.Current.XMBlack
            };
            passwordRemarkFrameLayout.AddChidren(btnPasswordRemarkContent);
 
            var btnLine = new FrameLayout()
            {
                Width = Application.GetRealWidth(965),
                Height = 1,
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(81 + 127),
                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
            };
            bottomFrameLayout.AddChidren(btnLine);
 
            var personRemarkRemarkFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(965),
                Height = Application.GetRealHeight(127),
                X = Application.GetRealWidth(58),
                Y = btnLine.Bottom + Application.GetRealHeight(2),
            };
            bottomFrameLayout.AddChidren(personRemarkRemarkFrameLayout);
 
            var btnMatchPersonRemark = new Button()
            {
                Width = Application.GetRealWidth(222),
                Height = Application.GetRealHeight(58),
                Y = Application.GetRealHeight(35),
                Text = Language.StringByID(R.MyInternationalizationString.MatchPerson) + ":",
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 14,
            };
            personRemarkRemarkFrameLayout.AddChidren(btnMatchPersonRemark);
 
            var btnMatchPersonContent = new Button()
            {
                Width = Application.GetRealWidth(965 - 222),
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(223),
                Y = Application.GetRealHeight(35),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 14,
            };
            personRemarkRemarkFrameLayout.AddChidren(btnMatchPersonContent);
 
            var btnLine1 = new FrameLayout()
            {
                Width = Application.GetRealWidth(965),
                Height = 1,
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(81 + 127 + 12 + 127),
                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
            };
            bottomFrameLayout.AddChidren(btnLine1);
 
            var completeBtn = new Button
            {
                X = Application.GetRealWidth(86),
                Y = Application.GetRealHeight(472),
                Height = Application.GetRealHeight(127),
                Width = Application.GetRealWidth(907),
                Text = Language.StringByID(R.MyInternationalizationString.DoorLockComplete),
                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                Radius = (uint)Application.GetRealHeight(127 / 2),
                TextSize = 16,
                IsBold = true,
            };
            bottomFrameLayout.AddChidren(completeBtn);
 
            if (currentType == "password")
            {
                btnPasswordRemark.Text = Language.StringByID(R.MyInternationalizationString.PasswordRemark);
                btnPasswordRemarkContent.PlaceholderText = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + doorLock.doorLockProgrammingEventNotificationCommand.UserID;
            }
            else if (currentType == "fingerprint")
            {
                btnPasswordRemark.Text = Language.StringByID(R.MyInternationalizationString.FingerprintRemark);
                btnPasswordRemarkContent.PlaceholderText = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + doorLock.doorLockProgrammingEventNotificationCommand.UserID;
            }
            else
            {
                btnPasswordRemark.Text = Language.StringByID(R.MyInternationalizationString.ProximityRemark);
                btnPasswordRemarkContent.PlaceholderText = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + doorLock.doorLockProgrammingEventNotificationCommand.UserID;
            }
 
            btnMatchPersonContent.Text = curAccountObj.ShowName;
 
            completeBtn.MouseDownEventHandler += async (sender, e) =>
             {
                 completeBtn.Enable = false;
                 if (doorLock.doorLockProgrammingEventNotificationCommand == null)
                 {
                     return;
                 }
                 var addLockInfo = new ZigBee.Device.DoorLock.AddDoorLockData();
                 if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1)
                 {
                     //☆マーク☆
                     //addLockInfo.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                     addLockInfo.IsOtherAccountCtrl = true;
                 }
 
                 //☆マーク☆
                 //addLockInfo.CloudAccountId = curAccountObj.SubAccountDistributedMark;
                 if (doorLock.DeviceAddr != null)
                 {
                     addLockInfo.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
                 }
                 addLockInfo.OpenLockMode = doorLock.doorLockProgrammingEventNotificationCommand.ProgramEventSoure;
                 addLockInfo.DoorLockLocalUserId = doorLock.doorLockProgrammingEventNotificationCommand.UserID.ToString();
                 addLockInfo.EntryTime = System.DateTime.Now;
                 if (!string.IsNullOrEmpty(btnPasswordRemarkContent.Text))
                 {
                     addLockInfo.UserIdRemarks = btnPasswordRemarkContent.Text;
                 }
                 else
                 {
                     addLockInfo.UserIdRemarks = btnPasswordRemarkContent.PlaceholderText;
                 }
                 try
                 {
                     Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
                     var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo);
                     if (result != null)
                     {
                         if (result.Code == HttpMessageEnum.A成功)
                         {
                             if (doorLock.localDoorLockUserList.ContainsKey(doorLock.doorLockProgrammingEventNotificationCommand.UserID))
                             {
                                 //☆マーク☆
                                 //存门锁信息
                                 //var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountObj.SubAccountDistributedMark);
                                 //if (resultList != null)
                                 //{
                                 //    if (resultList.ContainsKey(doorLock.doorLockProgrammingEventNotificationCommand.UserID) == true)
                                 //    {
                                 //        var a = resultList[doorLock.doorLockProgrammingEventNotificationCommand.UserID];
                                 //        if (a?.ConnectedAccount == curAccountObj.SubAccountDistributedMark)
                                 //        {
                                 //            completeBtn.Enable = true;
                                 //            this.RemoveFromParent();
                                 //            for (int i = UserView.HomePage.Instance.ChildrenCount - 1; i >= 0; i--)
                                 //            {
                                 //                var form = UserView.HomePage.Instance.GetChildren(i);
 
                                 //                if (form is UnLockMethod)
                                 //                {
                                 //                    doorLock.currentUserDisplayMethod = "";
                                 //                    ((UnLockMethod)form).RefreshList();
                                 //                    break;
                                 //                }
                                 //                else
                                 //                {
                                 //                    form.RemoveFromParent();
                                 //                }
                                 //            }
                                 //        }
                                 //        else
                                 //        {
                                 //            completeBtn.Enable = true;
                                 //            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
                                 //        }
                                 //    }
                                 //}
                                 //else
                                 //{
                                 //    completeBtn.Enable = true;
                                 //    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
                                 //}
 
                             }
                         }
                         else
                         {
                             completeBtn.Enable = true;
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AddFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
                         }
                     }
                     else
                     {
                         completeBtn.Enable = true;
                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnPasswordRemarkContent);
                     }
                 }
                 catch { }
                 finally
                 {
                     CommonPage.Loading.Hide();
                 }
             };
        }
    }
}