wxr
2020-09-09 c3e1b733fc45bd9f0b88bfb560cfa87a270b079b
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
using System;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
using System.Collections.Generic;
 
namespace HDL_ON.UI
{
    public partial class SceneFunctionListEditPage : FrameLayout
    {
        FrameLayout bodyView;
 
        FrameLayout showdFunctionTypeRow;
 
        /// <summary>
        /// 楼层选择下拉图标
        /// </summary>
        Button btnFloorDownIcon;
        /// <summary>
        /// 楼层显示
        /// </summary>
        Button btnFloor;
 
        /// <summary>
        /// 筛选选择下拉图标
        /// </summary>
        Button btnScreenIcon;
        /// <summary>
        /// 筛选文本显示
        /// </summary>
        Button btnScreenText;
        /// <summary>
        /// 筛选条件1
        /// </summary>
        string screen1;
        /// <summary>
        /// 筛选条件2
        /// </summary>
        string screen2;
 
        VerticalScrolViewLayout functionListView;
 
        List<Function> allocatedList;
        List<Function> unallocatedList;
 
        Scene scene;
        Action refreshAction;
        public SceneFunctionListEditPage(Scene function,Action action)
        {
            bodyView = this;
            scene = function;
            allocatedList = new List<Function>();
            unallocatedList = new List<Function>();
            refreshAction = () =>
            {
                this.RemoveFromParent();
                action();
            };
        }
 
 
        /// <summary>
        /// 加载界面
        /// </summary>
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, Language.StringByID(StringId.AddFunction)).LoadTopView();
            //new PublicAssmebly().LoadTopView(bodyView, Language.StringByID(StringId.AddFunction));
 
            #region 显示的功能类型切换区域
            showdFunctionTypeRow = new FrameLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(62),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(showdFunctionTypeRow);
 
          
            btnFloorDownIcon = new Button()
            {
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(18),
                UnSelectedImagePath = "Public/DownIcon.png",
            };
            showdFunctionTypeRow.AddChidren(btnFloorDownIcon);
         
            btnFloor = new Button()
            {
                X = btnFloorDownIcon.Right,
                Y = Application.GetRealHeight(18),
                Width = Application.GetRealWidth(200),
                Height = Application.GetMinRealAverage(16),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextAlignment = TextAlignment.CenterLeft,
                Text = OnAppConfig.Instance.CurFoor,
            };
            showdFunctionTypeRow.AddChidren(btnFloor);
 
 
            btnScreenIcon = new Button()
            {
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                X = Application.GetRealWidth(122),
                Y = Application.GetRealHeight(18),
                UnSelectedImagePath = "Public/DownIcon.png",
            };
            showdFunctionTypeRow.AddChidren(btnScreenIcon);
 
            btnScreenText = new Button()
            {
                X = btnScreenIcon.Right,
                Y = Application.GetRealHeight(18),
                Width = Application.GetRealWidth(200),
                Height = Application.GetMinRealAverage(16),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = StringId.Screen
            };
            showdFunctionTypeRow.AddChidren(btnScreenText);
 
 
            #endregion
 
            functionListView = new VerticalScrolViewLayout()
            {
                Y = showdFunctionTypeRow.Bottom,
                Height = Application.GetRealHeight(530),
                BackgroundColor = CSS_Color.BackgroundColor,
            };
            bodyView.AddChidren(functionListView);
 
            foreach (var function in DB_ResidenceData.functionList.GetAllDeviceFunctionList())
            {
                if (function == null)
                {
                    continue;
                }
                function.roomIdList.Remove(null);
                if (scene.sceneFunctionList.Find((obj) => obj.sid == function.sid) != null)
                {
                    allocatedList.Add(function);
                }
                else
                {
                    unallocatedList.Add(function);
                }
            }
 
            LoadFunctionListRow();
 
