wxr
2020-09-10 af1cb3ecd0f4b0589e00b28f7f9edccf39e6e12b
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
using System;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
 
namespace HDL_ON.UI 
{
    public partial class IntelligencePage : FrameLayout
    {
        FrameLayout bodyView;
        /// <summary>
        /// 场景/自动化分页区域
        /// </summary>
        PageLayout contentPageView;
        #region 场景区域
        FrameLayout scenePageView;
        /// <summary>
        /// 场景内容显示区域
        /// </summary>
        FrameLayout floorChangeView;
        #region 场景底部切换显示区域
        /// <summary>
        /// 场景区域,顶部区域
        /// </summary>
        FrameLayout sceneTopView;
        /// <summary>
        /// 楼层选择下拉图标
        /// </summary>
        Button btnFloorDownIcon;
        /// <summary>
        /// 楼层显示
        /// </summary>
        Button btnFloor;
        /// <summary>
        /// 添加场景按钮
        /// </summary>
        Button btnAddIcon;
 
        #endregion
        /// <summary>
        /// 场景功能控制区域
        /// </summary>
        VerticalScrolViewLayout sceneFunctionView;
        #endregion
 
        public IntelligencePage()
        {
            bodyView = this;
        }
 
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
            #region top
            FrameLayout topView = new FrameLayout()
            {
                Height = Application.GetRealHeight(64),
                BackgroundColor = CSS_Color.TopViewColor,
            };
            bodyView.AddChidren(topView);
 
            Button btnSceneTilte = new Button()
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(170),
                Height = Application.GetRealHeight(25),
                TextAlignment = TextAlignment.CenterRight,
                TextSize = CSS_FontSize.HeadlineFontSize,
                TextColor = CSS_Color.PromptingColor1,
                SelectedTextColor = CSS_Color.MainColor,
                TextID = StringId.Scenes,
                IsSelected = true
            };
            topView.AddChidren(btnSceneTilte);
 
            Button btnAutomationTitle = new Button()
            {
                X = Application.GetRealWidth(209),
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(170),
                Height = Application.GetRealHeight(25),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.PromptingColor1,
                SelectedTextColor = CSS_Color.MainColor,
                TextID = StringId.Automation,
            };
            topView.AddChidren(btnAutomationTitle);
 
            btnAddIcon = new Button()
            {
                X = Application.GetRealWidth(337),
                Y = Application.GetRealHeight(29),
                Width = Application.GetMinRealAverage(28),
                Height = Application.GetMinRealAverage(28),
                UnSelectedImagePath = "Public/AddIcon.png",
            };
            topView.AddChidren(btnAddIcon);
            #endregion
 
