1
wxr
2023-03-31 7e42cc13a14b7de31c9f5d5c61cdf24f3246335d
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
using System;
using System.Collections.Generic;
using Shared;
 
namespace Shared.SimpleControl.Phone
{
    public class AlexaSettingPage : Dialog
    {
        Room room;
        List<string> showList = new List<string> ();
        VerticalScrolViewLayout deviceScrolView;
        VerticalScrolViewLayout typeLayout;
        string selectedDeviceType = "All";
 
        List<string> roomSceneFilePathList = new List<string> ();
        List<string> roomDeviceFilePathList = new List<string> ();
        int show = 99;
        FrameLayout bodyView;
        public AlexaSettingPage (Room r)
        {
            room = r;
            showList.Clear ();
 
            roomSceneFilePathList.AddRange (room.SceneFilePathList);
            roomDeviceFilePathList.AddRange (room.DeviceFilePathList);
            showList.AddRange (roomDeviceFilePathList);
            showList.AddRange (roomSceneFilePathList);
            bodyView = new FrameLayout () {
                BackgroundColor = SkinStyle.Current.MainColor,
            };
            AddChidren (bodyView);
        }
 
        public void ShowPage (Action action, Action<List<string>, List<string>> saveAction)
        {
            #region ---TopView---
            var topView = new RowLayout () {
                Y = Application.GetRealHeight (36),
                Height = Application.GetRealHeight (90),
                Width = Application.GetRealWidth (640),
                BackgroundColor = SkinStyle.Current.MainColor,
            };
            bodyView.AddChidren (topView);
 
            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) => {
                this.Close ();
            };
 
            Button NameButton = new Button () {
                Width = Application.GetRealWidth (400),
                Height = Application.GetMinReal (90),
                TextID = R.MyInternationalizationString.AddNewDevice,
                //Text = MainPage.SoftTitle,
                SelectedTextColor = SkinStyle.Current.TextColor1,
                TextColor = SkinStyle.Current.TextColor1,
                Gravity = Gravity.CenterHorizontal,
                TextAlignment = TextAlignment.Center,
                TextSize = 20,
            };
            topView.AddChidren (NameButton);
 
            #endregion
            #region type view 
            var chooseTypeView = new RowLayout () {
                Y = topView.Bottom,
                Height = Application.GetRealHeight (110),
                BackgroundColor = SkinStyle.Current.ViewColor,
            };
            bodyView.AddChidren (chooseTypeView);
            Button btnEquipmentIcon = new Button () {
                Width = Application.GetRealHeight (65),
                Height = Application.GetRealHeight (65),
                UnSelectedImagePath = "Item/LogicModule.png",
                X = Application.GetRealWidth (30),
                Gravity = Gravity.CenterVertical,
            };
            chooseTypeView.AddChidren (btnEquipmentIcon);
            Button btnDrodIcon = new Button () {
                X = Application.GetRealWidth (540),
                Height = Application.GetRealHeight (46),
                Width = Application.GetRealWidth (47),
                UnSelectedImagePath = "Item/Down.png",
                SelectedImagePath = "Item/DownSelected.png",
                Gravity = Gravity.CenterVertical,
            };
            chooseTypeView.AddChidren (btnDrodIcon);
            Button btnEquipmentType = new Button () {
                Width = Application.GetRealHeight (460),
                X = btnEquipmentIcon.Right + Application.GetRealWidth (20),
                TextAlignment = TextAlignment.CenterLeft,
                Text = Language.StringByID (R.MyInternationalizationString.All),
                TextColor = SkinStyle.Current.TextColor1,
                SelectedTextColor = SkinStyle.Current.DialogTextColor
            };
            chooseTypeView.AddChidren (btnEquipmentType);
            typeLayout = new VerticalScrolViewLayout () {
                Y = chooseTypeView.Bottom,
                Height = Application.GetRealHeight (0),
                BackgroundColor = SkinStyle.Current.ViewColor
            };
            EventHandler<MouseEventArgs> chooseTypeMethod = (sender, e) => {
                if (show == 99) {//第一次需要先初始化选择设备类型界面
                    InitEquipmentTypeView (btnEquipmentType, btnEquipmentIcon, chooseTypeView);
                    show = 0;
                } else if (show == 0) {
                    typeLayout.Height = Application.GetRealHeight (1136 - 126 - 90);
                    chooseTypeView.BackgroundColor = SkinStyle.Current.MainColor;
                    show = 1;
                } else if (show == 1) {
                    typeLayout.Height = 0;
                    chooseTypeView.BackgroundColor = SkinStyle.Current.ViewColor;
                    show = 0;
                }
            };
            btnEquipmentType.MouseUpEventHandler += chooseTypeMethod;
            btnDrodIcon.MouseUpEventHandler += chooseTypeMethod;
            chooseTypeView.MouseUpEventHandler += chooseTypeMethod;
            #endregion
 