            LoadEventList();
        }
 
        /// <summary>
        /// 显示功能Row
        /// </summary>
        /// <param name="showUnallocated">是否是显示未分配</param>
        void LoadFunctionListRow()
        {
            functionListView.RemoveAll();
            List<Function> functions = new List<Function>();
            functions.AddRange(unallocatedList);
            functions.AddRange(allocatedList);
            foreach (var function in functions)
            {
                if (function.functionCategory != FunctionCategory.Light &&
                    function.functionCategory != FunctionCategory.Thermostat &&
                    function.functionCategory != FunctionCategory.Curtain
                    )
                {
                    continue;
                }
                //按楼层筛选
                if (!string.IsNullOrEmpty(screen1))
                {
                    if (!function.roomIdList.Contains(screen1))
                    {
                        continue;
                    }
                }
                //按类型筛选
                if (!string.IsNullOrEmpty(screen2))
                {
                    //if (!function.functionType!= screen2)
                    //{
                    //    continue;
                    //}
                }
                functionListView.AddChidren(new Button()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth(343),
                    Height = Application.GetRealWidth(1),
                    BackgroundColor = CSS_Color.DividingLineColor,
                });
 
                FrameLayout functionRow = new FrameLayout()
                {
                    Height = Application.GetRealHeight(50),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                };
                functionListView.AddChidren(functionRow);
 
                if (allocatedList.Contains(function))
                {
                    var btnTipAdded = new Button()
                    {
                        Width = Application.GetRealWidth(327),
                        TextAlignment = TextAlignment.CenterRight,
                        TextColor = CSS_Color.MainColor,
                        TextSize = CSS_FontSize.TextFontSize,
                        TextID = StringId.Added
                    };
                    functionRow.AddChidren(btnTipAdded);
                }
 
                var btnFunctionIcon = new Button()
                {
                    X = Application.GetRealWidth(12),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetMinRealAverage(28),
                    Height = Application.GetMinRealAverage(28),
                };
                functionRow.AddChidren(btnFunctionIcon);
                switch (function.functionCategory)
                {
                    case FunctionCategory.Thermostat:
                        switch (function.functionType)
                        {
                            case FunctionType.AC:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
                                break;
                            case FunctionType.FloorHeating:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
                                break;
                        }
                        break;
                    case FunctionCategory.Curtain:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
                        break;
                    case FunctionCategory.Light:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png";
                        break;
                    case FunctionCategory.SwitchDevice:
                        switch (function.functionType)
                        {
                            case FunctionType.Socket:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png";
                                break;
                        }
                        break;
                    case FunctionCategory.Electrical:
                        switch (function.functionType)
                        {
                            case FunctionType.Fan:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png";
                                break;
                            case FunctionType.TV:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png";
                                break;
                        }
                        break;
                    case FunctionCategory.Scene:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
                        break;
                    case FunctionCategory.Music:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png";
                        break;
                }
 
                var btnFunctionName = new Button()
                {
                    X = btnFunctionIcon.Right + Application.GetRealWidth(12),
                    Width = Application.GetRealWidth(200),
                    Height = Application.GetRealHeight(40),
                    Text = function.name,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                };
                functionRow.AddChidren(btnFunctionName);
 
                var btnFunctionFloorName = new Button()
                {
                    X = btnFunctionIcon.Right + Application.GetRealWidth(12),
                    Y = Application.GetRealHeight(30),
                    Width = Application.GetRealWidth(200),
                    Height = Application.GetRealHeight(20),
                    Text = function.GetRoomListName(),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                };
                functionRow.AddChidren(btnFunctionFloorName);
 
                Button btnChooseIcon = new Button()
                {
                    X = Application.GetRealWidth(339),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetMinRealAverage(16),
                    Height = Application.GetMinRealAverage(16),
                    UnSelectedImagePath = "Public/Right.png",
                };
                functionRow.AddChidren(btnChooseIcon);
                LoadEvent_SkipEditFunctionInfo(functionRow, btnFunctionFloorName, btnChooseIcon, btnFunctionName, function);
            }
 
        }
 
 
        /// <summary>
        /// 住宅列表点击事件
        /// </summary>
        void LoadDialog_ChangeFloor()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                var dialog = new Dialog();
                var dialogBody = new FrameLayout();
                dialog.AddChidren(dialogBody);
                dialogBody.MouseUpEventHandler += (sender1, e1) => {
                    dialog.Close();
                };
 
                var dispalyView = new FrameLayout()
                {
                    X = Application.GetRealWidth(10),
                    Y = Application.GetRealHeight(100),
                    Width = Application.GetRealWidth(160),
                    Height = Application.GetRealHeight(110),
                    BackgroundImagePath = "PersonalCenter/HomeList1bg.png",
                };
                dialogBody.AddChidren(dispalyView);
 
                var contentView = new VerticalScrolViewLayout()
                {
                    X = Application.GetRealWidth(8),
                    Y = Application.GetRealHeight(15),
                    Width = Application.GetRealWidth(150),
                    Height = Application.GetRealHeight(45 * 2),
                    ScrollEnabled = false
                };
                dispalyView.AddChidren(contentView);
 
                if (DB_ResidenceData.residenceData.floors.Count < 2)
                {
                }
                else if (DB_ResidenceData.residenceData.floors.Count < 3)
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(100),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(155),
                        BackgroundImagePath = "PersonalCenter/HomeList2bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
 
                    contentView.Height = Application.GetRealHeight(45 * 3);
                    dispalyView.AddChidren(contentView);
                }
                else if (DB_ResidenceData.residenceData.floors.Count < 4)
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(100),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(200),
                        BackgroundImagePath = "PersonalCenter/HomeList3bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
 
                    contentView.Height = Application.GetRealHeight(45 * 4);
                    dispalyView.AddChidren(contentView);
                }
                else
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(100),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(245),
                        BackgroundImagePath = "PersonalCenter/HomeList4bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
 
                    contentView.Height = Application.GetRealHeight(45 * 5);
                    contentView.ScrollEnabled = true;
                    dispalyView.AddChidren(contentView);
                }
 
 
                List<string> chooseList = new List<string>();
                chooseList.Add(Language.StringByID(StringId.All));
                foreach (var f in DB_ResidenceData.residenceData.floors)
                {
                    chooseList.Add(f.name);
                }
 
                foreach (var floor in chooseList)
                {
                    if (floor != Language.StringByID(StringId.All))
                    {
                        contentView.AddChidren(new Button()
                        {
                            Gravity = Gravity.CenterHorizontal,
                            Width = Application.GetRealWidth(112),
                            Height = Application.GetRealHeight(1),
                            BackgroundColor = CSS.CSS_Color.BackgroundColor
                        });
                    }
                    var btnHomeName = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(112),
                        Height = Application.GetRealHeight(44),
                        TextAlignment = TextAlignment.CenterLeft,
                        TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                        SelectedTextColor = CSS.CSS_Color.MainColor,
                        Text = floor,
                        TextSize = CSS.CSS_FontSize.SubheadingFontSize,
                        IsSelected = btnFloor.Text == floor,
                        IsMoreLines = true,
                        Tag = floor
                    };
                    contentView.AddChidren(btnHomeName);
 
                    btnHomeName.MouseUpEventHandler += (senderH, en) =>
                    {
                        dialog.Close();
                        btnFloor.Text = floor;
                    };
                }
 
                dialog.Show();
            };
 
            btnFloor.MouseUpEventHandler = eventHandler;
            btnFloorDownIcon.MouseUpEventHandler = eventHandler;
        }
 
    }
 
    //---------------------------------------
    public partial class SceneFunctionListEditPage
    {
 
        void LoadEventList()
        {
            LoadDialog_ChangeFloor();
        }
 
        void LoadEvent_SkipEditFunctionInfo(FrameLayout view, Button btn1, Button btn2, Button btn3, Function function)
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                var ssf = new SceneFunctionInfoEditPage(scene, function, refreshAction);
                MainPage.BasePageView.AddChidren(ssf);
                ssf.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            view.MouseUpEventHandler = eventHandler;
            btn1.MouseUpEventHandler = eventHandler;
            btn2.MouseUpEventHandler = eventHandler;
            btn3.MouseUpEventHandler = eventHandler;
 
        }
    }
}