wxr
2020-12-17 1a13c963a5fb8cad92bf03667e411f46d6a6a843
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
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 { uid = 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);
                    bghFrameLyout.BackgroundImagePath = "LogicIcon/bjicon5.png";
                }
                else
                {
 
                    bghFrameLyout.AddChidren(areaBgh);
                    bghFrameLyout.Height = Application.GetRealHeight(21 + 44 * roomList.Count);
                    areaBgh.Height = Application.GetRealHeight(44 * roomList.Count);
                    bghFrameLyout.BackgroundImagePath = $"LogicIcon/bjicon{roomList.Count}.png";
                }
                #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.roomName;
                    areaView.btnClick.Tag = room;
                    areaView.btnClick.MouseUpEventHandler += (sender2, e2) =>
                    {
                        fLayout.RemoveFromParent();
                        funAllAreaView.btnText1.Text = (areaView.btnClick.Tag as Entity.Room).roomName;
                        ///切换房间默认功能类型全部;
                        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);
                    };
                    if (roomList.Count-1==i) {
                        ///改变最后那条一个线的颜色,界面显示效果作用;
                        areaView.btnLine.BackgroundColor = CSS.CSS_Color.view;
                    }
                }
            };
            funAllAreaView.btnText1.MouseUpEventHandler += roomClick;
            funAllAreaView.btnIcon1.MouseUpEventHandler += roomClick;
            //功能点击事件
            EventHandler<MouseEventArgs> funClick = (sender3, e3) =>{
 
                //获取最终显示列表
                var functionList = LogicMethod.GetFunctionDeviceList(selectedRoom, if_type);
                //获取设备列表的类型(例如:灯光类,窗帘类。。。)
                var deviceTypeList = LogicMethod.GetDeviceTypeList(functionList);
                if (deviceTypeList.Count==0) {
                    //没有类型直接返回去;
                    return;
                }
                #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/bjicon5.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),
                };
 
           
 
 
                if (deviceTypeList.Count > 5)
                {
                    bghFrameLyout.Height = Application.GetRealHeight(21 + 44 * 5);
                    bghFrameLyout.AddChidren(vvBgh);
                    bghFrameLyout.BackgroundImagePath = "LogicIcon/bjicon5.png";
                }
                else
                {
                    bghFrameLyout.AddChidren(areaBgh);
                    bghFrameLyout.Height = Application.GetRealHeight(21 + 44 * deviceTypeList.Count);
                    areaBgh.Height = Application.GetRealHeight(44 * deviceTypeList.Count);
                    bghFrameLyout.BackgroundImagePath = $"LogicIcon/bjicon{deviceTypeList.Count}.png";
                }
                #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());
                        ///获取单个灯光类型(例如:灯光1,灯光2。。)显示设备列表
                        var lists = LogicMethod.GetShowDeviceList(typeFunctionList, functionList);
                        DeviceListView(vv, lists);
                    };
                    if (deviceTypeList.Count - 1 == i)
                    {
                        ///改变最后那条一个线的颜色,界面显示效果作用;
                        areaView.btnLine.BackgroundColor = CSS.CSS_Color.view;
                    }
                }
            };
            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) => {
                    if (if_type == LogicMethod.condition_if) {
                        ConditionDeviceFunList conditionDeviceFunList = new ConditionDeviceFunList();
                        MainPage.BasePageView.AddChidren(conditionDeviceFunList);
                        conditionDeviceFunList.Show(dev, 0, false);
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    } else {
                        TargetDeviceFunList targetDeviceFunList = new TargetDeviceFunList();
                        MainPage.BasePageView.AddChidren(targetDeviceFunList);
                        targetDeviceFunList.Show(dev, 0, false);
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    }
                   
                };
            }
        }
    }
 
 
}