HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-11-13 8b9ce384b26c414db32f98e94e088f5334869c2d
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
using System;
using System.Collections.Generic;
using Shared.Common;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DoorLock
{
    public class FunctionSetting : DoorLockCommonLayout, ZigBee.Common.IStatus
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="doorLock"></param>
        public FunctionSetting(ZigBee.Device.DoorLock doorLock)
        {
            this.doorLock = doorLock;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
        }
 
        #region ◆ 变量申明__________________________
        ZigBee.Device.DoorLock doorLock;
        /// <summary>
        /// 设备需要保存的设备名字
        /// </summary>
        private Dictionary<int, string> dicDeviceSaveName = new Dictionary<int, string>();
        /// <summary>
        /// 当前选择的设备
        /// </summary>
        private CommonDevice nowSelectDevice = null;
        /// <summary>
        /// 设备备注的控件
        /// </summary>
        private FrameCaptionInputControl btnDeviceName = null;
        /// <summary>
        /// 设备的某一回路
        /// </summary>
        private CommonDevice deviceObj = null;
        #endregion
 
        /// <summary>
        /// UI显示 
        /// </summary>
        public void Show()
        {
            this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.DoorLockFunctionSetting));
 
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
                RemoveFromParent();
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
 
            MidFrameLayoutContent();
 
        }
 
        public void MidFrameLayoutContent()
        {
 
            var MidTopFrameLayout = new FrameLayout()
            {
                X = Application.GetRealWidth(449),
                Y = Application.GetRealHeight(58),
                Width = Application.GetRealWidth(184),
                Height = Application.GetRealHeight(184),
                BackgroundImagePath = "DoorLock/DoorlockPicture.png",
            };
            this.midFrameLayout.AddChidren(MidTopFrameLayout);
            BottomFrameLayout();
        }
 
        public void BottomFrameLayout()
        {
            #region  UI 
            var bottomFrameLayout = new FrameLayout()
            {
                Height = Application.GetRealHeight(100),
                Y = Application.GetRealHeight(418),
                Radius = 17,
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout);
 
            var bottomFrameLayout1 = new FrameLayout()
            {
                Height = Application.GetRealHeight(1319 - 50),
                Y = Application.GetRealHeight(418 + 48),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout1);
 
            var bottomFrameLayout2 = new FrameLayout()
            {
                Height = Application.GetRealHeight(1054),
                Y = Application.GetRealHeight(418),
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout2);
 
            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 = 15,
            };
            bottomFrameLayout2.AddChidren(informationEdit);
 
            for (int i = 0; i < 6; i++)
            {
                var bottomRowLayout = new FrameLayout()
                {
                    Height = Application.GetRealHeight(58),
                };
                bottomFrameLayout2.AddChidren(bottomRowLayout);
 
                var btnName = new Button()
                {
                    Width = Application.GetRealWidth(233),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(58),
                    TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextSize = 14,
                };
                bottomRowLayout.AddChidren(btnName);
 
                var btnNextFrameLayout = new FrameLayout()
                {
                    Width = Application.GetRealWidth(104),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(861 + 58),
                };
                bottomRowLayout.AddChidren(btnNextFrameLayout);
 
                var btnNext = new Button()
                {
                    Width = Application.GetRealWidth(58),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(46)
                };
                btnNextFrameLayout.AddChidren(btnNext);
 
                var btnLine = new FrameLayout()
                {
                    Width = Application.GetRealWidth(965),
                    Height = 1,
                    X = Application.GetRealWidth(58),
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                    Visible = false,
                };
                bottomFrameLayout2.AddChidren(btnLine);
 
                if (i == 0)
                {
                    bottomRowLayout.Y = Application.GetRealHeight(220);
                    btnName.Text = Language.StringByID(R.MyInternationalizationString.DeviceRemarkXm) + ":";
                    btnNextFrameLayout.Width = btnNext.Width = Application.GetRealWidth(789 - 58);
                    btnNextFrameLayout.X = Application.GetRealWidth(233);
                    btnNext.TextAlignment = TextAlignment.CenterLeft;
                    btnNext.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                    btnNext.Text = doorLock.DeviceName;
                    btnLine.Visible = true;
                    btnLine.Y = Application.GetRealHeight(303);
                }
                else if (i == 1)
                {
                    bottomRowLayout.Y = Application.GetRealHeight(312);
                    bottomRowLayout.Height = Application.GetRealHeight(127);
                    btnName.Width = Application.GetRealWidth(0);
                    btnNextFrameLayout.Width = Application.GetRealWidth(0);
                    //所属区域
                    var rowBeloneArea = new BelongAreaControl(0);
                    bottomRowLayout.AddChidren(rowBeloneArea);
 
                    rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), doorLock);
                    //底线
                    rowBeloneArea.AddBottomLine();
                    rowBeloneArea.SelectRoomEvent += (roomKeys) =>
                    {
                        //变更房间
                        Common.Room.CurrentRoom.ChangedRoom(doorLock, roomKeys);
                    };
                    btnLine.Visible = false;
                }
                else if (i == 2)
                {
                    bottomRowLayout.Y = Application.GetRealHeight(481);
                    btnName.Text = Language.StringByID(R.MyInternationalizationString.BelongModel) + ":";
                    btnNextFrameLayout.Width = btnNext.Width = Application.GetRealWidth(789 - 58);
                    btnNextFrameLayout.X = Application.GetRealWidth(233);
 
                    btnNext.TextAlignment = TextAlignment.CenterLeft;
                    btnNext.Height = Application.GetRealHeight(58);
                    btnNext.Text = doorLock.DeviceName;
                    btnNext.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
 
                    btnLine.Visible = true;
                    btnLine.Y = Application.GetRealHeight(575);
                }
                else if (i == 3)
                {
                    bottomRowLayout.Y = Application.GetRealHeight(585 + 35);
                    btnName.Text = Language.StringByID(R.MyInternationalizationString.TemporaryPassword);
 
                    btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png";
 
                    btnLine.Visible = true;
                    btnLine.Y = Application.GetRealHeight(714);
                }
                else if (i == 4)
                {
                    bottomRowLayout.Y = Application.GetRealHeight(723 + 35);
                    btnNext.X = Application.GetRealWidth(0);
                    btnName.Text = Language.StringByID(R.MyInternationalizationString.RemotelyUnlock);
                    btnNext.Width = Application.GetRealWidth(104);
                    btnNext.Height = Application.GetRealHeight(63);
                    btnNext.UnSelectedImagePath = "DoorLock/Switch.png";
                    btnNext.SelectedImagePath = "DoorLock/SwitchOn.png";
                    btnLine.Visible = true;
                    btnLine.Y = Application.GetRealHeight(853);
                    if (doorLock.RemoteUnlockPassword == "")
                    {
                        btnNext.IsSelected = false;
                    }
                    else
                    {
                        btnNext.IsSelected = true;
                    }
                }
                else if (i == 5)
                {
                    bottomRowLayout.Y = Application.GetRealHeight(861 + 35);
                    btnName.Text = Language.StringByID(R.MyInternationalizationString.DoorLockTime);
                    btnNextFrameLayout.Y = btnName.Y;
                    btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png";
                    btnLine.Visible = false;
                    btnLine.Y = Application.GetRealHeight(992);
                }
                //else if (i == 6)
                //{
                //    bottomRowLayout.Y = Application.GetRealHeight(999 + 35);
                //    btnName.Text = Language.StringByID(R.MyInternationalizationString.DoorLockShare);
                //    btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png";
                //    btnLine.Visible = true;
                //    btnLine.Y = Application.GetRealHeight(1131);
                //}
                int currentIndex = i;
                EventHandler<MouseEventArgs> eHandler = async (sender, e) =>
                 {
                     if (currentIndex == 1)
                     {
                         //获取设备所属房间
                         var aa = Common.Room.CurrentRoom.GetRoomByDevice(doorLock);
                         //获取设备所在楼层
                         var bb = aa.FloorId;
                         //获取设备所在楼层
                         var cc = aa.FloorId;
                         //获取楼层的名字
                         var dd = Common.Config.Instance.Home.GetFloorNameById(cc);
                         //if (Common.Config.Instance.Home.FloorDics.Count == 0)//这个是无楼层模式
 
                         var listCheck = new List<string>();
                     }
                     else if (currentIndex == 3)
                     {
                         var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result == false)
                         {
                             var temporaryPassword = new Shared.Phone.UserCenter.DoorLock.TemporaryPassword(doorLock);
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(temporaryPassword);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                             temporaryPassword.Show();
                         }
                         else
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                         }
 
                     }
                     else if (currentIndex == 4)
                     {
                         if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                         {
                             var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                             if (result == false)
                             {
                                 var result1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                                 if (result1 == true)
                                 {
                                     btnNext.IsSelected = !btnNext.IsSelected;
                                     if (btnNext.IsSelected)
                                     {
                                         if (doorLock.RemoteUnlockPassword == "")
                                         {
                                             RemotePasswordDialog(doorLock, btnNext);
                                         }
                                     }
                                     else
                                     {
                                         doorLock.RemoteUnlockPassword = "";
                                     }
                                 }
                                 else
                                 {
                                     new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                                 }
                             }
                             else
                             {
                                 new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                             }
                         }
                         else
                         {
                             btnNext.IsSelected = !btnNext.IsSelected;
                             if (btnNext.IsSelected)
                             {
                                 if (doorLock.RemoteUnlockPassword == "")
                                 {
                                     RemotePasswordDialog(doorLock, btnNext);
                                 }
                             }
                             else
                             {
                                 doorLock.RemoteUnlockPassword = "";
                             }
                         }
                     }
                     else if (currentIndex == 5)
                     {
                         var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result == false)
                         {
                             var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "DoorLockTime");
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                             tempPage.Show();
                         }
                         else
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                         }
                     }
                 };
                bottomRowLayout.MouseDownEventHandler += eHandler;
                btnNext.MouseDownEventHandler += eHandler;
                btnName.MouseDownEventHandler += eHandler;
                btnNextFrameLayout.MouseDownEventHandler += eHandler;
                #endregion
            }
 
            //保存
            //var btnFinifh = new Button()
            //{
            //    Width = Application.GetRealWidth(907),
            //    Height = Application.GetRealHeight(127),
            //    Y = Application.GetRealHeight(1472),
            //    Gravity = Gravity.CenterHorizontal,
            //    Radius = (uint)Application.GetRealHeight(127) / 2,
            //    TextID = R.MyInternationalizationString.Save,
            //    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
            //    TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
            //    TextSize = 16,
            //};
            //this.midFrameLayout.AddChidren(btnFinifh);
            //btnFinish.MouseUpEventHandler += async (sender, e) =>
            //{
            //    //记录起当前正在操作的回路名字
            //    dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim();
            //    //开启进度条
            //    this.ShowProgressBar();
            //    foreach (var epoint in dicDeviceSaveName.Keys)
            //    {
            //        var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
            //        if (device == null || dicDeviceSaveName[epoint] == string.Empty)
            //        {
            //            //不能允许空白名字
            //            continue;
            //        }
            //        string newName = dicDeviceSaveName[epoint];
            //        string oldName = Common.LocalDevice.Current.GetDeviceEpointName(device);
            //        if (oldName != newName)
            //        {
            //            //设备名称修改
            //            var result = await Common.LocalDevice.Current.ReName(device, newName);
            //            if (result == false)
            //            {
            //                //关闭
            //                this.CloseProgressBar();
            //                return;
            //            }
            //        }
            //    }
            //    this.CloseProgressBar();
            //    //关闭自身
            //    this.CloseForm();
            //};
        }
 
        #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
    }
}