JLChen
2020-06-05 f86c8b5dcf5c84386745b009fc4115fa9db3b76d
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
//using System;
//using System.Collections.Generic;
 
//namespace Shared.SimpleControl.Phone
//{
//    public class UserSensorAutomationPage : FrameLayout
//    {
//        SensorAutomationDevice autonmationDevice;
//        List<Common> SensorDeviceList;
//        VerticalScrolViewLayout bodyScrolView;
 
//        public UserSensorAutomationPage (List<Common> common)
//        {
//            autonmationDevice = new SensorAutomationDevice () { SubnetID = common [0].SubnetID, DeviceID = common [0].DeviceID };
//            SensorDeviceList = common;
//        }
 
//        public void ShowPage ()
//        {
//            BackgroundColor = SkinStyle.Current.ViewColor;
//            this.RemoveAll ();
//            #region 标题
//            var topView = new FrameLayout () {
//                Y = Application.GetRealHeight (36),
//                Height = Application.GetRealHeight (90),
//                BackgroundColor = SkinStyle.Current.MainColor
//            };
//            AddChidren (topView);
 
//            var title = new Button () {
//                TextAlignment = TextAlignment.Center,
//                TextID = R.MyInternationalizationString.AutomationSetting,
//                TextColor = SkinStyle.Current.TextColor1,
//                TextSize = 19,
//            };
//            topView.AddChidren (title);
 
//            var logo = new Button () {
//                Width = Application.GetRealWidth (154),
//                Height = Application.GetRealHeight (90),
//                X = Application.GetRealWidth (486),
//                UnSelectedImagePath = MainPage.LogoString,
//            };
//            topView.AddChidren (logo);
//            //Button ItemButton = new Button () {
//            //    Width = Application.GetRealWidth (55),
//            //    Height = Application.GetRealHeight (55),
//            //    UnSelectedImagePath = "Item/+.png",
//            //    SelectedImagePath = "Item/+.png",
//            //    Y = Application.GetRealHeight (17),
//            //    X = Application.GetRealWidth (640 - 80),
//            //};
//            //topView.AddChidren (ItemButton);
 
//            //ItemButton.MouseUpEventHandler += (sender, e) => {
//            //    Action<string> refLoad = (obj) => {
//            //        InitAutomation ();
//            //    };
 
//            //    var addSensorAutomation = new SensorAutomation ();
//            //    for (int i = 0; i < autonmationDevice.AutomationEnableList.Length; i++) {
//            //        if (autonmationDevice.AutomationEnableList [i] == 255 || autonmationDevice.AutomationEnableList [i] == 0) {
//            //            addSensorAutomation.AutomationId = (byte)i;
//            //            addSensorAutomation.AutomationStatus = 0;
//            //            break;
//            //        }
//            //    }                
//            //    var uslp = new UserSensorAutomationSettingPage (SensorDeviceList, autonmationDevice);
//            //    UserMiddle.DevicePageView.AddChidren (uslp);
//            //    uslp.ShowPage (addSensorAutomation,refLoad);
//            //    UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
//            //};
 
//            var back = new Button () {
//                Height = Application.GetRealHeight (90),
//                Width = Application.GetRealWidth (85),
//                UnSelectedImagePath = "Item/Back.png",
//                SelectedImagePath = "Item/BackSelected.png",
//            };
//            topView.AddChidren (back);
//            back.MouseUpEventHandler += (sender, e) => {
//                (Parent as PageLayout).PageIndex -= 1;
//            };
//            #endregion
 
//            bodyScrolView = new VerticalScrolViewLayout () {
//                Y = topView.Bottom,
//                Height = Application.GetRealHeight (Application.DesignHeight - 126)
//            };
//            AddChidren (bodyScrolView);
 
//            InitAutomation ();
//        }
 
//        int loadingCount = 0;
 
//        void InitAutomation ()
//        {
//            bodyScrolView.RemoveAll ();
//            MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
 
//            System.Threading.Tasks.Task.Factory.StartNew (() => {
//                var conditianEnableList = Control.ControlBytesSendHasReturn (Command.ReadSensorAutomationEnableList, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { });
//                var conditionIdList = Control.ControlBytesSendHasReturn (Command.ReadSensorAutomationListID, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { });
 