            deviceScrolView = new VerticalScrolViewLayout () {
                Y = chooseTypeView.Bottom,
                Height = Application.GetRealHeight (1136 - 126 - 110 - 89),
                BackgroundColor = SkinStyle.Current.ViewColor,
            };
            bodyView.AddChidren (deviceScrolView);
 
            InitDeviceList ();
 
            var btnClose = new Button () {
                Height = Application.GetRealHeight (90),
                Y = deviceScrolView.Bottom,
                BackgroundColor = SkinStyle.Current.MainColor,
                Text = "OK",
                TextColor = SkinStyle.Current.TextColor1,
                TextAlignment = TextAlignment.Center,
                TextSize = 16,
            };
            bodyView.AddChidren (btnClose);
            btnClose.MouseUpEventHandler += (sender, e) => {
                saveAction (roomSceneFilePathList, roomDeviceFilePathList);
                this.Close ();
            };
        }
 
        /// <summary>
        /// 显示在本地找到的所有设备
        /// </summary>
        void InitDeviceList ()
        {
            deviceScrolView.RemoveAll ();
            System.Threading.Tasks.Task.Run (() => {
                //找出需要显示的设备
                var filesList = IO.FileUtils.ReadFiles ().FindAll ((obj) => {
                    string [] str = obj.Split ('_');
                    return obj.StartsWith ("Equipment_") && str.Length == 5;
                });
                var localEquipments = filesList.FindAll ((obj) => {
                    string typeString = obj.Split ('_') [1];
 
                    return (
                    #region light
                    typeString.ToString () == DeviceType.LightCCT.ToString () ||
                    typeString.ToString () == DeviceType.LightRGB.ToString () ||
                    typeString.ToString () == DeviceType.LightDALI.ToString () ||
                    typeString.ToString () == DeviceType.LightRGBW.ToString () ||
                    typeString.ToString () == DeviceType.LightLogic.ToString () ||
                    typeString.ToString () == DeviceType.LightSwitch.ToString () ||
                    typeString.ToString () == DeviceType.LightDimming.ToString () ||
                    typeString.ToString () == DeviceType.LightMixSwitch.ToString () ||
                    typeString.ToString () == DeviceType.LightRGBandCCT.ToString () ||
                    typeString.ToString () == DeviceType.LightMixDimming.ToString () ||
                    typeString.ToString () == DeviceType.LightEnergySocket.ToString () ||
                    typeString.ToString () == DeviceType.LightEnergySwitch.ToString () ||
                    typeString.ToString () == DeviceType.LightSwitchSocket.ToString ()
                    || typeString.ToString () == DeviceType.DMX48.ToString ()
                    #endregion
                    #region curtain
                    || typeString.ToString () == DeviceType.CurtainModel.ToString ()
                    || typeString.ToString () == DeviceType.CurtainRoller.ToString ()
                    || typeString.ToString () == DeviceType.CurtainTrietex.ToString ()
                    #endregion
                    #region ac
                    || typeString.ToString () == DeviceType.ACPanel.ToString ()
                    || typeString.ToString () == DeviceType.ACDevice.ToString ()
                    || typeString.ToString () == DeviceType.ACInfrared.ToString ()
                    || typeString.ToString () == DeviceType.ACCoolmaster.ToString ()
                    || typeString.ToString () == DeviceType.CustomAC.ToString ()
                    || typeString.ToString () == DeviceType.HVAC.ToString ()
                    #endregion
                    #region 
                    || typeString.ToString () == DeviceType.FanModule.ToString ()
                    || typeString.ToString () == DeviceType.UniversalDevice.ToString ()
                    #endregion
                    );
                });
                var globalSceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath)));
                if (globalSceneFileList == null) {
                    globalSceneFileList = new List<string> ();
                }
                List<string> RoomsSceneFileList = new List<string> ();
                foreach (var r in Room.Lists) {
                    if (string.IsNullOrEmpty (r.Name)) {
                        continue;
                    }
                    if (r != null) {
                        RoomsSceneFileList.AddRange (r.SceneFilePathList);
                    }
                }
                List<string> TargetList = new List<string> ();
 
