hxb
2020-12-17 5eeafe3af80bfd88306bd8ad9e76c8f4b51ca35f
HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs
@@ -7,10 +7,14 @@
namespace HDL_ON.UI
{
    /// <summary>
    /// 使用权限页面
    /// </summary>
    public partial class MemberPermissionPage : FrameLayout
    {
        MemberPermissionPage bodyView;
        Button btnDelMember;
        VerticalScrolViewLayout roomListView;
        ResidenceMemberInfo memberInfo;
@@ -54,25 +58,51 @@
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                Text = memberInfo.Nickname + "(" + memberInfo.UserName + ")",
                Text = memberInfo.nickName + "(" + memberInfo.Account + ")",
            };
            headPortraitView.AddChidren(btnMemberName);
            #region RoomList
            FrameLayout contentView = new FrameLayout()
            roomListView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(138),
                Height = Application.GetRealHeight(485),
                Height = Application.GetRealHeight(471),
                //BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(roomListView);
            #endregion
            btnDelMember = new Button()
            {
                Y = Application.GetRealHeight(617),
                //Height = MainPage.Increase ? Application.GetRealHeight(70) : Application.GetRealHeight(50),
                Height = Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.WarningColor,
                TextID = StringId.RemoveTheMember,
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(contentView);
            bodyView.AddChidren(btnDelMember);
            LoadEventList();
            GetShareDataByAccount();
        }
        /// <summary>
        /// 加载房间列表,统计分享的数据
        /// </summary>
        void ShowRoomListView()
        {
            roomListView.RemoveAll();
            var titleView = new FrameLayout()
            {
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Height = Application.GetRealWidth(44),
            };
            contentView.AddChidren(titleView);
            roomListView.AddChidren(titleView);
            var btnTitle = new Button()
            {
@@ -92,23 +122,25 @@
                Height = Application.GetRealHeight(1),
                BackgroundColor = CSS_Color.DividingLineColor,
            };
            contentView.AddChidren(btnLine);
            roomListView.AddChidren(btnLine);
            //---------------------------------------------
            var roomListView = new VerticalScrolViewLayout()
            {
                Y = btnLine.Bottom,
                Height = Application.GetRealHeight(440),
            };
            contentView.AddChidren(roomListView);
            //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)
            //List<Function> funss = new List<Function>();
            //if (memberInfo.CurResidenceShareDate.Count > 0)
            //{
            //    foreach (var sd in memberInfo.CurResidenceShareDate)
            //    {
            //        funss.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<ShareData>(System.Text.Encoding.UTF8.GetString(sd.ShareDataBytes)));
            //    }
            //}
            foreach (var room in SpatialInfo.CurrentSpatial.RoomList)
            {
                var roomView = new FrameLayout()
                {
@@ -126,20 +158,31 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    Text = room.name,
                    Text = room.roomName,
                };
                roomView.AddChidren(btnRoomName);
                //计算已经加入房间的设备数量
                int addCount = 0;
                foreach (var d in memberInfo.sharedDatas)
                foreach (var sd in memberInfo.CurResidenceShareDate)
                {
                    foreach(var f in funss)
                    if (room.GetRoomFunctions(false).Find((obj) => obj.deviceId == sd.shareTypeId) != null)
                    {
                        if (room.functions.Find((obj) => obj.sid == f.sid) != null)
                        {
                            addCount++;
                        }
                        addCount++;
                    }
                }
                //移除当前住宅已经不存在的功能
                for (int i = 0; i < memberInfo.CurResidenceShareDate.Count;)
                {
                    var sd = memberInfo.CurResidenceShareDate[i];
                    if (FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.deviceId == sd.shareTypeId) == null)
                    {
                        //new DAL.Server.HttpServerRequest().DeleteShareData(sd);
                        memberInfo.CurResidenceShareDate.Remove(sd);
                    }
                    else
                    {
                        i++;
                    }
                }
@@ -152,7 +195,7 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                    Text = addCount + "/" + room.functions.Count.ToString(),
                    Text = addCount + "/" + room.GetRoomFunctions(false).Count.ToString(),
                };
                roomView.AddChidren(btnFunctionCount);
@@ -168,17 +211,20 @@
                EventHandler<MouseEventArgs> eHandler = (sender, e) =>
                {
                    var mmp = new MemberFunctionPermissionPage(memberInfo,room);
                    Action<string> refreshFunctionCount = (newCount) => {
                        btnFunctionCount.Text = newCount + "/" + room.GetRoomFunctions(false).Count.ToString();
                    };
                    var mmp = new MemberFunctionPermissionPage(memberInfo, room, refreshFunctionCount);
                    MainPage.BasePageView.AddChidren(mmp);
                    mmp.LoadPage();
                    mmp.LoadPage(StringId.PermissionToUse);
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                roomView.MouseUpEventHandler = eHandler;
                btnRoomName.MouseUpEventHandler = eHandler;
                btnRight.MouseUpEventHandler = eHandler;
                btnFunctionCount.MouseUpEventHandler = eHandler;
                if (DB_ResidenceData.residenceData.rooms.IndexOf(room) < DB_ResidenceData.residenceData.rooms.Count - 2)
                if (SpatialInfo.CurrentSpatial.RoomList.IndexOf(room) < SpatialInfo.CurrentSpatial.RoomList.Count - 2)
                {
                    var btnRoomLine = new Button()
                    {
@@ -192,36 +238,20 @@
                }
            }
            if (DB_ResidenceData.residenceData.rooms.Count > 10)
            {
                roomListView.ScrollEnabled = true;
            }
            else
            {
                roomListView.ScrollEnabled = false;
            //if (DB_ResidenceData.rooms.Count > 10)
            //{
            //    roomListView.ScrollEnabled = true;
            //}
            //else
            //{
            //    roomListView.ScrollEnabled = false;
                roomListView.AddChidren(new Button()
                {
                    Height = Application.GetRealWidth(441),
                    BackgroundColor = CSS_Color.BackgroundColor,
                });
            }
            #endregion
            btnDelMember = new Button()
            {
                Y = Application.GetRealHeight(617),
                Height = MainPage.Increase ? Application.GetRealHeight(70) : Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.WarningColor,
                TextID = StringId.RemoveTheMember,
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(btnDelMember);
            LoadEventList();
            //    roomListView.AddChidren(new Button()
            //    {
            //        Height = Application.GetRealWidth(441),
            //        BackgroundColor = CSS_Color.BackgroundColor,
            //    });
            //}
        }
    }
}