//                try {
//                    if (conditianEnableList == null || conditionIdList == null) {
//                        //if(loadingCount <2){
//                        //    loadingCount++;
//                        //    Application.RunOnMainThread (() => {
//                        //        MainPage.Loading.Hide ();
//                        //        InitAutomation ();
//                        //    });
//                        //}
//                        Application.RunOnMainThread (() => {
//                            try {
//                                new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
//                                MainPage.Loading.Hide ();
//                                if (Parent != null)
//                                    (Parent as PageLayout).PageIndex -= 1;
//                            }catch{}
//                        });
//                        return;
//                    }
//                    loadingCount = 0;
//                    this.autonmationDevice.ConditionIdList = conditionIdList;
//                    this.autonmationDevice.AutomationEnableList = conditianEnableList;
 
//                    for (int i = 0; i < this.autonmationDevice.sensorAutomationList.Count; i++) {
//                        var tempAutonmation = this.autonmationDevice.sensorAutomationList [i];
//                        //var targetNameBytes = Control.ControlBytesSendHasReturn (Command.ReadSensorTargetRemark, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { (byte)(tempAutonmation.AutomationId / 8),(byte)(tempAutonmation.AutomationId % 8) });
//                        //if (targetNameBytes.Length < 21)
//                            //continue;
//                        Application.RunOnMainThread (() => {
//                            //tempAutonmation.AutomationName = CommonPage.MyEncodingGB2312.GetString (targetNameBytes, 1, 20).Trim ('\0');
//                            switch(tempAutonmation.AutomationId) {
//                            case 0:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorPM25) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipPM25Level1);
//                                break;
//                            case 1:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorPM25) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipPM25Level2);
//                                break;
//                            case 2:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorPM25) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipPM25Level3);
//                                break;
//                            case 3:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorPM25) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipPM25Level4);
//                                break;
//                            case 4:
//                            case 5:
//                            case 6:
//                            case 7:
//                                break;
//                            //----
//                            case 8:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorCO2) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipCO2Level1);
//                                break;
//                            case 9:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorCO2) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipCO2Level2);
//                                break;
//                            case 10:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorCO2) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipCO2Level3);
//                                break;
//                            case 11:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorCO2) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTipCO2Level4);
//                                break;
//                            case 12:
//                            case 13:
//                            case 14:
//                            case 15:
//                                break;
//                            //----
//                            case 16:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTVOC) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTVOCTipLevel1);
//                                break;
//                            case 17:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTVOC) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTVOCTipLevel2);
//                                break;
//                            case 18:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTVOC) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTVOCTipLevel3);
//                                break;
//                            case 19:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTVOC) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTVOCTipLevel4);
//                                break;
//                            case 20:
//                            case 21:
//                            case 22:
//                            case 23:
//                                break;
//                            //----
//                            case 24:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTemperature) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel1);
//                                break;
//                            case 25:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTemperature) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel2);
//                                break;
//                            case 26:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTemperature) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel3);
//                                break;
//                            case 27:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorTemperature) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel4);
//                                break;
//                            case 28:
//                            case 29:
//                            case 30:
//                            case 31:
//                                break;
//                            //----
//                            case 32:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorHumidity) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel1);
//                                break;
//                            case 33:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorHumidity) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel2);
//                                break;
//                            case 34:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorHumidity) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel3);
//                                break;
//                            case 35:
//                                tempAutonmation.AutomationName = Language.StringByID (R.MyInternationalizationString.SensorHumidity) + " " + Language.StringByID (R.MyInternationalizationString.SensorReferenceTempTipLevel4);
//                                break;
//                            case 36:
//                            case 37:
//                            case 38:
//                            case 39:
//                                break;
//                            }
//                            var rowView = new RowLayout () {
//                                Height = Application.GetRealHeight (100),
//                                BackgroundColor = SkinStyle.Current.ViewColor,
//                            };
//                            bodyScrolView.AddChidren (rowView);
//                            var btnPoint = new Button () {
//                                Width = Application.GetMinRealAverage (10),
//                                Height = Application.GetMinRealAverage (10),
//                                Radius = (uint)Application.GetMinRealAverage (5),
//                                X = Application.GetRealWidth (50),
//                                Gravity = Gravity.CenterVertical,
//                                BackgroundColor = SkinStyle.Current.TextColor1,
//                                SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
//                                Tag = i
//                            };
//                            rowView.AddChidren (btnPoint);
//                            var btnDeviceName = new Button () {
//                                Width = Application.GetRealWidth (300),
//                                X = Application.GetRealWidth (80),
//                                Text = tempAutonmation.AutomationName,
//                                TextColor = SkinStyle.Current.TextColor1,
//                                SelectedTextColor = SkinStyle.Current.SelectedColor,
//                                TextAlignment = TextAlignment.CenterLeft,
//                                Tag = i
//                            };
//                            rowView.AddChidren (btnDeviceName);
 