                if (selectedDeviceType == "Scene") {
                    if (string.IsNullOrEmpty (room.RoomFilePath) || room.RoomFilePath == Room.FavoriteRoom) {
                        TargetList.AddRange (globalSceneFileList);
                        TargetList.AddRange (RoomsSceneFileList);
                    } else {
                        Application.RunOnMainThread (() => {
                            new ScenePhoneMethod ().AddOrUpdataSceneBaseMassage (room.RoomFilePath);
                        });
                    }
                } else {
                    TargetList.AddRange (localEquipments);
                }
                for (int i = 0; i < TargetList.Count;) {
                    var taget = TargetList [i];
                    var tacount = TargetList.FindAll ((obj) => obj == taget).Count;
                    if (tacount == 1) {
                        i++;
                    }
                    while (tacount > 1) {
                        TargetList.Remove (taget);
                        tacount--;
                    }
                }
 
                foreach (string filePath in TargetList) {
                    try {
                        string [] str = filePath.Split ('_');
                        if (selectedDeviceType != null && selectedDeviceType != "Scene" && selectedDeviceType != "All") {
                            //只显示当前选择的设备类型的设备
                            if (selectedDeviceType == "EC") {
                                if (str [1].Contains (DeviceType.LightSwitch.ToString ())) {
                                    var b = IO.FileUtils.ReadFile (filePath);
                                    LightSwitch c = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (b));
                                    if (!c.IsSocket) {
                                        continue;
                                    }
                                } else
                                    continue;
                            } else {
                                if (!str [1].Contains (selectedDeviceType)) {
                                    continue;
                                }
                            }
                        }
                        var commonBytes = IO.FileUtils.ReadFile (filePath);
                        if (commonBytes.Length == 0) {
                            Console.WriteLine ("length loss");
                            continue;
                        }
                        if (commonBytes.Length == 1) {
                            Console.WriteLine ("length loss 1");
                            continue;
                        }
                        if (str [1] == DeviceType.InfraredMode.ToString ()) {
                            InfraredMode c = Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (filePath)));
                            if (c.InfraredType != InfraredType.TV) {
                                continue;
                            }
                        }
                        var deviceFilePath = filePath;
                        if (deviceFilePath.Contains ("LightEnergySocket")) {
                            deviceFilePath = deviceFilePath.Replace ("LightEnergySocket", "LightSwitch");
                        } else if (deviceFilePath.Contains ("LightEnergySwitch")) {
                            deviceFilePath = deviceFilePath.Replace ("LightEnergySwitch", "LightSwitch");
                        } else if (deviceFilePath.Contains ("LightSwitchSocket")) {
                            deviceFilePath = deviceFilePath.Replace ("LightSwitchSocket", "LightSwitch");
                        } else if(deviceFilePath.Contains("ACInfrared")) {
                            deviceFilePath = deviceFilePath.Replace ("ACInfrared", "HVAC");
                        }
                        Common commonDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (commonBytes));
                        if (commonDevice.Type == DeviceType.OnePortBus || commonDevice.Type == DeviceType.OnePortWirelessFR || commonDevice.Type == DeviceType.RCU
                            || commonDevice.Type == DeviceType.A31MusicModel || commonDevice.Type == DeviceType.MusicA31) {
                            continue;
                        }
                        Application.RunOnMainThread (() => {
                            var deviceRow = new RowLayout () {
                                Height = Application.GetRealHeight (120),
                            };
                            deviceScrolView.AddChidren (deviceRow);
 
                            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,
                            };
                            deviceRow.AddChidren (btnPoint);
 
                            Button btnEquipment = new Button () {
                                X = btnPoint.Right + Application.GetRealWidth (30),
                                Width = Application.GetRealWidth (310),
                                TextAlignment = TextAlignment.CenterLeft,
                                SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
                                SelectedTextColor = SkinStyle.Current.DialogTextColor,
                                TextColor = SkinStyle.Current.TextColor1,
                                Text = commonDevice.Name,
                                Tag = filePath,
                            };
                            deviceRow.AddChidren (btnEquipment);
 
                            Button btnFindDevcie = new Button () {
                                X = btnEquipment.Right,
                                Width = Application.GetRealWidth (75),
                                Height = Application.GetRealHeight (72),
                                Gravity = Gravity.CenterVertical,
                                UnSelectedImagePath = "CrabtreeAdd/Position.png",
                                SelectedImagePath = "CrabtreeAdd/PositionOn.png",
                            };
                            deviceRow.AddChidren (btnFindDevcie);                        
 
                            btnFindDevcie.MouseUpEventHandler += (sdd, dds) => {
                                btnFindDevcie.IsSelected = true;
                                Control.ControlBytesSend (Command.PositioningEquipment, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { 5 });
                                System.Threading.Tasks.Task.Run (() => {
                                    System.Threading.Thread.Sleep (3000);
                                    Application.RunOnMainThread (() => {
                                        btnFindDevcie.IsSelected = false;
                                    });
                                });
                            };
 
                            if (selectedDeviceType != "Scene") {
                                var btnEdit = new Button () {
                                    X = btnEquipment.Right + Application.GetRealWidth (80),
                                    Width = Application.GetRealWidth (75),
                                    Height = Application.GetRealHeight (72),
                                    Gravity = Gravity.CenterVertical,
                                    UnSelectedImagePath = "CrabtreeAdd/Edit.png",
                                    SelectedImagePath = "CrabtreeAdd/EditOn.png",
                                };
                                deviceRow.AddChidren (btnEdit);
                                btnEdit.MouseUpEventHandler += (sd, ds) => {
                                    Dialog dialog = new Dialog ();
 
                                    var dialogView = new FrameLayout () {
                                        Gravity = Gravity.Center,
                                        Width = Application.GetRealWidth (500),
                                        Height = Application.GetRealHeight (300),
                                        BackgroundColor = SkinStyle.Current.DialogColor,
                                        Radius = 5,
                                        BorderColor = SkinStyle.Current.Transparent,
                                        BorderWidth = 1,
                                    };
                                    dialog.AddChidren (dialogView);
 
                                    var etDeviceName = new EditText () {
                                        Y = Application.GetRealHeight (80),
                                        Gravity = Gravity.CenterHorizontal,
                                        Width = Application.GetRealWidth (350),
                                        Height = Application.GetRealHeight (70),
                                        Text = commonDevice.Name,
                                        TextAlignment = TextAlignment.Center,
                                        TextColor = SkinStyle.Current.TextColor,
                                        Radius = 1,
                                        BorderWidth = 1,
                                        BorderColor = SkinStyle.Current.BorderColor,
                                    };
                                    dialogView.AddChidren (etDeviceName);
 
                                    etDeviceName.EditorEnterAction += (obj2) => {
                                        Application.HideSoftInput ();
                                    };
 
                                    var dialogBottomView = new FrameLayout () {
                                        Y = Application.GetRealHeight (213),
                                        Height = Application.GetRealHeight (90),
                                        BackgroundColor = SkinStyle.Current.Black50Transparent,
                                    };
                                    dialogView.AddChidren (dialogBottomView);
 
                                    var btnClose = new Button () {
                                        Width = Application.GetRealWidth (250),
                                        TextAlignment = TextAlignment.Center,
                                        TextID = R.MyInternationalizationString.cancel,
                                        TextColor = SkinStyle.Current.TextColor,
                                        BackgroundColor = SkinStyle.Current.ButtonColor,
                                    };
                                    dialogBottomView.AddChidren (btnClose);
                                    btnClose.MouseUpEventHandler += (ddss, dddsss) => {
                                        dialog.Close ();
                                    };
 
                                    var editor = new Button () {
                                        X = btnClose.Right + 1,
                                        Width = Application.GetRealWidth (250),
                                        TextAlignment = TextAlignment.Center,
                                        TextID = R.MyInternationalizationString.SAVE,
                                        TextColor = SkinStyle.Current.TextColor,
                                        BackgroundColor = SkinStyle.Current.ButtonColor,
                                    };
                                    dialogBottomView.AddChidren (editor);
 
                                    editor.MouseUpEventHandler += (dff, ffd) => {
                                        MainPage.Loading.Start ();
                                        byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (etDeviceName.Text.Trim ());
                                        System.Threading.Tasks.Task.Run (() => {
                                            byte [] updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { commonDevice.BigClass, commonDevice.MinClass, commonDevice.LoopID });
                                            if (updateBytes == null) {
                                                Application.RunOnMainThread (() => {
                                                    new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                                                    MainPage.Loading.Hide ();
                                                    dialog.Close ();
                                                });
                                                return;
                                            }
                                            byte [] uBytes = new byte [20];
                                            Array.Copy (remakeBytes, 0, uBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20);
                                            Array.Copy (uBytes, 0, updateBytes, 3, 20 < uBytes.Length ? 20 : uBytes.Length);
                                            var reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, updateBytes);
                                            if (reBytes != null) {
                                                Application.RunOnMainThread (() => {
                                                    btnEquipment.Text = commonDevice.Name = etDeviceName.Text.Trim ();
                                                    IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ());
                                                    MainPage.Loading.Hide ();
                                                    dialog.Close ();
                                                });
                                            } else {
                                                Application.RunOnMainThread (() => {
                                                    new Alert ("", Language.StringByID (R.MyInternationalizationString.FailureToModify), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                                                    MainPage.Loading.Hide ();
                                                    dialog.Close ();
                                                });
                                            }
                                        });
                                    };
 
                                    dialog.Show ();
                                };
                            }
                            var btnChoose = new Button () {
                                X = Application.GetRealWidth (472 + 80),
                                Width = Application.GetRealWidth (75),
                                Height = Application.GetRealHeight (72),
                                Gravity = Gravity.CenterVertical,
                                UnSelectedImagePath = "CrabtreeAdd/Choose.png",
                                SelectedImagePath = "CrabtreeAdd/ChooseOn.png",
                                IsSelected = showList.Contains (deviceFilePath),
                                Tag = filePath
                            };
                            btnChoose.AddTag ("DeviceFilePath", deviceFilePath);
                            deviceRow.AddChidren (btnChoose);
 
                            btnChoose.MouseUpEventHandler += (sendere, ee) => {
                                btnChoose.IsSelected = !btnChoose.IsSelected;
                                if (btnChoose.IsSelected) {
                                    if (selectedDeviceType == "Scene") {
                                        roomSceneFilePathList.Add (((Button)sendere).Tag.ToString ());
                                    } else {
                                        roomDeviceFilePathList.Add (((Button)sendere).Tag.ToString ());
                                    }
                                    showList.Add (((Button)sendere).Tag.ToString ());
                                } else {
                                    if (selectedDeviceType == "Scene") {
                                        roomSceneFilePathList.Remove (((Button)sendere).Tag.ToString ());
                                    } else {
                                        roomDeviceFilePathList.Remove (((Button)sendere).GetTagByKey ("DeviceFilePath").ToString ());
                                        roomDeviceFilePathList.Remove (((Button)sendere).Tag.ToString ());
                                    }
                                    showList.Remove (((Button)sendere).Tag.ToString ());
                                }
                            };
                        });
                    } catch (Exception ex) {
                        Console.WriteLine (ex.Message);
                    }
                }
            });
        }
      
        void InitEquipmentTypeView (Button btnEquipmentType, Button btnEquipmentIcon, RowLayout chooseTypeView)
        {
            bodyView.AddChidren (typeLayout);
 
            //下拉列表的数据源(选项为设备类型有关)
            List<string> typeTemp = new List<string>{
                    Language.StringByID(R.MyInternationalizationString.All),
                    Language.StringByID(R.MyInternationalizationString.Scenes),
                    Language.StringByID(R.MyInternationalizationString.Lights),
                    Language.StringByID(R.MyInternationalizationString.AC),
                    Language.StringByID(R.MyInternationalizationString.Curtains),
                    //Language.StringByID(R.MyInternationalizationString.FoolHeat),
                    //Language.StringByID(R.MyInternationalizationString.FreshAir),
                    //Language.StringByID(R.MyInternationalizationString.TV),
                    Language.StringByID(R.MyInternationalizationString.Fan),
                    //Language.StringByID (R.MyInternationalizationString.Security),
                    //Language.StringByID (R.MyInternationalizationString.LogicModule),
                    //Language.StringByID(R.MyInternationalizationString.ElectricalControl),
                    //Language.StringByID (R.MyInternationalizationString.MusicModel),
                    Language.StringByID (R.MyInternationalizationString.UniversalDevice),
                    //Language.StringByID (R.MyInternationalizationString.Sensor),
                };
 
            foreach (string typeName in typeTemp) {
                var dialogRow = new RowLayout () {
                    Height = Application.GetRealHeight (110),
                };
                typeLayout.AddChidren (dialogRow);
                var btnPoint = new Button () {
                    Width = Application.GetMinRealAverage (10),
                    Height = Application.GetMinRealAverage (10),
                    Radius = (uint)Application.GetMinRealAverage (5),
                    X = Application.GetRealWidth (70),
                    Gravity = Gravity.CenterVertical,
                    BackgroundColor = SkinStyle.Current.TextColor1,
                    SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
                };
                dialogRow.AddChidren (btnPoint);
 
                Button btnTypeName = new Button () {
                    Width = Application.GetRealHeight (400),
                    X = btnPoint.Right + Application.GetRealWidth (30),
                    Text = typeName,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = SkinStyle.Current.TextColor1
                };
                dialogRow.AddChidren (btnTypeName);
                EventHandler<MouseEventArgs> typeEvent = (sender1, e1) => {
                    typeLayout.Height = 0;
                    btnEquipmentType.Text = typeName;
                    if (typeName == Language.StringByID (R.MyInternationalizationString.Lights)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Item/Light.png";
                        selectedDeviceType = "Light";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.Curtains)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Curtain/Curtain.png";
                        selectedDeviceType = "Curtain";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.AC)) {
                        btnEquipmentIcon.UnSelectedImagePath = "AC/AC.png";
                        selectedDeviceType = "AC";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.FoolHeat)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Item/FloorHeating.png";
                        selectedDeviceType = "FoolHeat";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.DryContactPanel)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Item/DryContact.png";
                        selectedDeviceType = "DryContact";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.MusicModel)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Item/Music.png";
                        selectedDeviceType = "Music";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.InfraredMode)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Item/InfraredTV.png";
                        selectedDeviceType = "InfraredMode";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.TV)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Item/InfraredTV.png";
                        selectedDeviceType = "InfraredMode";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.ElectricalControl)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Light/Socket.png";
                        selectedDeviceType = "EC";//电器控制
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.Fan)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Fan/Fan.png";
                        selectedDeviceType = "Fan";
                        //} else if (typeName == Language.StringByID (R.MyInternationalizationString.LogicModule)) {
                        //    btnEquipmentIcon.UnSelectedImagePath = "Item/PointBig.png";
                        //    selectedDeviceType = "LogicModule";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.Scenes)) {
                        btnEquipmentIcon.UnSelectedImagePath = "Scene/Scene.png";
                        selectedDeviceType = "Scene";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.UniversalDevice)) {
                        btnEquipmentIcon.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
                        selectedDeviceType = "UniversalDevice";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.Sensor)) {
                        btnEquipmentIcon.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
                        selectedDeviceType = "Sensor";
                    } else if (typeName == Language.StringByID (R.MyInternationalizationString.FreshAir)) {
                        btnEquipmentIcon.UnSelectedImagePath = "FreshAir/FreshAir.png";
                        selectedDeviceType = "FreshAir";
                    } else {
                        btnEquipmentIcon.UnSelectedImagePath = "Item/LogicModule.png";
                        selectedDeviceType = "All";
                    }
                    chooseTypeView.BackgroundColor = SkinStyle.Current.ViewColor;
                    InitDeviceList ();
                };
                dialogRow.MouseUpEventHandler += typeEvent;
                btnTypeName.MouseUpEventHandler += typeEvent;
            }
        }
    }
}