黄学彪
2020-01-17 4b378188ce972df432b23d9cb73babb6cc0679c6
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
using System;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DoorLock
{
    public class AddUnLockMethod : DoorLockCommonLayout, ZigBee.Common.IStatus
    {
        /// 构造函数
        /// </summary>
        /// <param name="doorLock"></param>
        public AddUnLockMethod(ZigBee.Device.DoorLock doorLock, Shared.Phone.UserCenter.MemberInfoRes accountObj)
        {
            this.doorLock = doorLock;
            this.curAccountObj = accountObj;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
        }
 
        #region 变量申明
        /// <summary>
        /// 当前门锁
        /// </summary>
        ZigBee.Device.DoorLock doorLock;
        /// <summary>
        /// 当前账户
        /// </summary>
        Shared.Phone.UserCenter.MemberInfoRes curAccountObj;
        #endregion
 
        /// <summary>
        /// UI显示 
        /// </summary>
        public void Show()
        {
            this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.AddNewUnlockMethod));
 
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
                RemoveFromParent();
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
 
            MidFrameLayoutContent();
        }
       
        /// <summary>
        /// 中部布局
        /// </summary>
        public void MidFrameLayoutContent()
        {
            var bodyView = new VerticalScrolViewLayout()
            {
            };
            this.midFrameLayout.AddChidren(bodyView);
 
            for (int i = 0; i < 3; i++)
            {
                var RowView = new FrameLayout()
                {
                    Height = Application.GetRealHeight(161),
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                };
                bodyView.AddChidren(RowView);
 
                var btnText = new Button()
                {
                    X = Application.GetRealWidth(58),
                    Width = Application.GetRealWidth(300),
                    Height = Application.GetRealHeight(300),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                    Gravity = Gravity.CenterVertical,
                    TextSize=14,
                };
                RowView.AddChidren(btnText);
 
                var btnRightFrameLayout = new FrameLayout()
                {
                    Height = Application.GetRealHeight(110),
                    Width = Application.GetRealWidth(110),
                    X = Application.CurrentWidth - Application.GetRealWidth(150),
                    Y = Application.GetRealHeight(25),
                };
                RowView.AddChidren(btnRightFrameLayout);
 
                var btnRight = new Button()
                {
                    Height = Application.GetRealHeight(60),
                    Width = Application.GetRealWidth(60),
                    UnSelectedImagePath = "DoorLock/RightIcon.png",
                    Gravity = Gravity.Center,
                };
                btnRightFrameLayout.AddChidren(btnRight);
 
                var line2 = new Button()
                {
                    Y = RowView.Height - 1,
                    X = Application.GetRealWidth(58),
                    Width = Application.GetRealWidth(965),
                    Height = 1,
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                };
                RowView.AddChidren(line2);
 
                if (i == 0)
                {
                    btnText.TextID = R.MyInternationalizationString.AddPassword;
                }
                else if (i == 1)
                {
                    btnText.TextID = R.MyInternationalizationString.AddFingerprint;
                }
                else if (i == 2)
                {
                    btnText.TextID = R.MyInternationalizationString.AddIcCard;
                    line2.Visible = false;
                }
 
                int currentIndex = i;
                EventHandler<MouseEventArgs> eHandler = (sender, e) =>
                {
                    if (currentIndex == 0)
                    {
                        var addUnLockMethodTip = new AddUnLockMethodTip(doorLock, curAccountObj, "password");
                        Shared.Phone.UserView.HomePage.Instance.AddChidren(addUnLockMethodTip);
                        Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                        addUnLockMethodTip.Show();
                    }
                    else if (currentIndex == 1)
                    {
                        var addUnLockMethodTip = new AddUnLockMethodTip(doorLock, curAccountObj, "fingerprint");
                        Shared.Phone.UserView.HomePage.Instance.AddChidren(addUnLockMethodTip);
                        Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                        addUnLockMethodTip.Show();
                    }
                    else if (currentIndex == 2)
                    {
                        var addUnLockMethodTip = new AddUnLockMethodTip(doorLock, curAccountObj, "proximity");
                        Shared.Phone.UserView.HomePage.Instance.AddChidren(addUnLockMethodTip);
                        Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                        addUnLockMethodTip.Show();
                    }
                };
                btnRight.MouseUpEventHandler += eHandler;
                RowView.MouseUpEventHandler += eHandler;
                btnText.MouseUpEventHandler += eHandler;
            }
        }
 
        #region 接口实现
        /// <summary>
        /// 处理变化事件 --将弃用 改用DeviceInfoChange()
        /// </summary>
        /// <returns>The changed.</returns>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        { 
        }
        /// <summary>
        /// 处理变化事件
        /// </summary>
        /// <param name="common"></param>
        /// <param name="typeTag"></param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
        }
        /// <summary>
        /// Changeds the IL ogic status.
        /// </summary>
        /// <param name="logic">Logic.</param>
        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
        {
        }
        /// <summary>
        /// Changeds the IS cene status.
        /// </summary>
        /// <param name="scene">Scene.</param>
        public void ChangedISceneStatus(Scene scene)
        {
        }
        #endregion
    }
}