//                            var tempSwitch = new Button () {
//                                Width = Application.GetMinRealAverage (90),
//                                Height = Application.GetMinRealAverage (53),
//                                X = Application.GetRealWidth (640 - 90 - 30),
//                                Gravity = Gravity.CenterVertical,
//                                IsSelected = tempAutonmation.AutomationStatus == 2 ? false : true,
//                                UnSelectedImagePath = "Item/SwitchClose.png",
//                                SelectedImagePath = "Item/SwitchOpen.png",
//                                Tag = tempAutonmation.AutomationId
//                            };
//                            rowView.AddChidren (tempSwitch);
 
//                            tempSwitch.MouseUpEventHandler += (ddff, ffdd) => {
//                                tempSwitch.IsSelected = !tempSwitch.IsSelected;
//                                byte autoEnalbeByte = tempSwitch.IsSelected == true ? (byte)1 : (byte)2;
//                                //MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
//                                System.Threading.Tasks.Task.Run (() => {
//                                    try {
//                                        var updateId = Convert.ToByte (((Button)ddff).Tag);
//                                        var delSensorAutomation = autonmationDevice.sensorAutomationList.Find ((obj) => obj.AutomationId == updateId);//根据自动化ID找到需要删除的自动化
//                                        if (delSensorAutomation == null)
//                                            return;
//                                        autonmationDevice.AutomationEnableList [updateId] = autoEnalbeByte;//将自动化相应的使能改为无效
 
//                                        var conditianStatusListRevice = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationEnableList, autonmationDevice.SubnetID, autonmationDevice.DeviceID, autonmationDevice.AutomationEnableList);
//                                    } catch (Exception ex) {
//                                        Console.WriteLine (ex.Message);
//                                    } finally {
//                                        //Application.RunOnMainThread (() => {
//                                            //MainPage.Loading.Hide ();
//                                            //InitAutomation ();
//                                        //});
//                                    }
//                                });
//                            };
 
//                            //var editor = new Button () {
//                            //    UnSelectedImagePath = "Item/EditInRightView.png",
//                            //    BackgroundColor = SkinStyle.Current.MainColor,
//                            //};
//                            //if (MainPage.LoginUser.AccountString == "464027401@qq.com")
//                            //    rowView.AddRightView (editor);
//                            //editor.MouseUpEventHandler += (sender, e) => {
//                            //    Action<string> refLoad = (obj) => {
//                            //        btnDeviceName.Text = obj;
//                            //    };
//                            //    var uslp = new UserSensorAutomationSettingPage (SensorDeviceList, autonmationDevice);
//                            //    UserMiddle.DevicePageView.AddChidren (uslp);
//                            //    uslp.ShowPage (tempAutonmation, refLoad);
//                            //    UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
//                            //};
//                            //var btnDel = new Button () {
//                            //    UnSelectedImagePath = "Item/DelInRightView.png",
//                            //    Tag = tempAutonmation.AutomationId
//                            //};
//                            //if (MainPage.LoginUser.AccountString == "464027401@qq.com")
//                                //rowView.AddRightView (btnDel);
//                            //btnDel.MouseUpEventHandler += (ddff, ffdd) => {
//                            //    var delAlert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.ConfirmDelAutomation), Language.StringByID (R.MyInternationalizationString.cancel), Language.StringByID (R.MyInternationalizationString.confirm));
//                            //    delAlert.Show ();
//                            //    delAlert.ResultEventHandler += (ddaa, dde) => {
//                            //        if (dde) {
//                            //            MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
//                            //            System.Threading.Tasks.Task.Run (() => {
//                            //                try {
//                            //                    var delId = Convert.ToByte (((Button)ddff).Tag);
//                            //                    var delSensorAutomation = autonmationDevice.sensorAutomationList.Find ((obj) => obj.AutomationId == delId);//根据自动化ID找到需要删除的自动化
//                            //                    if (delSensorAutomation == null)
//                            //                        return;
//                            //                    autonmationDevice.AutomationEnableList [delId] = 0;//将自动化相应的使能改为删除
//                            //                    for (int delIndex = 0; delIndex < 40; delIndex++) {//循环自动化包含的每一个触发条件
//                            //                        //var delCondition = delSensorAutomation.sensorAutomationConditionList [delIndex];
//                            //                        ////读取自动化条件触发目标的使能数据
//                            //                        //var automationTargetLevelEnable = Control.ControlBytesSendHasReturn (Command.ReadSensorAutomationLevelTargetEnable, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { delCondition.PushId });
//                            //                        //automationTargetLevelEnable [3 * delCondition.ConditionLevel + 1] = 0;//将对应的自动化条件触发的目标使能改为无效
//                            //                        //automationTargetLevelEnable [3 * delCondition.ConditionLevel + 2] = 0;
//                            //                        //automationTargetLevelEnable [3 * delCondition.ConditionLevel + 3] = 0;
//                            //                        //var setAutomationTargetLevelEnable = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationTargetLevelEnable, autonmationDevice.SubnetID, autonmationDevice.DeviceID, automationTargetLevelEnable);
//                            //                        if (autonmationDevice.ConditionIdList [delIndex] == delId)//将自动化条件绑定的自动化删除
//                            //                        {
//                            //                            autonmationDevice.ConditionIdList [delIndex] = 255;
//                            //                        }
//                            //                    }
//                            //                    var conditianStatusListRevice = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationEnableList, autonmationDevice.SubnetID, autonmationDevice.DeviceID, autonmationDevice.AutomationEnableList);
//                            //                    var conditionIdListRevice = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationListID, autonmationDevice.SubnetID, autonmationDevice.DeviceID, autonmationDevice.ConditionIdList);
//                            //                } catch (Exception ex) {
//                            //                    Console.WriteLine (ex.Message);
//                            //                } finally {
//                            //                    Application.RunOnMainThread (() => {
//                            //                        MainPage.Loading.Hide ();
//                            //                        InitAutomation ();
//                            //                    });
//                            //                }
//                            //            });
//                            //        }
//                            //    };
//                            //};
                        
                        
//                        });
//                    }
//                } catch (Exception ex) {
//                    Console.WriteLine (ex.Message);
//                } finally {
//                    Application.RunOnMainThread (() => {
//                        MainPage.Loading.Hide ();
//                    });
//                }
//            });
//        }
 
