wei
2021-06-23 d4973876384be55df64de45db8a511d1e0330872
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
using Shared;
using HDL_ON.Stan;
using System;
using System.Collections.Generic;
using System.Text;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 门锁列表界面(有多个门锁的时候,才会显示的界面)
    /// </summary>
    public class DoorLockListPage : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 门锁设备列表
        /// </summary>
        private List<Function> listDevice = new List<Function>();
        /// <summary>
        /// 电池控件列表(key:设备的sid)
        /// </summary>
        private Dictionary<string, BatteryPersentControl> dicBatteryContr = new Dictionary<string, BatteryPersentControl>();
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listView = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_listDevice">门锁设备列表</param>
        public void ShowForm(List<Function> i_listDevice)
        {
            this.listDevice.AddRange(i_listDevice);
 
            //智能门锁
            base.SetTitleText(Language.StringByID(StringId.DoorLock));
 
            //初始化头部历史记录控件
            this.InitTopHistoryControl();
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            string nowSelectId = string.Empty;
            //楼层下拉图标
            var btnFloor = new NormalViewControl(100, Application.GetRealHeight(16), false);
            var btnFloorIcon = new IconViewControl(16);
            btnFloorIcon.X = HdlControlResourse.XXLeft;
            btnFloorIcon.Y = Application.GetRealHeight(18);
            btnFloorIcon.UnSelectedImagePath = "Public/DownIcon.png";
            bodyFrameLayout.AddChidren(btnFloorIcon);
            btnFloorIcon.ButtonClickEvent += (sender, e) =>
            {
                //显示下拉列表
                var form = new FloorRoomSelectPopupView();
                form.ShowDeviceFunctionView(btnFloor, this.listDevice, (selectId, listFunc) =>
                {
                    nowSelectId = selectId;
                    //重新初始化门锁列表控件
                    this.InitDoorListControl(listFunc);
 
                }, nowSelectId);
            };
            //楼层
            btnFloor.X = btnFloorIcon.Right + Application.GetRealWidth(2);
            btnFloor.TextColor = CSS_Color.FirstLevelTitleColor;
            btnFloor.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
            btnFloor.Text = DB_ResidenceData.Instance.CurFloor.roomName;
            btnFloor.Width = btnFloor.GetRealWidthByText();
            bodyFrameLayout.AddChidren(btnFloor);
            //让它相对图标居中
            btnFloor.Y = btnFloorIcon.Y + (btnFloorIcon.Height - btnFloor.Height) / 2;
            btnFloor.ButtonClickEvent += (sender, e) =>
            {
                btnFloorIcon.ButtonClickEvent(null, null);
            };
 
            //列表控件
            this.listView = new VerticalListControl();
            listView.Y = Application.GetRealHeight(53);
            listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(53);
            bodyFrameLayout.AddChidren(listView);
 
            //初始化门锁列表控件
            this.InitDoorListControl(this.listDevice);
        }
 
        #endregion
 
        #region ■ 添加门锁控件_______________________
 
        /// <summary>
        /// 初始化门锁列表控件
        /// </summary>
        private void InitDoorListControl(List<Function> i_listDevice)
        {
            this.listView.RemoveAll();
            this.dicBatteryContr = new Dictionary<string, BatteryPersentControl>();
 
            //生成门锁控件
            foreach (var device in i_listDevice)
            {
                this.AddDoorControl(device);
            }
        }
 
        /// <summary>
        /// 添加门锁控件
        /// </summary>
        /// <param name="i_device">门锁对象</param>
        private void AddDoorControl(Function i_device)
        {
            //白色背景容器
            var frameBack = new FrameLayoutStatuControl();
            frameBack.Width = Application.GetRealWidth(343);
            frameBack.Height = Application.GetRealHeight(96);
            frameBack.Radius = (uint)Application.GetRealWidth(12);
            frameBack.Gravity = Gravity.CenterHorizontal;
            frameBack.BackgroundColor = CSS_Color.MainBackgroundColor;
            this.listView.AddChidren(frameBack);
            //门锁图标
            var btnIcon = new IconViewControl(32);
            btnIcon.X = Application.GetRealWidth(10);
            btnIcon.Y = Application.GetRealHeight(15);
            btnIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/DoorLock.png";
            frameBack.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
            //设备名字
            var btnName = new Button();
            btnName.X = btnIcon.Right + Application.GetRealWidth(12);
            btnName.Y = Application.GetRealHeight(12);
            btnName.Width = Application.GetRealWidth(150);
            btnName.Height = Application.GetRealHeight(20);
            btnName.TextColor = CSS_Color.FirstLevelTitleColor;
            btnName.TextAlignment = TextAlignment.CenterLeft;
            btnName.Text = i_device.name;
            frameBack.AddChidren(btnName, ChidrenBindMode.BindEvent);
            //房间
            var btnRoom = new Button();
            btnRoom.X = btnName.X;
            btnRoom.Y = btnName.Bottom + Application.GetRealHeight(4);
            btnRoom.Width = Application.GetRealWidth(150);
            btnRoom.Height = Application.GetRealHeight(15);
            btnRoom.TextColor = CSS_Color.PromptingColor1;
            btnRoom.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
            btnRoom.TextAlignment = TextAlignment.CenterLeft;
            btnRoom.Text = i_device.GetRoomListName();
            frameBack.AddChidren(btnRoom, ChidrenBindMode.BindEvent);
            //电池图标
            var btnBattery = new BatteryPersentControl();
            btnBattery.Y = Application.GetRealHeight(62);
            frameBack.AddChidren(btnBattery, ChidrenBindMode.BindEvent);
            btnBattery.InitControl();
            btnBattery.SetValue(80);
            btnBattery.X = frameBack.Width - btnBattery.Width - Application.GetRealWidth(12);
            this.dicBatteryContr[i_device.sid] = btnBattery;
            frameBack.ButtonClickEvent += (sender, e) =>
            {
                var form = new DoorLockPage();
                form.AddForm(i_device, new Button(), btnName, btnRoom);
            };
 
            //底部再加个间距
            var frameSpace = new FrameLayout();
            frameSpace.Height = Application.GetRealHeight(12);
            this.listView.AddChidren(frameSpace);
        }
 
        #endregion
 
        #region ■ 初始化头部历史记录图标_____________
 
        /// <summary>
        /// 初始化头部历史记录控件
        /// </summary>
        private void InitTopHistoryControl()
        {
            //历史记录图标
            var btnIcon = new IconViewControl(28);
            btnIcon.X = Application.GetRealWidth(337);
            btnIcon.Y = Application.GetRealHeight(9);
            btnIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/History.png";
            topFrameLayout.AddChidren(btnIcon);
            btnIcon.ButtonClickEvent += (sender, e) =>
            {
                var form = new DoorLockHistoryInfoPage();
                form.AddForm(this.listDevice);
            };
        }
 
        #endregion
 
        #region ■ 设备状态推送_______________________
 
        /// <summary>
        /// 设备状态推送
        /// </summary>
        /// <param name="i_LocalDevice"></param>
        public override void DeviceStatuPush(Function i_LocalDevice)
        {
            //不是目标设备
            if (this.dicBatteryContr.ContainsKey(i_LocalDevice.sid) == false)
            {
                return;
            }
 
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        #endregion
    }
}