gxc
2020-01-15 27e6f7742991170672feba0f4fd8d693b333ba0e
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
using System;
using Shared.Common;
using Shared.Phone.Device.Category;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.UserView;
 
namespace Shared.Phone.Device.Room
{
 
    public class RoomManagement : FrameLayout
    {
 
        #region ◆ 变量____________________________
        /// <summary>
        /// bodyFrameLayout
        /// </summary>
        private FrameLayout bodyFrameLayout;
 
        private Button floorBtn;
        /// <summary>
        /// 当前楼层id
        /// </summary>
        private string curFloorId;
 
        public FrameLayout itemView;
 
        static RoomManagement roomManagement;
        public static RoomManagement Instance
        {
            get
            {
                if (roomManagement == null)
                {
                    roomManagement = new RoomManagement { };
                }
                return roomManagement;
            }
        }
 
        /// <summary>
        /// 是否可以触发点击事件--是否可以跳转主页房间
        /// </summary>
        public bool CanClick = true;
 
        #endregion
 
 
        public Action action;
 
 
 
        public override void RemoveFromParent()
        {
            //action?.Invoke();
            base.RemoveFromParent();
        }
        /// <summary>
        /// 房间管理
        /// </summary>
        public void Show()
        {
            RemoveAll();
 
            AddTop();
 
            AddBodyView(Config.Instance.Home.CurrentFloorId);
        }
 
        #region Add____________________________________
 
        /// <summary>
        /// AddTop
        /// </summary>
        public void AddTop()
        {
            var top = new TopFrameLayout();
            AddChidren(top);
            top.InitTopview();
            top.SetTopTitle(R.MyInternationalizationString.RoomList);
            top.backButton.MouseUpEventHandler += (sender, e) =>
            {
                CommonPage.Instance.CloseLeftMenu();
            };
 
            floorBtn = new Button()
            {
                X = Application.GetRealWidth(650),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(60),
                Gravity = Gravity.CenterVertical,
                TextAlignment = TextAlignment.CenterRight,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextSize = 14,
                IsBold = true
            };
 
            var selectFloorBtn = new Button()
            {
                X = Application.GetRealWidth(950),
                Width = Application.GetMinRealAverage(69),
                Height = Application.GetMinRealAverage(69),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "Item/Drop_Down.png"
            };
 
            floorBtn.Text = Config.Instance.Home.GetCurrentFloorName;
            if(Config.Instance.Home.FloorDics.Count>0)
            {
                curFloorId = Config.Instance.Home.CurrentFloorId;
                top.topView.AddChidren(floorBtn);
                top.topView.AddChidren(selectFloorBtn);
            }
            selectFloorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler;
            floorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler;
        }
 
        /// <summary>
        /// 选择楼层
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void SelectedFloor_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs)
        {
            var floors = new SelectFloor();
            AddChidren(floors);
            floors.changeFloor = false;
            floors.CurFloorId = curFloorId;
            floors.Init(599, 161,Direction.Right);
            floors.FloorAction += (floorId) =>
            {
                curFloorId = floorId;
                floorBtn.Text = Config.Instance.Home.GetFloorNameById(floorId);
                AddBodyView(floorId);
            };
        }
 
        /// <summary>
        /// AddBodyView
        /// </summary>
        public void AddBodyView(string floorId)
        {
            bodyFrameLayout = new FrameLayout()
            {
                Y = Application.GetRealHeight(184),
                Height = Application.GetRealHeight(1737),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
            };
            AddChidren(bodyFrameLayout);
 
            try
            {
                if (Common.Room.Lists.Count <= 1)
                {
                    return;
                }
                var roomScrolView = new VerticalScrolViewLayout { };
                bodyFrameLayout.AddChidren(roomScrolView);
                var roomList = Common.Room.CurrentRoom.GetRoomsByFloorId(floorId);
                if (roomList == null || roomList.Count == 0)
                {
                    itemView = new FrameLayout()
                    {
                        Height = Application.GetRealHeight(354 + 58)
                    };
                    roomScrolView.AddChidren(itemView);
 
                    var roomView = new RoomNoNameMainView(34, 58);
                    itemView.AddChidren(roomView);
                    roomView.Init();
 
                    roomView.Icon.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent;
                    roomView.RoomNameButton.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent;
                    roomView.iconFL.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent;
                }
                else
                {
                    for (int i = 0; i < roomList.Count + 1; i++)
                    {
                        int xx = 43 + i % 2 * (20 + 487);
                        int yy = 0;
                        if (i == 0 || i == 1)
                        {
                            if (i % 2 == 0)
                            {
                                itemView = new FrameLayout()
                                {
                                    Height = Application.GetRealHeight(354 + 58)
                                };
                                roomScrolView.AddChidren(itemView);
                            }
                            yy = 58;
                        }
                        else if (i % 2 == 0)
                        {
                            itemView = new FrameLayout()
                            {
                                Height = Application.GetRealHeight(354)
                            };
                            roomScrolView.AddChidren(itemView);
                        }
 
                        if (i < roomList.Count)
                        {
                            var room = roomList[i];
                            var roomView = new RoomMainView(xx, yy);
                            itemView.AddChidren(roomView);
                            roomView.Init(this, room);
                            roomView.SetRoomName(room.Name);
                            roomView.SetRoomIcon(room.BackgroundImageType == 0 ? room.BackgroundImage : System.IO.Path.Combine(Config.Instance.FullPath, room.BackgroundImage));
                            roomView.ClickBtn.MouseUpEventHandler += (sender, e) =>
                            {
                                if (CanClick == false)
                                {
                                    return;
                                }
                                CommonPage.Instance.CloseLeftMenu();
                                Common.Room.CurrentRoom = room;
                                Config.Instance.Home.CurrentFloorId = room.FloorId;
                                UserPage.Instance.Fresh();
                            };
                        }
                        else
                        {
                            var roomView = new RoomNoNameMainView(xx, yy);
                            itemView.AddChidren(roomView);
                            roomView.Init();
 
                            roomView.Icon.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent;
                            roomView.RoomNameButton.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent;
                            roomView.iconFL.MouseUpEventHandler += ShowUnallocatedRoom_MouseUpEvent;
                        }
                    }
                }
                
            }
            catch (Exception ex)
            {
                string tt=ex.Message;
            }
        }
 
        #endregion
 
        /// <summary>
        /// 房间管理界面
        /// </summary>
        public RoomManagement()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            roomManagement = this;
        }
 
        /// <summary>
        /// ShowUnallocatedRoom_MouseUpEvent
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        private void ShowUnallocatedRoom_MouseUpEvent(object sender,MouseEventArgs mouseEventArgs)
        {
            if(CanClick==false)
            {
                return;
            }
            var unalloctedRoom = new UnallocatedRoom();
            AddChidren(unalloctedRoom);
            unalloctedRoom.Show();
        }
    }
}