From 3cdd43cee7355743eb554badf5b742e061ab2172 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 17 十二月 2020 10:39:00 +0800
Subject: [PATCH] 2020-12-17 1.成员管理UI还原度优化

---
 HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs |  284 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 217 insertions(+), 67 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs
index 265b3cb..dea9002 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs
+++ b/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,53 @@
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.TextFontSize,
-                Text = memberInfo.Nickname + "(" + memberInfo.UserName + ")",
+                //Text = memberInfo.nickName + "(" + memberInfo.UserName + ")",
             };
             headPortraitView.AddChidren(btnMemberName);
+            string username = HDLCommon.Current.GetUserName(memberInfo.memberName);
+            btnMemberName.Text = memberInfo.nickName + "(" + username + ")";
 
             #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()
             {
@@ -87,33 +119,54 @@
             var btnLine = new Button()
             {
                 X = Application.GetRealWidth(16),
-                Y = btnTitle.Bottom,
+                Y = titleView.Height - Application.GetRealHeight(2),
                 Width = Application.GetRealWidth(360),
                 Height = Application.GetRealHeight(1),
                 BackgroundColor = CSS_Color.DividingLineColor,
             };
-            contentView.AddChidren(btnLine);
+            titleView.AddChidren(btnLine);
 
             //---------------------------------------------
-            var roomListView = new VerticalScrolViewLayout()
+            //鏈垎閰嶅尯鍩熺殑鍔熻兘
+            List<Function> allFunctionList = FunctionList.List.GetDeviceFunctionList();
+            //鏈垎閰嶅尯鍩熺殑鍔熻兘
+            List<Function> unallocatedList = new List<Function>();
+            foreach (var function in allFunctionList)
             {
-                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));
+                function.roomIds.Remove(null);
+                if (function.roomIds.Count > 0)
+                {
+                    //allocatedList.Add(function);
+                }
+                else
+                {
+                    unallocatedList.Add(function);
+                }
             }
-            foreach (var room in DB_ResidenceData.residenceData.rooms)
+
+            //绉婚櫎褰撳墠浣忓畢宸茬粡涓嶅瓨鍦ㄧ殑鍔熻兘
+            for (int i = 0; i < memberInfo.CurResidenceShareDate.Count;)
             {
-                var roomView = new FrameLayout()
+                var sd = memberInfo.CurResidenceShareDate[i];
+                if (allFunctionList.Find((obj) => obj.deviceId == sd.shareTypeId) == null)
+                {
+                    //new DAL.Server.HttpServerRequest().DeleteShareData(sd);
+                    //寰呯‘璁ゆ槸鍚﹀悓姝ヤ簯绔垹闄ゅ垎浜�
+                    memberInfo.CurResidenceShareDate.Remove(sd);
+                }
+                else
+                {
+                    i++;
+                }
+            }
+
+            foreach (var room in SpatialInfo.CurrentSpatial.RoomList)
+            {
+                var roomView = new RowLayout()
                 {
                     Height = Application.GetRealWidth(50),
                     BackgroundColor = CSS_Color.MainBackgroundColor,
+                    LineColor = CSS_Color.MainBackgroundColor,
                 };
                 roomListView.AddChidren(roomView);
 
@@ -126,22 +179,33 @@
                     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 (allFunctionList.Find((obj) => obj.deviceId == sd.shareTypeId) == null)
+                //    {
+                //        //new DAL.Server.HttpServerRequest().DeleteShareData(sd);
+                //        memberInfo.CurResidenceShareDate.Remove(sd);
+                //    }
+                //    else
+                //    {
+                //        i++;
+                //    }
+                //}
 
                 var btnFunctionCount = new Button()
                 {
@@ -152,7 +216,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);
 
@@ -165,63 +229,149 @@
                     UnSelectedImagePath = "Public/Right.png",
                 };
                 roomView.AddChidren(btnRight);
