wei
2021-02-23 0f5d7d18f98d6d961b3d21dc2b1b59905e261fff
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
using System;
using System.Collections.Generic;
using System.Linq;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
    public partial class FunctionPage : FrameLayout
    {
        #region 控件列表
        /// <summary>
        /// 当前窗体
        /// </summary>
        static FrameLayout bodyView;
        /// <summary>
        /// 楼层选择下拉图标
        /// </summary>
        Button btnFloorDownIcon;
        /// <summary>
        /// 楼层显示
        /// </summary>
        Button btnFloor;
        /// <summary>
        /// 功能列表集合显示区域
        /// </summary>
        static VerticalScrolViewLayout functionListView;
        #endregion
 
        List<Function> functionList;
 
        public FunctionPage()
        {
            bodyView = this;
            functionList = new List<Function>();
        }
 
        public void LoadPage(int titleId)
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView();
 
            /// <summary>
            /// 房间内容显示区域
            /// </summary>
            var roomFloorChangeView = new FrameLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(52),
            };
            bodyView.AddChidren(roomFloorChangeView);
            #region 房间顶部切换显示区域
            btnFloorDownIcon = new Button()
            {
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(18),
                UnSelectedImagePath = "Public/DownIcon.png",
            };
            roomFloorChangeView.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 = DB_ResidenceData.Instance.CurFloor.roomName,
            };
            roomFloorChangeView.AddChidren(btnFloor);
            #endregion
 
            functionListView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64 + 52),
                Height = Application.GetRealHeight(603 - 12 - 52),
            };
            bodyView.AddChidren(functionListView);
 
            if (titleId == StringId.Lights)
            {
                functionList.AddRange(FunctionList.List.lights);
            }
            else if (titleId == StringId.AC)
            {
                functionList.AddRange(FunctionList.List.aCs);
            }
            else if (titleId == StringId.Curtain)
            {
                functionList.AddRange(FunctionList.List.curtains);
            }
            else if (titleId == StringId.FloorHeating)
            {
                functionList.AddRange(FunctionList.List.floorHeatings);
            }
            else if (titleId == StringId.Electric)
            {
                functionList.AddRange(FunctionList.List.electricals);
            }
            else if (titleId == StringId.EnvironmentalScience)
            {
                functionList.AddRange(FunctionList.List.sensorsEnvironmentalScience);
            }
            else if (titleId == StringId.Sensor)
            {
                functionList.AddRange(FunctionList.List.sensorsArm);
            }
            functionList.OrderByDescending(o => o.controlCounter).ToList();
 
            ShowFunctionRow(functionList);
 
            LoadDialog_ChangeFloor();
        }
 
        /// <summary>
        /// 加载功能row
        /// </summary>
        void ShowFunctionRow(List<Function> showList)
        {
            functionListView.RemoveAll();
            foreach (var function in showList)
            {
 
                if (function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
                {
                    var functionDiv = new FunctionControlZone(function)
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(343),
                        Height = Application.GetRealHeight(116),
                        Radius = (uint)Application.GetMinRealAverage(12),
                        BorderColor = 0x00FFFFFF,
                        BorderWidth = 1,
                        BackgroundColor = CSS_Color.MainBackgroundColor,
                        Tag = function.spk + function.sid
                    };
                    functionDiv.LoadFunctionDiv();
                    functionListView.AddChidren(functionDiv);
                }
                else
                {
                    var functionDiv = new FunctionControlZone(function)
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(343),
                        Height = Application.GetRealHeight(96),
                        Radius = (uint)Application.GetMinRealAverage(12),
                        BorderColor = 0x00FFFFFF,
                        BorderWidth = 1,
                        BackgroundColor = CSS_Color.MainBackgroundColor,
                        Tag = function.spk + function.sid
                    };
                    functionDiv.LoadFunctionDiv();
                    functionListView.AddChidren(functionDiv);
                }
                functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) });
            }
        }
 
 
        /// <summary>
        /// 住宅列表点击事件
        /// </summary>
        void LoadDialog_ChangeFloor()
        {
            string nowSelectId = null;
            btnFloor.MouseUpEventHandler += (sender, e) =>
            {
                //显示下拉列表
                var form = new FloorRoomSelectPopupView();
                form.ShowDeviceFunctionView(btnFloor, this.functionList, (selectId, listFunc) =>
                {
                    nowSelectId = selectId;
                    //重新加载界面
                    ShowFunctionRow(listFunc);
                }, nowSelectId);
            };
        }
    }
}