HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-12 c6b35c3138b944830b5336bf610f918154dd47c7
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
using System;
using System.Collections.Generic;
using Shared.Common;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DoorLock
{
    public class DoorLockListPage : FrameLayout, ZigBee.Common.IStatus
    {
        /// <summary>
        /// 按键模式接收
        /// </summary>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        {
            //if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch)
            //{
            //    return;
            //}
 
            Shared.Application.RunOnMainThread(() =>
            {
                //var dev = common as Panel;
            });
        }
 
        #region 变量声明
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalScrolViewLayout listView = null;
        /// <summary>
        /// 门锁设备列表
        /// </summary>
        private List<ZigBee.Device.CommonDevice> localDoorLocklist = new List<ZigBee.Device.CommonDevice>();
        #endregion
 
        /// <summary>
        /// 界面加载
        /// </summary>
        public void Show()
        {
            #region topFrameLayout (只有UI,无数据处理)
            var topFrameLayout = new FrameLayout()
            {
                Height = Application.GetRealHeight(220),
                BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor,
            };
            this.AddChidren(topFrameLayout);
 
            var titleFrameLayout = new FrameLayout()
            {
                Y = Application.GetRealHeight(80),
                Height = Application.GetRealHeight(140),
                BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor,
            };
            topFrameLayout.AddChidren(titleFrameLayout);
 
            var title = new Button()
            {
                TextAlignment = TextAlignment.Center,
                Text = Language.StringByID(R.MyInternationalizationString.DoorLock),
                TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor,
                Width = Application.GetRealWidth(1080 - 500),
                Gravity = Gravity.CenterHorizontal,
            };
            titleFrameLayout.AddChidren(title);
            var back = new Button()
            {
                X = Application.GetRealWidth(50),
                Height = Application.GetRealHeight(100),
                Width = Application.GetRealWidth(100),
                UnSelectedImagePath = "Item/Back.png",
                SelectedImagePath = "Item/BackOn.png",
                Gravity = Gravity.CenterVertical,
            };
            titleFrameLayout.AddChidren(back);
            #endregion
 
            #region midFrameLayout
            var midFrameLayout = new FrameLayout()
            {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight(1920 - 220),
                Y = topFrameLayout.Bottom,
                BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCBackgroundColor,
            };
            this.AddChidren(midFrameLayout);
 
            listView = new VerticalScrolViewLayout();
            midFrameLayout.AddChidren(listView);
            #endregion
 
            #region 数据信息处理
            listView.RemoveAll();
            localDoorLocklist.Clear();
 
            //foreach (var dev in Shared.Common.LocalDevice.Current.listAllDevice)
            //{
            //    if(dev.Type ==ZigBee.Device.DeviceType.DoorLock)
            //    {
            //        localDoorLocklist.Add(dev);
            //    }
            //} 
 
            //测试代码
            for (int i = 0; i < 3; i++)
            {
                var tempDoorLock = new ZigBee.Device.DoorLock();
                localDoorLocklist.Add(tempDoorLock);
            }
 
            foreach (var doorLock in localDoorLocklist)
            {
                this.AddDoorLockRow(doorLock);
            }
            #endregion
        }
 
        /// <summary>
        /// 添加设备的菜单行
        /// </summary>
        /// <param name="listDevice">设备对象</param>
        private void AddDoorLockRow(ZigBee.Device.CommonDevice doorLock)
        {
            var doorLockView = new RowLayout()
            {
                Height = Application.GetRealHeight(180),
            };
            listView.AddChidren(doorLockView);
 
            var btnPoint = new Button()
            {
                Width = Application.GetRealWidth(10),
                Height = Application.GetRealHeight(10),
                X = Application.GetRealWidth(40),
                Gravity = Gravity.CenterVertical,
                //UnSelectedImagePath = "Item/Point.png",
                //SelectedImagePath = "Item/Point.png",
            };
            doorLockView.AddChidren(btnPoint);
 
            var tempDeviceName = new Button()
            {
                Width = Application.GetRealWidth(340),
                X = btnPoint.Right + Application.GetRealWidth(20),
                TextAlignment = TextAlignment.CenterLeft,
                Text = "门锁1",
                TextColor = 0xff000000,
                Tag = doorLock,
            };
            doorLockView.AddChidren(tempDeviceName);
 
            var btnRight = new Button()
            {
                Height = Application.GetRealHeight(110),
                Width = Application.GetRealWidth(110),
                UnSelectedImagePath = "Item/Next.png",
                SelectedImagePath = "Item/Down.png",
                Gravity = Gravity.CenterVertical,
                X = Application.CurrentWidth - Application.GetRealWidth(150),
            };
            doorLockView.AddChidren(btnRight);
 
            EventHandler<MouseEventArgs> openDoorLockControlPageEvent = (button, mouseEventArgs) =>
            {
                //var doorLockManagement = new Shared.Phone.UserCenter.DoorLock.DoorLockManagement();
                //Shared.Phone.UserView.HomePage.Instance.AddChidren(doorLockManagement);
                //Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                //doorLockManagement.Show();
            };
            doorLockView.MouseUpEventHandler += openDoorLockControlPageEvent;
            tempDeviceName.MouseUpEventHandler += openDoorLockControlPageEvent;
            btnRight.MouseUpEventHandler += openDoorLockControlPageEvent;
        }
 
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
        }
 
        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
        {
        }
 
        public void ChangedISceneStatus(Scene scene)
        {
        }
    }
}