From cd1029a11d96f55337430cec97b7d4cd510f5d5f Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 17 十二月 2020 15:09:38 +0800
Subject: [PATCH] 2020-12-17 1.成员管理UI还原度修改。2.增加右键删除。3.增加无区域功能管理。

---
 HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs |  235 +++++++++++++++++++++++-----------------------------------
 1 files changed, 92 insertions(+), 143 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs
index dea9002..9798f7e 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/MemberManagement/MemberPermissionPage.cs
@@ -4,11 +4,12 @@
 using HDL_ON.Entity;
 using System.Collections.Generic;
 using HDL_ON.DAL;
+using HDL_ON.DAL.Server;
 
 namespace HDL_ON.UI
 {
     /// <summary>
-    /// 浣跨敤鏉冮檺椤甸潰
+    /// 鎴愬憳鏉冮檺绠$悊椤甸潰
     /// </summary>
     public partial class MemberPermissionPage : FrameLayout
     {
@@ -30,7 +31,7 @@
         public void LoadPage()
         {
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
-            new TopViewDiv(bodyView, Language.StringByID(StringId.PermissionToUse)).LoadTopView();
+            new TopViewDiv(bodyView, Language.StringByID(StringId.MemberPermissionManagement)).LoadTopView();
 
             FrameLayout headPortraitView = new FrameLayout()
             {
@@ -131,6 +132,7 @@
             List<Function> allFunctionList = FunctionList.List.GetDeviceFunctionList();
             //鏈垎閰嶅尯鍩熺殑鍔熻兘
             List<Function> unallocatedList = new List<Function>();
+            //
             foreach (var function in allFunctionList)
             {
                 function.roomIds.Remove(null);
@@ -145,14 +147,14 @@
             }
 
             //绉婚櫎褰撳墠浣忓畢宸茬粡涓嶅瓨鍦ㄧ殑鍔熻兘
-            for (int i = 0; i < memberInfo.CurResidenceShareDate.Count;)
+            for (int i = 0; i < memberInfo.CurResidenceShareData.Count;)
             {
-                var sd = memberInfo.CurResidenceShareDate[i];
+                var sd = memberInfo.CurResidenceShareData[i];
                 if (allFunctionList.Find((obj) => obj.deviceId == sd.shareTypeId) == null)
                 {
                     //new DAL.Server.HttpServerRequest().DeleteShareData(sd);
                     //寰呯‘璁ゆ槸鍚﹀悓姝ヤ簯绔垹闄ゅ垎浜�
-                    memberInfo.CurResidenceShareDate.Remove(sd);
+                    memberInfo.CurResidenceShareData.Remove(sd);
                 }
                 else
                 {
@@ -160,118 +162,57 @@
                 }
             }
 
-            foreach (var room in SpatialInfo.CurrentSpatial.RoomList)
+            try
             {
-                var roomView = new RowLayout()
+                //閬嶅巻鍔犺浇鎴块棿鍒嗕韩涓暟缁熻鐘舵�丷owLayout
+                foreach (var room in SpatialInfo.CurrentSpatial.RoomList)
                 {
-                    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,
-                    Text = room.roomName,
-                };
-                roomView.AddChidren(btnRoomName);
-
-                //璁$畻宸茬粡鍔犲叆鎴块棿鐨勮澶囨暟閲�
-                int addCount = 0;
-                foreach (var sd in memberInfo.CurResidenceShareDate)
-                {
-                    if (room.GetRoomFunctions(false).Find((obj) => obj.deviceId == sd.shareTypeId) != null)
-                    {
-                        addCount++;
-                    }
+                    AddRoomFunctionRowLayout(room);
                 }
-                ////绉婚櫎褰撳墠浣忓畢宸茬粡涓嶅瓨鍦ㄧ殑鍔熻兘
-                //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()
-                {
-                    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.GetRoomFunctions(false).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);
-                //鍒嗗壊绾�
-                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 + "/" + room.GetRoomFunctions(false).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;
+                //2020-12-16 鍔犺浇鏈垎閰嶅尯鍩熷姛鑳絉owLayout
+                AddNoAreaFunctionRowLayout(unallocatedList);
             }
-
-            //2020-12-16 鍔犺浇鏈垎閰嶅尯鍩熷姛鑳�
-            AddNoAreaFunction(unallocatedList);
+            catch
+            {
+                Utlis.WriteLine("AddRoomFunctionRowLayout error");
+            }
         }
 
         /// <summary>
-        /// 娣诲姞鏈垎閰嶅尯鍩熷姛鑳�
+        /// 娣诲姞鎴块棿鍒嗕韩涓暟缁熻鐘舵�佺殑RowLayout
         /// </summary>
-        /// <param name="unallocatedList"></param>
-        void AddNoAreaFunction(List<Function> unallocatedList)
+        /// <param name="mRoom"></param>
+        void AddRoomFunctionRowLayout(Room mRoom)
         {
+            ShowBaseRoomFunOrNoAreaFunRowLayout(mRoom, null);
+        }
+
+        /// <summary>
+        /// 娣诲姞鏈垎閰嶅尯鍩熷姛鑳� 鐨勪釜鏁扮粺璁$姸鎬佺殑RowLayout
+        /// </summary>
+        /// <param name="unallocatedList">鏈垎閰嶇殑鎵�鏈夊姛鑳藉垪琛�</param>
+        void AddNoAreaFunctionRowLayout(List<Function> unallocatedList)
+        {
+            ShowBaseRoomFunOrNoAreaFunRowLayout(null, unallocatedList);
+        }
+
+        /// <summary>
+        /// 2020-12-17 閲嶆柊璋冩暣
+        /// 娣诲姞鎴块棿鍒嗕韩鎴栬�呮棤鍖哄煙鍒嗛厤 涓暟缁熻鐘舵�佺殑RowLayout
+        /// </summary>
+        /// <param name="room">濡傛灉鎴块棿涓虹┖锛屼唬琛ㄧ鐞嗘棤鍒嗛厤鍖哄煙</param>
+        /// <param name="unallocatedList">绠$悊鏃犲垎閰嶅尯鍩熸墠鏈夋晥</param>
+        void ShowBaseRoomFunOrNoAreaFunRowLayout(Room mRoom, List<Function> unallocatedList)
+        {
+            /// 褰撳墠鎴块棿鎴栬�呮棤鍒嗛厤鍖哄煙鍒嗕韩鍒楄〃
+            List<ShareData> funs_RoomAll = new List<ShareData>();
+            /// <summary>
+            /// 鎴块棿鎴栬�呮棤鍒嗛厤鍖哄煙鎵�鏈夊姛鑳藉垪琛�
+            /// </summary>
+            List<Function> roomFunctionList = new List<Function>();
+            /// 鎴块棿ID
+            string roomId = "";
+
             var roomView = new RowLayout()
             {
                 Height = Application.GetRealWidth(50),
@@ -289,33 +230,25 @@
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.TextFontSize,
-                TextID = StringId.NoAreaFunction
+                //Text = room.roomName,
             };
             roomView.AddChidren(btnRoomName);
 
-            //璁$畻宸茬粡鍔犲叆鎴块棿鐨勮澶囨暟閲�
-            int addCount = 0;
-            foreach (var sd in memberInfo.CurResidenceShareDate)
+            //濡傛灉鎴块棿涓虹┖锛屼唬琛ㄧ鐞嗘棤鍒嗛厤鍖哄煙
+            if (mRoom != null)
             {
-                if (unallocatedList.Find((obj) => obj.deviceId == sd.shareTypeId) != null)
-                {
-                    addCount++;
-                }
+                //鏄剧ず鎴块棿鍚�
+                btnRoomName.Text = mRoom.roomName;
+                roomFunctionList = mRoom.GetRoomFunctions(false);
+                roomId = mRoom.roomId;
             }
-            ////绉婚櫎褰撳墠浣忓畢宸茬粡涓嶅瓨鍦ㄧ殑鍔熻兘
-            //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++;
-            //    }
-            //}
+            else
+            {
+                //鏄剧ず鏃犲尯鍩熷姛鑳�
+                btnRoomName.TextID = StringId.NoAreaFunction;
+                roomFunctionList = unallocatedList;
+                roomId = null;
+            }
 
             var btnFunctionCount = new Button()
             {
@@ -326,7 +259,7 @@
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.PromptingColor1,
                 TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
-                Text = addCount + "/" + unallocatedList.Count.ToString(),
+                //Text = addCount + "/" + room.GetRoomFunctions(false).Count.ToString(),
             };
             roomView.AddChidren(btnFunctionCount);
 
@@ -339,9 +272,9 @@
                 UnSelectedImagePath = "Public/Right.png",
             };
             roomView.AddChidren(btnRight);
-            ////鍒嗗壊绾�
-            //var lineView = new LineView(roomView.Height - Application.GetRealHeight(1));
-            //roomView.AddChidren(lineView);
+            //鍒嗗壊绾�
+            var lineView = new LineView(roomView.Height - Application.GetRealHeight(1));
+            roomView.AddChidren(lineView);
             //鍒犻櫎鎸夐挳
             var deleteBtn = new Button()
             {
@@ -353,25 +286,41 @@
             roomView.AddRightView(deleteBtn);
             deleteBtn.MouseUpEventHandler = (sender, e) =>
             {
-                //鍒犻櫎浜嬩欢
+                //涓�閿垹闄ゆ墍鏈夊垎浜�
+                DeleteRoomAllShare(funs_RoomAll, roomFunctionList, roomId, btnFunctionCount, roomView);
             };
 
+            //璁$畻宸茬粡鍔犲叆鎴块棿鐨勮澶囨暟閲忕殑Action浜嬩欢
+            Action RefreshAction = () => {
+                funs_RoomAll = new List<ShareData>();
+                int addCount = 0;
+                foreach (var sd in memberInfo.CurResidenceShareData)
+                {
+                    if (roomFunctionList.Find((obj) => obj.deviceId == sd.shareTypeId) != null)
+                    {
+                        addCount++;
+                        funs_RoomAll.Add(sd);
+                    }
+                }
+                btnFunctionCount.Text = addCount + "/" + roomFunctionList.Count.ToString();
+                //Utlis.WriteLine("鍒锋柊鎴愬姛");
+            };
+            //鐐瑰嚮璋冩暣浜嬩欢
             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;
+                var mmp = new MemberFunctionPermissionPage(memberInfo, roomFunctionList, funs_RoomAll, roomId, RefreshAction);
+                MainPage.BasePageView.AddChidren(mmp);
+                mmp.LoadPage(StringId.MemberPermissionManagement);
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
             };
             roomView.MouseUpEventHandler = eHandler;
             btnRoomName.MouseUpEventHandler = eHandler;
             btnRight.MouseUpEventHandler = eHandler;
             btnFunctionCount.MouseUpEventHandler = eHandler;
 
-           
+            RefreshAction?.Invoke();
         }
+
+
     }
 }

--
Gitblit v1.8.0