//        public void ShowSceneListView (Sensor sensorDevice, byte targetLoop, VerticalScrolViewLayout sceneListView)
//        {
//            #region sceneList
//            ////全部类型的场景列表
//            //var allSceneFilePaths = new List<string> ();
//            ////全局场景中所有的场景
//            //var sceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath)));
//            //allSceneFilePaths.AddRange (sceneFileList);
//            ////房间的所有场景
//            //foreach (var room in Room.Lists) {
//            //    if (string.IsNullOrEmpty (room.Name)) {
//            //        continue;
//            //    }
//            //    allSceneFilePaths.AddRange (room.SceneFilePathList);
//            //}
 
//            //int i = 0;
//            //foreach (var sceneFilePath in allSceneFilePaths) {
//            //    var scene = Scene.GetSceneByFilePath (sceneFilePath);
//            //    if (scene == null) {
//            //        continue;
//            //    }
 
//            //    var frameLayout = new RowLayout () {
//            //        Height = Application.GetRealHeight (115),
//            //    };
//            //    sceneListView.AddChidren (frameLayout);
 
//            //    var btnRemarkName = new Button () {
//            //        Width = Application.GetRealWidth (420),
//            //        Height = LayoutParams.MatchParent,
//            //        Text = scene.Name,
//            //        TextAlignment = TextAlignment.CenterLeft,
//            //        X = Application.GetRealWidth (80),
//            //    };
//            //    frameLayout.AddChidren (btnRemarkName);
 
//            //    int currentIndex = i;
 
//            //    EventHandler<MouseEventArgs> hander = (sender, e) => {
//            //        var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<Scene> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (sceneFilePath)));
 
//            //        for (int j = 0; j < sceneListView.ChildrenCount; j++) {
//            //            var rowView = sceneListView.GetChildren (j);
//            //            if (rowView.GetType () == typeof (RowLayout)) {
//            //                if (currentIndex == j) {
//            //                    ((RowLayout)rowView).BackgroundImagePath = "DoorLockPic/door_lock_ scene_on.png";
//            //                } else {
//            //                    ((RowLayout)rowView).BackgroundImagePath = "DoorLockPic/door_lock_ scene.png";
//            //                }
//            //            }
//            //        }
 
//            //        Application.RunOnMainThread (() => {
//            //            MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.TargetsConfiguring) + "...");
//            //        });
//            //        System.Threading.Tasks.Task.Run (() => {
//            //            try {
//            //                var controlSceneBLL = new ScenePhoneMethod ();
//            //                int controlDeviceIndex = 0;
//            //                foreach (var deviceFilePath in tempScene.DeviceFilePathList) {
//            //                    if (!tempScene.busScene) {
//            //                        if (controlDeviceIndex > 19) {
//            //                            break;
//            //                        }
 
