黄学彪
2020-03-23 21923381bdac04d1633b168c97accc81f0898d84
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
using System;
using Shared.Common;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DoorLock
{
    public class MasterManagementPage : DoorLockCommonLayout
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="doorLock"></param>
        public MasterManagementPage(ZigBee.Device.DoorLock doorLock, Shared.Phone.UserCenter.MemberInfoRes accountObj)
        {
            this.doorLock = doorLock;
            this.accountObj = accountObj;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
        }
 
        #region  变量申明
        /// <summary>
        /// 当前门锁
        /// </summary>
        ZigBee.Device.DoorLock doorLock;
        /// <summary>
        /// 当前账户
        /// </summary>
        Shared.Phone.UserCenter.MemberInfoRes accountObj;
        #endregion
 
        /// <summary>
        /// UI显示 
        /// </summary>
        public void Show()
        {
            string accountTitle = "";
            if (accountObj.UserName != null)
            {
                accountTitle = accountObj.UserName;
            }
            else
            {
                accountTitle = accountObj.Account;
            }
            this.TopFrameLayout(this, accountTitle);
 
            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 VerticalRefreshLayout()
            {
            };
            this.midFrameLayout.AddChidren(bodyView);
            bodyView.BeginHeaderRefreshingAction += async () =>
             {
                 bodyView.BeginHeaderRefreshing();
                 await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock);
                 bodyView.EndHeaderRefreshing();
             };
 
            for (int i = 0; i < 2; i++)
            {
                var RowView = new FrameLayout()
                {
                    Height = Application.GetRealHeight(127 + 23),
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                };
                bodyView.AddChidren(RowView);
 
                var btnMemberName = new Button()
                {
                    X = Application.GetRealWidth(58),
                    Y = Application.GetRealHeight(58),
                    Width = Application.GetRealWidth(743),
                    Height = Application.GetRealHeight(58),
                    TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextSize = 14,
                };
                RowView.AddChidren(btnMemberName);
 
                var btnRight = new Button()
                {
                    X = Application.GetRealWidth(58 + 899),
                    Y = Application.GetRealHeight(58),
                    Height = Application.GetRealHeight(58),
                    Width = Application.GetRealWidth(58),
                    UnSelectedImagePath = "Item/RightNext.png",
                    SelectedImagePath = "Item/Down.png",
                };
                RowView.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);
 
                int currentIndex = i;
                if (i == 0)
                {
                    btnMemberName.Text = Language.StringByID(R.MyInternationalizationString.LockMethod);
                }
                else
                {
                    btnMemberName.Text = Language.StringByID(R.MyInternationalizationString.LinkageEvent);
                    line2.Visible = false;
                }
 
                EventHandler<MouseEventArgs> eHandler = (sender, e) =>
                {
                    if (currentIndex == 0)
                    {
                        var unLockMethod = new Shared.Phone.UserCenter.DoorLock.UnLockMethod(doorLock, accountObj);
                        Shared.Phone.UserView.HomePage.Instance.AddChidren(unLockMethod);
                        Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                        unLockMethod.Show();
                    }
                    else
                    {
                        ///备注:WJC的
                        ///记录当前用户信息
                        Phone.Device.Logic.Send.UserMemberInfoRes = accountObj;
                        Phone.Device.Logic.Send.CurrentDoorLock = doorLock;
                        if (accountObj == null)
                        {
                            ///防止抛异常
                            Phone.Device.Logic.Send.UserMemberInfoRes = new MemberInfoRes();
                        }
                        if (doorLock == null)
                        {
                            ///防止抛异常
                            Phone.Device.Logic.Send.CurrentDoorLock = new ZigBee.Device.DoorLock();
                        }
                        ///进来刷新一次设备列表;
                        Common.Logic.LogicDviceList.Clear();
                        if (Common.Logic.LogicDviceList.Count == 0)
                        {
                            Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
                        }
                        var doorLockLogicList = new Phone.Device.Logic.DoorLockLogic.LockLogicList();
                        UserView.HomePage.Instance.AddChidren(doorLockLogicList);
                        UserView.HomePage.Instance.PageIndex += 1;
                        doorLockLogicList.Show();
                    }
                };
                btnRight.MouseUpEventHandler += eHandler;
                RowView.MouseUpEventHandler += eHandler;
                btnMemberName.MouseUpEventHandler += eHandler;
            }
        }
    }
}