wxr
2020-06-08 b71dfb3ca100340005d56e1298292807da82322d
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
using System;
using HDL_ON.UI.CSS;
using Shared;
using HDL_ON.Entity;
using System.Collections.Generic;
using HDL_ON.DAL;
 
namespace HDL_ON.UI
{
    public partial class MemberPermissionPage : FrameLayout
    {
        MemberPermissionPage bodyView;
 
        ResidenceMemberInfo memberInfo;
 
        public MemberPermissionPage(ResidenceMemberInfo mInfo)
        {
            bodyView = this;
            memberInfo = mInfo;
        }
 
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, Language.StringByID(StringId.PermissionToUse)).LoadTopView();
 
            FrameLayout headPortraitView = new FrameLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(66),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(headPortraitView);
 
            ImageView userHeadImageView = new ImageView()
            {
                X = Application.GetRealWidth(16),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(42),
                Height = Application.GetRealWidth(42),
                Radius = (uint)Application.GetRealWidth(21),
                ImagePath = memberInfo.headImagePagePath
            };
            headPortraitView.AddChidren(userHeadImageView);
 
            Button btnMemberName = new Button()
            {
                X = Application.GetRealWidth(70),
                Width = Application.GetRealWidth(300),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                Text = memberInfo.Nickname + "(" + memberInfo.UserName + ")",
            };
            headPortraitView.AddChidren(btnMemberName);
 
            #region RoomList
            FrameLayout contentView = new FrameLayout()
            {
                Y = Application.GetRealHeight(138),
                Height = Application.GetRealHeight(485),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(contentView);
 
            var titleView = new FrameLayout()
            {
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Height = Application.GetRealWidth(44),
            };
            contentView.AddChidren(titleView);
 
            var btnTitle = new Button()
            {
                X = Application.GetRealWidth(16),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.UseArea,
            };
            titleView.AddChidren(btnTitle);
 
            var btnLine = new Button()
            {
                X = Application.GetRealWidth(16),
                Y = btnTitle.Bottom,
                Width = Application.GetRealWidth(360),
                Height = Application.GetRealHeight(1),
                BackgroundColor = CSS_Color.DividingLineColor,
            };
            contentView.AddChidren(btnLine);
 
            //---------------------------------------------
            var roomListView = new VerticalScrolViewLayout()
            {
                Y = btnLine.Bottom,
                Height = Application.GetRealHeight(440),
            };
            contentView.AddChidren(roomListView);
 
            List<Function> funss = new List<Function>();
            if (memberInfo.CurShareData.ShareDataBytes != null)
            {
                funss = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Function>>(
                       CommonPage.MyEncodingUTF8.GetString(memberInfo.CurShareData.ShareDataBytes));
            }
            foreach (var room in DB_ResidenceData.residenceData.rooms)
            {
                var roomView = new FrameLayout()
                {
                    Height = Application.GetRealWidth(50),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                };
                roomListView.AddChidren(roomView);
 
                var btnRoomName = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Y = Application.GetRealWidth(4),
                    Width = Application.GetRealWidth(330),
                    Height = Application.GetRealWidth(24),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    Text = room.name,
                };
                roomView.AddChidren(btnRoomName);
 
                //计算已经加入房间的设备数量
                int addCount = 0;
                foreach (var d in memberInfo.sharedDatas)
                {
                    foreach(var f in funss)
                    {
                        if (room.functions.Find((obj) => obj.sid == f.sid) != null)
                        {
                            addCount++;
                        }
                    }
                }
 
                var btnFunctionCount = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Y = btnRoomName.Bottom,
                    Width = Application.GetRealWidth(330),
                    Height = Application.GetRealWidth(18),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                    Text = addCount + "/" + room.functions.Count.ToString(),
                };
                roomView.AddChidren(btnFunctionCount);
 
                var btnRight = new Button()
                {
                    X = Application.GetRealWidth(351),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetMinRealAverage(16),
                    Height = Application.GetMinRealAverage(16),
                    UnSelectedImagePath = "Public/Right.png",
                };
                roomView.AddChidren(btnRight);
 
                EventHandler<MouseEventArgs> eHandler = (sender, e) =>
                {
                    var mmp = new MemberFunctionPermissionPage(memberInfo,room);
                    MainPage.BasePageView.AddChidren(mmp);
                    mmp.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                roomView.MouseUpEventHandler = eHandler;
                btnRoomName.MouseUpEventHandler = eHandler;
                btnRight.MouseUpEventHandler = eHandler;
 
 
                if (DB_ResidenceData.residenceData.rooms.IndexOf(room) < DB_ResidenceData.residenceData.rooms.Count - 2)
                {
                    var btnRoomLine = new Button()
                    {
                        X = Application.GetRealWidth(16),
                        Y = Application.GetRealWidth(49),
                        Width = Application.GetRealWidth(343),
                        Height = Application.GetRealWidth(1),
                        BackgroundColor = CSS_Color.DividingLineColor,
                    };
                    roomView.AddChidren(btnRoomLine);
                }
            }
 
            if (DB_ResidenceData.residenceData.rooms.Count > 10)
            {
                roomListView.ScrollEnabled = true;
            }
            else
            {
                roomListView.ScrollEnabled = false;
 
                roomListView.AddChidren(new Button()
                {
                    Height = Application.GetRealWidth(441),
                    BackgroundColor = CSS_Color.BackgroundColor,
                });
            }
 
            #endregion
 
 
        }
    }
}