wxr
2020-12-01 a46cd0adb5af29e8a9cf47c219475acaedfcf839
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
using System;
using HDL_ON.UI.UI2.Intelligence.Automation.LogicView;
using Shared;
using System.Collections.Generic;
 
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
    public class FunTpye : FrameLayout
    {
        public FunTpye()
        {
            Tag = "Logic";
        }
        /// <summary>
        /// 默认选中是房间时:全部区域
        /// </summary>
        private Entity.Room selectedRoom = new Entity.Room { sid = Language.StringByID(StringId.allAreas) };
        /// <summary>
        /// 表示是(条件/目标)
        /// </summary>
        private string if_type;
        public void Show(string str)
        {
            
            if_type = str;
            this.BackgroundColor = CSS.CSS_Color.viewMiddle;
            LogicView.TopView topView = new LogicView.TopView();
            this.AddChidren(topView.FLayoutView());
            topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
            {
                RemoveFromParent();
            };
            topView.topNameBtn.TextID = StringId.selectedFunCondition;
 
            LogicView.FunAllAreaView funAllAreaView = new LogicView.FunAllAreaView();
            funAllAreaView.frameLayout.Y = topView.frameLayout.Bottom;
            this.AddChidren(funAllAreaView.FLayoutView());
 
            VerticalScrolViewLayout vv = new VerticalScrolViewLayout
            {
                Y = Application.GetRealHeight(117),
                Height = Application.GetRealHeight(667 - 117),
            };
            this.AddChidren(vv);
 
            //房间点击事件
            EventHandler<MouseEventArgs> roomClick = (sender, e) =>
            {
                #region 区域弹框界面
                FrameLayout fLayout = new FrameLayout
                {
                    BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
                };
                this.AddChidren(fLayout);
                fLayout.MouseUpEventHandler += (sender1, e1) =>
                {
                    fLayout.RemoveFromParent();
                };
 
                FrameLayout bghFrameLyout = new FrameLayout
                {
                    X = Application.GetRealWidth(10),
                    Y = Application.GetRealHeight(103),
                    Width = Application.GetRealWidth(160),
                    Height = Application.GetRealHeight(21 + 44),
                    BackgroundImagePath = "LogicIcon/bjicon.png",
                };
                fLayout.AddChidren(bghFrameLyout);
 
                FrameLayout areaBgh = new FrameLayout
                {
                    X = Application.GetRealWidth(8),
                    Y = Application.GetRealHeight(14),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                VerticalScrolViewLayout vvBgh = new VerticalScrolViewLayout
                {
                    X = Application.GetRealWidth(8),
                    Y = Application.GetRealHeight(14),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44 * 5),
                };
                var roomList = LogicMethod.GetGatewayRoomList(Language.StringByID(StringId.allAreas));
                if (roomList.Count > 5)
                {
                    bghFrameLyout.Height = Application.GetRealHeight(21 + 44 * 5);
                    bghFrameLyout.AddChidren(vvBgh);
 
                }
                else
                {
 
                    bghFrameLyout.AddChidren(areaBgh);
                    bghFrameLyout.Height = Application.GetRealHeight(21 + 44 * roomList.Count);
                    areaBgh.Height = Application.GetRealHeight(44 * roomList.Count);
                }
                #endregion
 
                for (int i = 0; i < roomList.Count; i++)
                {
                    var room = roomList[i];
                    LogicView.AreaView areaView = new LogicView.AreaView();
                    if (roomList.Count > 5)
                    {
                        vvBgh.AddChidren(areaView.FLayoutView());
                    }
                    else
                    {
                        areaView.frameLayout.Y = Application.GetRealHeight(i * 44);
                        areaBgh.AddChidren(areaView.FLayoutView());
                    }
                    areaView.btnRoomName.Text = room.name;
                    areaView.btnClick.Tag = room;
                    areaView.btnClick.MouseUpEventHandler += (sender2, e2) =>
                    {
                        fLayout.RemoveFromParent();
                        funAllAreaView.btnText1.Text = (areaView.btnClick.Tag as Entity.Room).name;
                        ///切换房间默认功能类型全部;
                        funAllAreaView.btnText2.Text = Language.StringByID(StringId.allFun);
                        selectedRoom = (areaView.btnClick.Tag as Entity.Room);
                        ///获取显示设备列表
                        var list = LogicMethod.GetFunctionDeviceList(areaView.btnClick.Tag as Entity.Room,if_type);
 
                        DeviceListView(vv, list);
                    };
 
                }
            };
            funAllAreaView.btnText1.MouseUpEventHandler += roomClick;
            funAllAreaView.btnIcon1.MouseUpEventHandler += roomClick;
            //功能点击事件
            EventHandler<MouseEventArgs> funClick = (sender3, e3) =>{
                #region 区域弹框界面
                FrameLayout fLayout = new FrameLayout
                {
                    BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
                };
                this.AddChidren(fLayout);
                fLayout.MouseUpEventHandler += (sender1, e1) =>
                {
                    fLayout.RemoveFromParent();
                };
 
                FrameLayout bghFrameLyout = new FrameLayout
                {
                    X = Application.GetRealWidth(10),
                    Y = Application.GetRealHeight(103),
                    Width = Application.GetRealWidth(160),
                    Height = Application.GetRealHeight(21 + 44),
                    BackgroundImagePath = "LogicIcon/bjicon.png",
                };
                fLayout.AddChidren(bghFrameLyout);
 
                FrameLayout areaBgh = new FrameLayout
                {
                    X = Application.GetRealWidth(8),
                    Y = Application.GetRealHeight(14),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                VerticalScrolViewLayout vvBgh = new VerticalScrolViewLayout
                {
                    X = Application.GetRealWidth(8),
                    Y = Application.GetRealHeight(14),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44 * 5),
                };
 
                //获取最终显示列表
                var functionList = LogicMethod.GetFunctionDeviceList(selectedRoom, if_type);
                //获取设备列表的类型(例如:灯光类,窗帘类。。。)
                var deviceTypeList = LogicMethod.GetDeviceTypeList(functionList);
 
 
                if (deviceTypeList.Count > 5)
                {
                    bghFrameLyout.Height = Application.GetRealHeight(21 + 44 * 5);
                    bghFrameLyout.AddChidren(vvBgh);
 
                }
                else
                {
                    bghFrameLyout.AddChidren(areaBgh);
                    bghFrameLyout.Height = Application.GetRealHeight(21 + 44 * deviceTypeList.Count);
                    areaBgh.Height = Application.GetRealHeight(44 * deviceTypeList.Count);
                }
                #endregion
 
                for (int i = 0; i < deviceTypeList.Count; i++)
                {
                    var deviceTypeName = deviceTypeList[i];
                    LogicView.AreaView areaView = new LogicView.AreaView();
                    if (deviceTypeList.Count > 5)
                    {
                        vvBgh.AddChidren(areaView.FLayoutView());
                    }
                    else
                    {
                        areaView.frameLayout.Y = Application.GetRealHeight(i * 44);
                        areaBgh.AddChidren(areaView.FLayoutView());
                    }
                    areaView.btnRoomName.Text = deviceTypeName;
                    areaView.btnClick.Tag = deviceTypeName;
                    areaView.btnClick.MouseUpEventHandler += (sender, e2) =>
                    {
                        fLayout.RemoveFromParent();
                        funAllAreaView.btnText2.Text = areaView.btnClick.Tag.ToString();
                        ///获取单个类型(例如:灯光类。。)设备FunctionType列表
                        var typeFunctionList = LogicMethod.GetDeviceTypeFunctionList(areaView.btnClick.Tag.ToString());
                        ///获取单个类型(例如:灯光类。。)显示设备列表
                        var lists = LogicMethod.GetShowDeviceList(typeFunctionList, functionList);
                        DeviceListView(vv, lists);
                    };
 
                }
            };
            funAllAreaView.btnText2.MouseUpEventHandler += funClick;
            funAllAreaView.btnIcon2.MouseUpEventHandler += funClick;
            ///获取显示设备列表
            var deviceList = LogicMethod.GetFunctionDeviceList(selectedRoom, if_type);
            DeviceListView(vv, deviceList);
 
        }
        /// <summary>
        /// 显示设备的View
        /// </summary>
        /// <param name="verticalScrolView">上下滑动</param>
        /// <param name="deviceList"></param>
        public void DeviceListView(VerticalScrolViewLayout verticalScrolView, List<HDL_ON.Entity.Function>  deviceList)
        {
            verticalScrolView.RemoveAll();
            foreach (var dev in deviceList)
            {
                LogicView.SelectTypeView funView = new LogicView.SelectTypeView();
                funView.btnText.Visible = false;
                funView.btnDeviceName.Visible = true;
                funView.btnRoomName.Visible = true;
                funView.btnLine.X = Application.GetRealWidth(16);
                funView.btnLine.Width = Application.GetRealWidth(343);
                verticalScrolView.AddChidren(funView.FLayoutView());
                funView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(dev.functionType);
                funView.btnDeviceName.Text = dev.name;
                funView.btnRoomName.Text = dev.GetRoomListName();
                funView.btnClick.MouseUpEventHandler += (sen,e) => {
                    DeviceFunList deviceFunList = new DeviceFunList();
                    MainPage.BasePageView.AddChidren(deviceFunList);
                    deviceFunList.Show(dev,0,false,if_type);
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
            }
        }
    }
 
 
}