+                //鍒嗗壊绾�
+                var lineView = new LineView(roomView.Height - Application.GetRealHeight(1));
+                roomView.AddChidren(lineView);
+                //鍒犻櫎鎸夐挳
+                var deleteBtn = new Button()
+                {
+                    TextID = StringId.Del,
+                    BackgroundColor = CSS_Color.AuxiliaryColor2,
+                    TextColor = CSS_Color.MainBackgroundColor,
+                    TextSize = CSS_FontSize.TextFontSize,
+                };
+                roomView.AddRightView(deleteBtn);
+                deleteBtn.MouseUpEventHandler = (sender, e) =>
+                {
+                    //鍒犻櫎浜嬩欢
+                };
 
                 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;
+            }
 
+            //2020-12-16 鍔犺浇鏈垎閰嶅尯鍩熷姛鑳�
+            AddNoAreaFunction(unallocatedList);
+        }
 
-                if (DB_ResidenceData.residenceData.rooms.IndexOf(room) < DB_ResidenceData.residenceData.rooms.Count - 2)
+        /// <summary>
+        /// 娣诲姞鏈垎閰嶅尯鍩熷姛鑳�
+        /// </summary>
+        /// <param name="unallocatedList"></param>
+        void AddNoAreaFunction(List<Function> unallocatedList)
+        {
+            var roomView = new RowLayout()
+            {
+                Height = Application.GetRealWidth(50),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                LineColor = 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,
+                TextID = StringId.NoAreaFunction
+            };
+            roomView.AddChidren(btnRoomName);
+
+            //璁$畻宸茬粡鍔犲叆鎴块棿鐨勮澶囨暟閲�
+            int addCount = 0;
+            foreach (var sd in memberInfo.CurResidenceShareDate)
+            {
+                if (unallocatedList.Find((obj) => obj.deviceId == sd.shareTypeId) != null)
                 {
-                    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);
+                    addCount++;
                 }
             }
+            ////绉婚櫎褰撳墠浣忓畢宸茬粡涓嶅瓨鍦ㄧ殑鍔熻兘
+            //for (int i = 0; i < memberInfo.CurResidenceShareDate.Count;)
+            //{
+            //    var sd = memberInfo.CurResidenceShareDate[i];
+            //    if (allFunctionList.Find((obj) => obj.deviceId == sd.shareTypeId) == null)
+            //    {
+            //        //new DAL.Server.HttpServerRequest().DeleteShareData(sd);
+            //        memberInfo.CurResidenceShareDate.Remove(sd);
+            //    }
+            //    else
+            //    {
+            //        i++;
+            //    }
+            //}
 
-            if (DB_ResidenceData.residenceData.rooms.Count > 10)
+            var btnFunctionCount = new Button()
             {
-                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,
+                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 + "/" + unallocatedList.Count.ToString(),
             };
-            bodyView.AddChidren(btnDelMember);
+            roomView.AddChidren(btnFunctionCount);
 
-            LoadEventList();
+            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);
+            ////鍒嗗壊绾�
+            //var lineView = new LineView(roomView.Height - Application.GetRealHeight(1));
+            //roomView.AddChidren(lineView);
+            //鍒犻櫎鎸夐挳
+            var deleteBtn = new Button()
+            {
+                TextID = StringId.Del,
+                BackgroundColor = CSS_Color.AuxiliaryColor2,
+                TextColor = CSS_Color.MainBackgroundColor,
+                TextSize = CSS_FontSize.TextFontSize,
+            };
+            roomView.AddRightView(deleteBtn);
+            deleteBtn.MouseUpEventHandler = (sender, e) =>
+            {
+                //鍒犻櫎浜嬩欢
+            };
+
+            EventHandler<MouseEventArgs> eHandler = (sender, e) =>
+            {
+                Action<string> refreshFunctionCount = (newCount) => {
+                    btnFunctionCount.Text = newCount + "/" + unallocatedList.Count.ToString();
+                };
+                //var mmp = new MemberFunctionPermissionPage(memberInfo, room, refreshFunctionCount);
+                //MainPage.BasePageView.AddChidren(mmp);
+                //mmp.LoadPage(StringId.PermissionToUse);
+                //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+            roomView.MouseUpEventHandler = eHandler;
+            btnRoomName.MouseUpEventHandler = eHandler;
+            btnRight.MouseUpEventHandler = eHandler;
+            btnFunctionCount.MouseUpEventHandler = eHandler;
+
+           
         }
     }
 }

--
Gitblit v1.8.0