//            //                        var sendBytes = new byte [10];
//            //                        sendBytes [0] = sensorDevice.DevicePushType;//开锁
//            //                        sendBytes [1] = targetLoop;//开锁类型   密码开锁
//            //                        sendBytes [2] = (byte)controlDeviceIndex;
 
//            //                        if (deviceFilePath.Split ('_') [1] == DeviceType.LightDimming.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x59;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = device.CurrentBrightness;
//            //                            sendBytes [8] = device.DelayTimeHeight;
//            //                            sendBytes [9] = device.DelayTimeLow;
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightDALI.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDALI> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x59;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = device.CurrentBrightness;
//            //                            sendBytes [8] = device.DelayTimeHeight;
//            //                            sendBytes [9] = device.DelayTimeLow;
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightMixDimming.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x59;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.PhysicsLoopID;
//            //                            sendBytes [7] = device.CurrentBrightness;
//            //                            sendBytes [8] = device.DelayTimeHeight;
//            //                            sendBytes [9] = device.DelayTimeLow;
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightMixSwitch.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x59;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.PhysicsLoopID;
//            //                            sendBytes [7] = device.CurrentBrightness;
//            //                            sendBytes [8] = device.DelayTimeHeight;
//            //                            sendBytes [9] = device.DelayTimeLow;
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightSwitch.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x59;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = device.CurrentBrightness;
//            //                            sendBytes [8] = device.DelayTimeHeight;
//            //                            sendBytes [9] = device.DelayTimeLow;
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightEnergySwitch.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x59;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = device.CurrentBrightness;
//            //                            sendBytes [8] = device.DelayTimeHeight;
//            //                            sendBytes [9] = device.DelayTimeLow;
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.FanModule.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<FanModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x59;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = (byte)device.WindSpeed;
//            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) {
//            //                            //    result = true;
//            //                            //}
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.CurtainModel.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x5C;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = (byte)device.Status;
//            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) {
//            //                            //    result = true;
//            //                            //}
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.CurtainRoller.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x5C;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = (byte)device.Status;
//            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) {
//            //                            //    result = true;
//            //                            //}
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.CurtainTrietex.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x5C;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.LoopID;
//            //                            sendBytes [7] = (byte)device.Status;
//            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) {
//            //                            //    result = true;
//            //                            //}
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LogicModule.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            sendBytes [3] = 0x55;
//            //                            sendBytes [4] = device.SubnetID;
//            //                            sendBytes [5] = device.DeviceID;
//            //                            sendBytes [6] = device.AreaID;
//            //                            sendBytes [7] = device.AreaSceneID;
//            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.UniversalDevice.ToString ()) {
//            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                            if (device == null) {
//            //                                continue;
//            //                            }
//            //                            if (device.UniversalType == 0xE01C) {
//            //                                sendBytes [3] = 0x58;
//            //                                sendBytes [4] = device.SubnetID;
//            //                                sendBytes [5] = device.DeviceID;
//            //                                sendBytes [6] = 0 < device.SendBytes.Count ? device.SendBytes [0] : (byte)0;
//            //                                sendBytes [7] = 1 < device.SendBytes.Count ? device.SendBytes [1] : (byte)0;
//            //                                //if (!sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) {
//            //                                //    result = true;
//            //                                //}
//            //                            }
//            //                        } else {
//            //                            continue;
//            //                        }
//            //                        controlSceneBLL.ControlSceneDevice (deviceFilePath, controlDeviceIndex, 20);
//            //                    } else {
//            //                        var device = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
//            //                        var sendBytes = new byte [10];
//            //                        sendBytes [0] = sensorDevice.DevicePushType;
//            //                        sendBytes [1] = targetLoop;
//            //                        sendBytes [2] = (byte)controlDeviceIndex;
//            //                        sendBytes [3] = device.obj1;
//            //                        sendBytes [4] = device.SubnetID;
//            //                        sendBytes [5] = device.DeviceID;
//            //                        sendBytes [6] = device.obj2;
//            //                        sendBytes [7] = device.obj3;
//            //                        sendBytes [8] = device.obj4;
//            //                        sendBytes [9] = device.obj5;
//            //                        controlSceneBLL.ControlBusSceneDevice (device);
//            //                    }
//            //                    controlDeviceIndex++;
//            //                }
//            //            } catch { } finally {
//            //                Application.RunOnMainThread (() => {
//            //                    MainPage.Loading.Hide ();
//            //                });
//            //            }
//            //        });
//            //    };
 
//            //    frameLayout.MouseUpEventHandler += hander;
//            //    btnRemarkName.MouseUpEventHandler += hander;
//            //    i++;
//            //}
//            #endregion
 
//        }
 
//    }
//}