            contentPageView = new PageLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(667 - 64 - 49 + 30),
                BackgroundColor = CSS_Color.BackgroundColor,
                IsShowPoint = false
            };
            bodyView.AddChidren(contentPageView);
 
            LoadScenePageView();
            //LoadFunctionPageView();
            LoadEventList();
        }
        /// <summary>
        /// 加载场景列表界面
        /// </summary>
        void LoadScenePageView()
        {
            scenePageView = new FrameLayout();
            contentPageView.AddChidren(scenePageView);
            /// <summary>
            /// 场景内容显示区域
            /// </summary>
            floorChangeView = new FrameLayout()
            {
                Height = Application.GetRealHeight(52),
            };
            scenePageView.AddChidren(floorChangeView);
            #region 场景底部切换显示区域
            /// <summary>
            /// 场景区域,顶部区域
            /// </summary>
            sceneTopView = new FrameLayout()
            {
                Height = Application.GetRealHeight(53),
            };
            floorChangeView.AddChidren(sceneTopView);
            /// <summary>
            /// 楼层选择下拉图标
            /// </summary>
            btnFloorDownIcon = new Button()
            {
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(18),
                UnSelectedImagePath = "Public/DownIcon.png",
            };
            floorChangeView.AddChidren(btnFloorDownIcon);
            /// <summary>
            /// 楼层显示
            /// </summary>
            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,
            };
            floorChangeView.AddChidren(btnFloor);
 
            #endregion
 
            sceneFunctionView = new VerticalScrolViewLayout() {
                Y = floorChangeView.Bottom,
                Height = Application.GetRealHeight(667 - 64 - 49 - 52 + 30),
            };
            scenePageView.AddChidren(sceneFunctionView);
            LoadSceneFunctionControlZone();
        }
 
        /// <summary>
        /// 加载场景功能显示区域
        /// </summary>
        void LoadSceneFunctionControlZone()
        {
            sceneFunctionView.RemoveAll();
            var rowView = new FrameLayout();
            try
            {
                int index = 0;
                foreach (var function in DB_ResidenceData.functionList.scenes)
                {
                    if (function.roomIdList.Count == 0)//如何在房间已经移除了这个功能,则收藏界面也不会再显示
                    {
                        function.collection = false;
                        continue;
                    }
                    if (index % 2 == 0)
                    {
                        sceneFunctionView.AddChidren(new Button() { Height = Application.GetRealHeight(7) });
                        rowView = new FrameLayout()
                        {
                            Height = Application.GetRealWidth(122),
                        };
                        sceneFunctionView.AddChidren(rowView);
                        sceneFunctionView.AddChidren(new Button() { Height = Application.GetRealHeight(7) });
                    }
                    var functionView_X = Application.GetRealWidth((16 + 164) * (index % 2) + 16);
 
                    var functionView = new FrameLayout()
                    {
                        X = functionView_X,
                        Width = Application.GetRealWidth(164),
                        Height = Application.GetRealWidth(122),
                        Tag = function.sid,
                        BackgroundImagePath = (function as Scene).ImagePath,
                    };
                    rowView.AddChidren(functionView);
 
                    LoadSceneFunctionDiv(functionView, function);
                    index++;
                }
 
                if (index == 0)
                {
                    var view = new FrameLayout();
                    sceneFunctionView.AddChidren(view);
 
                    var btnNoCollectionBg = new Button()
                    {
                        Y = Application.GetRealHeight(120),
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(180),
                        Height = Application.GetRealWidth(180),
                        UnSelectedImagePath = "Collection/NoCollectionBg.png",
                    };
                    view.AddChidren(btnNoCollectionBg);
 
                    var btnNoCollectionTip = new Button()
                    {
                        Height = Application.GetRealHeight(42),
                        Y = btnNoCollectionBg.Bottom,
                        TextAlignment = TextAlignment.Center,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                        TextID = StringId.TipNoScene,
                    };
                    view.AddChidren(btnNoCollectionTip);
                }
            }
            catch (Exception ex)
            {
                MainPage.Log("homepage erorr : " + ex.Message);
            }
            sceneFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
 
        }
 
        /// <summary>
        /// 加载场景控制卡片
        /// </summary>
        void LoadSceneFunctionDiv(FrameLayout view, Function function)
        {
            try
            {
                Button btnCoverd = new Button()
                {
                    UnSelectedImagePath = "Collection/SceneCovered.png",
                };
                view.AddChidren(btnCoverd);
 
                Button btnName;
                btnName = new Button()
                {
                    X = Application.GetRealWidth(12),
                    Y = Application.GetRealWidth(68),
                    Width = Application.GetRealWidth(150),
                    Height = Application.GetRealHeight(24),
                    Text = function.name,
                    TextSize = CSS_FontSize.TextFontSize,
                    TextColor = CSS_Color.MainBackgroundColor,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                view.AddChidren(btnName);
 
                Button btnZone;
                btnZone = new Button()
                {
                    X = Application.GetRealWidth(12),
                    Y = btnName.Bottom,
                    Height = Application.GetRealWidth(18),
                    Width = Application.GetRealWidth(113),
                    TextColor = CSS_Color.MainBackgroundColor,
                    TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                    TextAlignment = TextAlignment.CenterLeft,
                    SelectedTextColor = CSS_Color.MainBackgroundColor,
                    Text = function.GetRoomListName(),
                };
                view.AddChidren(btnZone);
 
 
                Button btnSettingIcon;
                btnSettingIcon = new Button()
                {
                    X = Application.GetRealWidth(4),
                    Y = Application.GetRealWidth(4),
                    Height = Application.GetRealWidth(32),
                    Width = Application.GetRealWidth(32),
                    UnSelectedImagePath = "Public/FuncInfoSetIcon_white.png",
                };
                view.AddChidren(btnSettingIcon);
 
                Button btnCollection;
                btnCollection = new Button()
                {
                    X = Application.GetRealWidth(116),
                    Y = Application.GetRealWidth(8),
                    Width = Application.GetMinRealAverage(32),
                    Height = Application.GetMinRealAverage(32),
                    UnSelectedImagePath = "Collection/CollectionWhiteIcon.png",
                    SelectedImagePath = "Collection/CollectionIcon.png",
                    IsSelected = function.collection,
                };
                view.AddChidren(btnCollection);
                btnCollection.MouseUpEventHandler = (sender, e) => {
                    function.collection = btnCollection.IsSelected = !btnCollection.IsSelected;
                    function.SaveFunctionData();
                };
                LoadEvent_ControlScene(btnCoverd,btnName,btnZone, function);
                btnSettingIcon.MouseUpEventHandler = (sender, e) => {
                    Action backAction = () => {
                        LoadSceneFunctionControlZone();
                    };
                    Action refreshAction = () => {
                        btnName.Text = function.name;
                        btnZone.Text = function.GetRoomListName();
                        view.BackgroundImagePath = (function as Scene).ImagePath;
                    };
                    var aep = new SceneEditPage(function as Scene, backAction);
                    MainPage.BasePageView.AddChidren(aep);
                    aep.LoadPage(StringId.EditScene, refreshAction);
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
            }
            catch (Exception ex)
            {
                MainPage.Log("homepage LoadControlView error : " + ex.Message);
            }
        }
 
    }
 
 
    //-------------
    public partial class IntelligencePage
    {
        void LoadEventList()
        {
            LoadEvent_SkipAddScenePage();
        }
        /// <summary>
        /// 跳转至添加场景的界面
        /// </summary>
        void LoadEvent_SkipAddScenePage()
        {
            btnAddIcon.MouseUpEventHandler = (sender, e) =>
            {
                Action action = () => {
                    LoadSceneFunctionControlZone();
                };
                var aep = new NewSceneMenuListPage(action);
                MainPage.BasePageView.AddChidren(aep);
                aep.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
        }
 
 
        /// <summary>
        /// 加载场景控制事件
        /// </summary>
        void LoadEvent_ControlScene(Button btnCoverd, Button btnName, Button btnZone, Function function)
        {
 
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                string msg = function.name + Language.StringByID(StringId.AlreadyOpened);
                new PublicAssmebly().TipMsgAutoClose(msg, true);
                Control.Send(function);
            };
            btnCoverd.MouseUpEventHandler = eventHandler;
            btnName.MouseUpEventHandler = eventHandler;
            btnZone.MouseUpEventHandler = eventHandler;
        }
    }
 
}