黄学彪
2020-07-01 304dca51c28183a9dfc192c6b93ea1c00bdd5d97
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
using System;
using System.Collections.Generic;
using Shared.Common;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DeviceBind
{
    public class BindCommonLayout : FrameLayout
    {
        public BindCommonLayout()
        {
 
        }
        #region ◆ 变量申明__________________________
        /// <summary>
        /// 楼层回调
        /// </summary>
        public Action FloorAction = null;
        /// <summary>
        /// 选中的楼层回调[
        /// </summary>
        public Action<string, Button> ChooseFloorAction = null;
 
        public FrameLayout topFrameLayout = new FrameLayout { Height = Application.GetRealHeight(184), BackgroundColor = ZigbeeColor.Current.XMTopFrameLayout };
        public FrameLayout midFrameLayout = new FrameLayout { Height = Application.GetRealHeight(1925 - 184), BackgroundColor = ZigbeeColor.Current.XMMidFrameLayout };
 
        public FrameLayout bottomRadiusFrameLayout = new FrameLayout()
        {
            Height = Application.GetRealHeight(100),
            Y = Application.GetRealHeight(930),
            Radius = 17,
            BackgroundColor = ZigbeeColor.Current.XMWhite,
        };
 
        public FrameLayout titleFrameLayout = new FrameLayout
        {
            Y = Application.GetRealHeight(92),
            X = Application.GetRealWidth(161),
            Width = Application.GetRealWidth(1080 - 161),//919
            Height = Application.GetRealHeight(69),
        };
        public Button btnTitle = new Button
        {
            TextAlignment = TextAlignment.CenterLeft,
            TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
            Width = Application.GetRealWidth(1080 - 161),//919
            Height = Application.GetRealWidth(69),
            TextSize = 17,
            IsBold = true,
            //X = Application.GetRealWidth(161 - 116),
        };
        /// <summary>
        /// 标题返回布局
        /// </summary>
        public FrameLayout btnBackFrameLayout = new FrameLayout
        {
            Width = Application.GetRealWidth(58 * 2),//116
        };
 
        /// <summary>
        /// 标题返回按键
        /// </summary>
        public Button btnBack = new Button
        {
            Height = Application.GetRealHeight(51),
            Width = Application.GetRealWidth(30),
            X = Application.GetRealWidth(58),
            Y = Application.GetRealHeight(98),
            UnSelectedImagePath = "DoorLock/Left.png",
        };
 
        /// <summary>
        /// 标题下线
        /// </summary>
        public Button btnTitleLine = new Button
        {
            Y = Application.GetRealHeight(181),
            Height = 1,
            BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine,
        };
        #endregion
 
        /// <summary>
        /// 顶部布局
        /// </summary>
        /// <param name="frameLayout"></param>
        public void TopFrameLayout(FrameLayout frameLayout, string titleText)
        {
            this.AddChidren(topFrameLayout);
            topFrameLayout.AddChidren(btnBackFrameLayout);
            topFrameLayout.AddChidren(titleFrameLayout);
            topFrameLayout.AddChidren(btnTitleLine);
            btnBackFrameLayout.AddChidren(btnBack);
            titleFrameLayout.AddChidren(btnTitle);
            btnTitle.Text = titleText;
        }
        /// <summary>
        /// 门锁中部布局
        /// </summary>
        /// <param name="frameLayout"></param>
        public void MidFrameLayout(FrameLayout frameLayout)
        {
            //midFrameLayout.BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCBackgroundColor;
            midFrameLayout.Y = topFrameLayout.Bottom;
            this.AddChidren(midFrameLayout);
        }
 
        /// <summary>
        /// 门锁底部布局
        /// </summary>
        /// <param name="frameLayout"></param>
        public void BottomFrameLayout(FrameLayout frameLayout)
        {
            var bottomFrameLayout1 = new FrameLayout()
            {
                Height = Application.GetRealHeight(806 - 50),
                Y = Application.GetRealHeight(930 + 48),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout1);
        }
 
        /// <summary>
        /// 添加楼层UI
        /// </summary> 
        public void BindDownFrameLayout(FrameLayout frameLayout, Panel curControlDev, Dictionary<string, string> dicFloorList, ref Button btnFloorText)
        {
            var btnAddFrameLayout = new FrameLayout
            {
                X = Application.GetRealWidth(619),
            };
            this.titleFrameLayout.AddChidren(btnAddFrameLayout);
 
            btnFloorText = new Button
            {
                Width = Application.GetRealWidth(300 - 69 - 58),
                Text = Language.StringByID(R.MyInternationalizationString.FirstFloor),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 14,
                IsBold = true,
                TextAlignment = TextAlignment.CenterRight,
            };
            btnAddFrameLayout.AddChidren(btnFloorText);
 
            var btnBindDownFrameLayout = new FrameLayout
            {
                Width = Application.GetMinReal(69 + 58),
                X = Application.GetRealWidth(300 - 69 - 58),
            };
            btnAddFrameLayout.AddChidren(btnBindDownFrameLayout);
 
            var btnBindDown = new Button
            {
                Height = Application.GetMinReal(69),
                Width = Application.GetMinReal(69),
                UnSelectedImagePath = "BindPic/BindDown.png",
                Gravity = Gravity.CenterVertical,
            };
            btnBindDownFrameLayout.AddChidren(btnBindDown);
 
            EventHandler<MouseEventArgs> eHandlerBindDown = (sender, e) =>
            {
                if (dicFloorList == null)
                {
                    dicFloorList = new Dictionary<string, string>();
                }
                SideslipFramelayout(curControlDev, dicFloorList);
            };
            btnBindDown.MouseDownEventHandler += eHandlerBindDown;
            btnBindDownFrameLayout.MouseDownEventHandler += eHandlerBindDown;
            if (Common.Config.Instance.Home.FloorDics.Count == 0)
            {
                btnAddFrameLayout.Width = 0;
            }
            else
            {
                btnAddFrameLayout.Width = Application.GetRealWidth(300);
            }
        }
 
        /// <summary>
        /// 楼层选择的侧边栏
        /// </summary>
        void SideslipFramelayout(Panel curControlDev, Dictionary<string, string> dicFloorList)
        {
            var dialog = new Dialog
            {
            };
            dialog.Show();
 
            var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
            dialog.AddChidren(flMain);
            flMain.MouseUpEventHandler += (sender11, e11) =>
            {
                dialog.Close();
            };
 
            var sidelipFrameLayout = new FrameLayout()
            {
                Width = Application.GetMinReal(449),
                Y = Application.GetRealHeight(161),
                X = Application.GetRealWidth(596),
                BackgroundImagePath = "DoorLock/SideslipPic.png",
            };
            flMain.AddChidren(sidelipFrameLayout);
 
            var btnSelectFloor = new Button()
            {
                Width = Application.GetRealWidth(200),
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(81),
                Y = Application.GetRealHeight(81),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 14,
                IsBold = true,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = R.MyInternationalizationString.SelectFloor,
            };
            sidelipFrameLayout.AddChidren(btnSelectFloor);
 
            var sidelipVerticalScrolViewLayout = new VerticalScrolViewLayout()
            {
                Y = btnSelectFloor.Bottom + Application.GetRealHeight(45),
                Height = Application.GetRealHeight(600),
            };
            sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout);
 
            Button oldbutton = null;
            Button oldbuttonText = null;
            int count = 0;
            foreach (var floorId in dicFloorList.Keys)
            {
                var rowFrameLayout = new RowLayout()
                {
                    Height = Application.GetRealHeight(152),
                    LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                    X = Application.GetRealWidth(81),
                };
                sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout);
 
                var btnAllMethod = new Button()
                {
                    Width = Application.GetMinReal(81),
                    Height = Application.GetMinReal(81),
                    UnSelectedImagePath = "Floor/Floor.png",
                    SelectedImagePath = "Floor/FloorSelected.png",
                    Gravity = Gravity.CenterVertical,
                };
                rowFrameLayout.AddChidren(btnAllMethod);
 
                var btnMethodText = new Button()
                {
                    Width = Application.GetRealWidth(311),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(92),
                    Gravity = Gravity.CenterVertical,
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    TextSize = 14,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = dicFloorList[floorId],
                };
                rowFrameLayout.AddChidren(btnMethodText);
 
                if (curControlDev.currentSelectFloorId == floorId)
                {
                    btnAllMethod.IsSelected = true;
                    btnAllMethod.IsBold = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                }
 
                EventHandler<MouseEventArgs> hander = (sender, e) =>
                {
                    if (curControlDev.currentSelectFloorId == floorId)
                    {
                        return;
                    }
                    curControlDev.currentSelectFloorId = floorId;
 
                    if (!btnMethodText.IsSelected)
                    {
                        if (oldbutton != null)
                        {
                            oldbutton.IsSelected = false;
                        }
                        if (oldbuttonText != null)
                        {
                            oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                        }
                        oldbutton = btnMethodText;
                        oldbuttonText = btnMethodText;
                        btnMethodText.IsSelected = true;
                        oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        oldbuttonText.IsBold = true;
                    }
 
                    int index = 0;
                    dialog.Close();
                    ChooseFloorAction?.Invoke(floorId, btnMethodText);
                };
                btnAllMethod.MouseUpEventHandler += hander;
                rowFrameLayout.MouseUpEventHandler += hander;
                btnMethodText.MouseUpEventHandler += hander;
                count++;
            }
 
            if (count == 0)
            {
                sidelipFrameLayout.Height = 0;
            }
            else if (count <= 4 && count > 0)
            {
                sidelipFrameLayout.Height = Application.GetRealHeight(180) + count * Application.GetRealHeight(150);
            }
            else
            {
                sidelipFrameLayout.Height = Application.GetMinReal(780);
            }
        }
    }
}