From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 10 七月 2020 10:52:13 +0800
Subject: [PATCH] 2020-07-10-01

---
 ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs |  320 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 204 insertions(+), 116 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs
index dae9d48..658ee39 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Member/MemberManagementForm.cs
@@ -1,10 +1,12 @@
 锘縰sing System;
+using System.Collections.Generic;
+
 namespace Shared.Phone.UserCenter.Member
 {
     /// <summary>
     /// 鎴愬憳淇℃伅绠$悊
     /// </summary>
-    public class MemberManagementForm : UserCenterCommonForm
+    public class MemberManagementForm : EditorCommonForm
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
@@ -13,17 +15,13 @@
         /// </summary>
         private MemberInfoRes memberInfo = null;
         /// <summary>
-        /// TopFrameLayout
-        /// </summary>
-        private SpecialFrameLayout specialTopFrame = null;
-        /// <summary>
         /// 绠$悊鍛樻潈闄愬浘鏍囨帶浠�
         /// </summary>
-        private TopLayoutMostRightView btnTopIcon = null;
+        private MostRightIconControl btnTopIcon = null;
         /// <summary>
         /// 鏉冮檺鐨勭炕璇戝悕鎺т欢
         /// </summary>
-        private ViewNormalControl btnAuthority = null;
+        private NormalViewControl btnAuthority = null;
 
         #endregion
 
@@ -38,10 +36,8 @@
             this.memberInfo = info;
 
             //璁剧疆鏍囬淇℃伅
-            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.MenberManagement));
-
-            //涓轰簡鑳藉鏄剧ず妯″潡鍥炬牱
-            bodyFrameLayout.BackgroundColor = UserCenterColor.Current.TopFrameLayout;
+            string title = string.IsNullOrEmpty(info.UserName) == true ? info.Account : info.UserName;
+            base.SetTitleText(title);
 
             //鍒濆鍖栧彸涓婅鐨勫浘鏍�
             this.InitTopRightIcon();
@@ -60,25 +56,35 @@
                 return;
             }
             //绠$悊鍛樻潈闄愬浘鏍�
-            btnTopIcon = new TopLayoutMostRightView();
+            btnTopIcon = new MostRightIconControl(69, 69);
             if (memberInfo.AccountType == 1)
             {
-                btnTopIcon.UnSelectedImagePath = "Account/HadAuthority.png";
+                btnTopIcon.UnSelectedImagePath = "Item/HadAuthority.png";
             }
             else
             {
-                btnTopIcon.UnSelectedImagePath = "Account/NotAuthority.png";
+                btnTopIcon.UnSelectedImagePath = "Item/NotAuthority.png";
             }
             topFrameLayout.AddChidren(btnTopIcon);
-
-            btnTopIcon.MouseUpEventHandler += (sender, e) =>
+            btnTopIcon.InitControl();
+            btnTopIcon.ButtonClickEvent += (sender, e) =>
             {
+                //纭畾鍙栨秷銆寋0}銆嶇鐞嗗憳鏉冮檺锛�
                 string msg = Language.StringByID(R.MyInternationalizationString.uDownSubAccountLevel);
                 if (memberInfo.AccountType != 1)
                 {
+                    //纭畾鎺堟潈銆寋0}銆嶆垚涓虹鐞嗗憳?
                     msg = Language.StringByID(R.MyInternationalizationString.uUpSubAccountLevel);
                 }
-                this.ShowConfirmMsg(msg, "UpOrDownSubAccountLevel");
+                msg = msg.Replace("{0}", string.IsNullOrEmpty(memberInfo.UserName) == true ? memberInfo.Account : memberInfo.UserName);
+
+                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                 {
+                     //浜屾瀹夊叏楠岃瘉,濡傛灉娌℃湁璁剧疆鏈�,鐩存帴璺宠繃楠岃瘉
+                     HdlCheckLogic.Current.CheckSecondarySecurity(
+                         () => { this.UpOrDownSubAccountLevel(); },
+                         () => { this.UpOrDownSubAccountLevel(); });
+                 });
             };
         }
 
@@ -87,6 +93,9 @@
         /// </summary>
         private void InitMiddleFrame()
         {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
             //鍒濆鍖栫敤鎴峰浘鏍�
             this.InitMenberIconControl();
 
@@ -99,42 +108,45 @@
         /// </summary>
         private void InitMenberIconControl()
         {
-            this.specialTopFrame = new SpecialFrameLayout(400, 10);
-            specialTopFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
-            bodyFrameLayout.AddChidren(specialTopFrame);
+            var frame = new FrameLayout();
+            frame.Height = Application.GetRealHeight(372);
+            frame.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(frame);
 
             //鐢ㄦ埛鍥炬爣
-            var btnUserIcon = new ProfilePhotoControl();
-            btnUserIcon.Y = Application.GetRealHeight(40);
+            string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, memberInfo.DistributedMark + ".png");
+            var btnUserIcon = new ImageView();
+            btnUserIcon.Height = this.GetPictrueRealSize(207);
+            btnUserIcon.Width = this.GetPictrueRealSize(207);
+            btnUserIcon.Radius = (uint)this.GetPictrueRealSize(207) / 2;
+            if (System.IO.File.Exists(iconPath) == true)
+            {
+                btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(iconPath);
+            }
+            else
+            {
+                btnUserIcon.ImagePath = "Center/Admin.png";
+            }
+            btnUserIcon.Y = Application.GetRealHeight(45);
             btnUserIcon.Gravity = Gravity.CenterHorizontal;
-            btnUserIcon.UnSelectedImagePath = "Account/Admin.png";
-            this.specialTopFrame.AddChidren(btnUserIcon);
+            frame.AddChidren(btnUserIcon);
+            //鑾峰彇鎴愬憳澶村儚
+            this.GetMemberIcon(btnUserIcon);
 
             //鏉冮檺
-            btnAuthority = new ViewNormalControl(800, true);
+            btnAuthority = new NormalViewControl(800, 50, true);
             btnAuthority.TextAlignment = TextAlignment.Center;
-            btnAuthority.Y = btnUserIcon.Bottom + Application.GetRealHeight(10);
+            btnAuthority.TextSize = 12;
+            btnAuthority.Y = btnUserIcon.Bottom + Application.GetRealHeight(23);
             btnAuthority.Gravity = Gravity.CenterHorizontal;
-            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor;
+            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor1;
             btnAuthority.TextID = R.MyInternationalizationString.uMember;
             if (memberInfo.AccountType == 1)
             {
                 //鎷ユ湁绠$悊鍛樻潈闄�
                 btnAuthority.TextID = R.MyInternationalizationString.uMemberHadActionAuthority;
             }
-            this.specialTopFrame.AddChidren(btnAuthority);
-
-            //鏄电О
-            var btnName = new ViewNormalControl(800, true);
-            btnName.TextAlignment = TextAlignment.Center;
-            btnName.Y = btnAuthority.Bottom + Application.GetRealHeight(10);
-            btnName.Text = memberInfo.UserName;
-            btnName.Gravity = Gravity.CenterHorizontal;
-            this.specialTopFrame.AddChidren(btnName, HeightAutoMode.IncreaseOnly);
-            if (string.IsNullOrEmpty(memberInfo.UserName) == true)
-            {
-                btnName.Text = memberInfo.Account;
-            }
+            frame.AddChidren(btnAuthority);
         }
 
         #endregion
@@ -146,65 +158,69 @@
         /// </summary>
         private void InitInfoList()
         {
-            //鍒涘缓涓�涓狥rameLayout
-            var frameLayout = new FrameLayout();
-            frameLayout.Height = bodyFrameLayout.Height - specialTopFrame.Height - Application.GetRealHeight(50);
-            frameLayout.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
-            frameLayout.Y = specialTopFrame.Bottom + Application.GetRealHeight(50);
-            bodyFrameLayout.AddChidren(frameLayout);
-
             //鏍囬:鎴愬憳鏉冮檺
-            var btnMenberTile = new ViewNormalControl(800, true);
+            var btnMenberTile = new NormalViewControl(800, 60, true);
             btnMenberTile.X = ControlCommonResourse.XXLeft;
-            btnMenberTile.Y = Application.GetRealHeight(20);
+            btnMenberTile.Y = Application.GetRealHeight(418);
+            btnMenberTile.TextColor = UserCenterColor.Current.TextColor2;
             btnMenberTile.TextID = R.MyInternationalizationString.MenberAuthority;
-            frameLayout.AddChidren(btnMenberTile);
+            btnMenberTile.TextSize = 15;
+            bodyFrameLayout.AddChidren(btnMenberTile);
+
+            var frame = new FrameListControl();
+            frame.Height = Application.GetRealHeight(311);
+            frame.BackgroundColor = UserCenterColor.Current.White;
+            frame.Y = Application.GetRealHeight(501);
+            bodyFrameLayout.AddChidren(frame);
+
+            //濉炰竴涓┖鐧界殑杩涘幓鍗犵┖闂�
+            var rowTemp = new FrameRowControl();
+            rowTemp.UseClickStatu = false;
+            rowTemp.Height = Application.GetRealHeight(23) - frame.rowSpace;
+            frame.AddChidren(rowTemp);
 
             //娣诲姞杩滅▼鎿嶄綔琛�
-            var rowLayout = new RowLayout();
-            rowLayout.Y = btnMenberTile.Bottom + Application.GetRealHeight(10);
-            rowLayout.Height = ControlCommonResourse.ListViewRowHeight;
-            frameLayout.AddChidren(rowLayout);
-            this.AddRemoteRow(rowLayout);
+            var rowRemote = new FrameRowControl(frame.rowSpace / 2);
+            rowRemote.UseClickStatu = false;
+            frame.AddChidren(rowRemote);
+            this.AddRemoteRow(rowRemote);
 
             //娣诲姞宸插叡浜唴瀹硅
-            var rowDevice = new StatuRowLayout();
-            rowDevice.Y = rowLayout.Bottom;
-            frameLayout.AddChidren(rowDevice);
-            this.AddShardContentRow(rowDevice);
-
-            //娣诲姞鐢婚潰搴曢儴鐨勮鏄�
-            var frameNote = new FrameLayout();
-            frameNote.Height = ControlCommonResourse.NormalControlHeight * 2;
-            frameNote.Y = Application.GetRealHeight(680);
-            frameLayout.AddChidren(frameNote);
+            var rowShard = new FrameRowControl(frame.rowSpace / 2);
+            frame.AddChidren(rowShard);
+            this.AddShardContentRow(rowShard);
 
             //涓�鏃︾Щ闄よ瀹跺涵鎴愬憳锛屼粬/濂瑰皢鏃犳硶浣跨敤璇ョ綉鍏充笅鎵�缁戝畾鐨勮澶�
-            Button btnNote1 = new ViewNormalControl(Application.GetRealWidth(800), ControlCommonResourse.NormalControlHeight * 2, false);
+            var btnNote1 = new NormalViewControl(613, 100, true);
+            btnNote1.X = Application.GetRealWidth(248);
+            btnNote1.Y = Application.GetRealHeight(1327);
+            btnNote1.TextSize = 12;
             btnNote1.TextID = R.MyInternationalizationString.RemoveMenberAndDonotUserBindGatewayDevice;
             btnNote1.IsMoreLines = true;
-            btnNote1.TextColor = UserCenterColor.Current.Gray;
-            btnNote1.Gravity = Gravity.CenterHorizontal;
+            btnNote1.TextColor = UserCenterColor.Current.TextGrayColor1;
             btnNote1.TextAlignment = TextAlignment.Center;
-            frameNote.AddChidren(btnNote1);
+            bodyFrameLayout.AddChidren(btnNote1);
 
-            var btnIcon = new IconViewControl(80);
-            btnIcon.X = btnNote1.X - Application.GetRealWidth(80);
+            var btnIcon = new IconViewControl(58);
+            btnIcon.X = Application.GetRealWidth(167);
+            btnIcon.Y = btnNote1.Y;
             btnIcon.UnSelectedImagePath = "Item/Tips.png";
-            btnIcon.Gravity = Gravity.CenterVertical;
-            frameNote.AddChidren(btnIcon);
+            bodyFrameLayout.AddChidren(btnIcon);
 
             //娣诲姞绉婚櫎鎸夐挳
             var btnDelete = new BottomClickButton();
             btnDelete.TextID = R.MyInternationalizationString.RemoveBotton;
-            btnDelete.Y = frameNote.Bottom + Application.GetRealHeight(100);
-            btnDelete.BackgroundColor = UserCenterColor.Current.Red;
-            frameLayout.AddChidren(btnDelete);
-            btnDelete.MouseUpEventHandler += (sender, e) =>
+            btnDelete.BackgroundColor = 0xfff75858;
+            bodyFrameLayout.AddChidren(btnDelete);
+            btnDelete.ButtonClickEvent += (sender, e) =>
             {
                 //纭畾瑕佺Щ闄よ瀹跺涵鎴愬憳鍚楋紵
                 string msg = Language.StringByID(R.MyInternationalizationString.uConfirmRemoveMember);
-                this.ShowConfirmMsg(msg, "DeleteSubAccount");
+                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                {
+                    //鍒犻櫎瀛愯处鍙�
+                    this.DeleteSubAccount();
+                });
             };
         }
 
@@ -216,26 +232,54 @@
         /// 娣诲姞杩滅▼鎿嶄綔琛�
         /// </summary>
         /// <param name="row">Row.</param>
-        private void AddRemoteRow(RowLayout row)
+        private void AddRemoteRow(FrameRowControl row)
         {
             //鍥炬爣
-            var btnIcon = new RowLeftIconView();
+            var btnIcon = row.AddLeftIcon(81);
             btnIcon.UnSelectedImagePath = "Item/Remote.png";
-            btnIcon.SelectedImagePath = "Item/RemoteSelected.png";
-            row.AddChidren(btnIcon);
 
             //鏂囧瓧:杩滅▼鎿嶄綔
-            var btnName = new RowCenterView(true);
+            var btnName = row.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.RemoteManipulation), 500);
             btnName.TextID = R.MyInternationalizationString.RemoteManipulation;
-            row.AddChidren(btnName);
+            btnName.TextSize = 15;
 
             //寮�鍏�
-            var btnSwitch = new SwichControl();
-            row.AddChidren(btnSwitch);
-            btnSwitch.MouseUpEventHandler += (sender, e) =>
+            var btnSwitch = row.AddMostRightSwitchIcon();
+            if (this.memberInfo.IsAllowRemoteCtrl == true)
             {
-                btnSwitch.IsSelected = !btnSwitch.IsSelected;
+                btnSwitch.IsSelected = true;
+            }
+            btnSwitch.ButtonClickEvent += (sender, e) =>
+            {
+                HdlThreadLogic.Current.RunThread(async () =>
+                {
+                    var pra = new
+                    {
+                        HouseDistributedMark = Common.Config.Instance.Home.Id,
+                        DistributedMark = this.memberInfo.DistributedMark,
+                        IsAllowRemoteCtrl = !btnSwitch.IsSelected
+                    };
+                    //鎵撳紑杩涘害鏉�
+                    this.ShowProgressBar();
+                    var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ChangeSubAccountIsAllowRemoteCtrl", false, pra);
+                    //鍏抽棴杩涘害鏉�
+                    this.CloseProgressBar();
+
+                    if (result == false)
+                    {
+                        return;
+                    }
+                    this.memberInfo.IsAllowRemoteCtrl = !btnSwitch.IsSelected;
+
+                    Application.RunOnMainThread(() =>
+                    {
+                        btnSwitch.IsSelected = !btnSwitch.IsSelected;
+                    });
+                });
+      
             };
+            //搴曠嚎
+            row.AddBottomLine();
         }
 
         #endregion
@@ -246,27 +290,25 @@
         /// 娣诲姞宸插叡浜唴瀹硅
         /// </summary>
         /// <param name="row">Row.</param>
-        private void AddShardContentRow(StatuRowLayout row)
+        private void AddShardContentRow(FrameRowControl row)
         {
             //鍥炬爣
-            var btnIcon = new RowLeftIconView();
-            btnIcon.UnSelectedImagePath = "Item/ShardDevice.png";
-            btnIcon.SelectedImagePath = "Item/ShardDeviceSelected.png";
-            row.AddChidren(btnIcon);
+            var btnIcon = row.AddLeftIcon(81);
+            btnIcon.UnSelectedImagePath = "Item/ShardMenu.png";
 
-            //鏂囧瓧:宸插叡浜唴瀹硅
-            var btnName = new RowCenterView(true);
-            btnName.TextID = R.MyInternationalizationString.uHadSharedContent;
-            row.AddChidren(btnName);
+            //鍏变韩
+            var btnName = row.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uShared2), 500);
+            btnName.TextID = R.MyInternationalizationString.uShared2;
+            btnName.TextSize = 15;
 
             //鍙冲浘鏍�
-            row.AddRightIconControl();
+            row.AddRightArrow();
 
             var memberShardInfo = new MemberShardInfoData();
-            row.MouseUpEvent += (sender, e) =>
+            row.ButtonClickEvent += (sender, e) =>
             {
-                var form = new SharedContent.SearchConfigureSharedListRoomForm();
-                this.AddForm(form, memberInfo, memberShardInfo);
+                var form = new SharedContent.LookSharedListRoomForm();
+                form.AddForm(memberInfo, memberShardInfo);
             };
         }
 
@@ -285,7 +327,7 @@
             var pra = new UpOrDownLevelPra();
             pra.DistributedMark = memberInfo.DistributedMark;
 
-            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpSubAccount", pra);
+            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpSubAccount", false, pra);
             if (result == false)
             {
                 this.CloseProgressBar();
@@ -298,24 +340,25 @@
 
             Application.RunOnMainThread(() =>
             {
+                if (this.Parent == null)
+                {
+                    return;
+                }
                 //鍙樻洿鏉冮檺鍥炬爣
                 if (memberInfo.AccountType == 1)
                 {
-                    btnTopIcon.UnSelectedImagePath = "Account/HadAuthority.png";
+                    btnTopIcon.UnSelectedImagePath = "Item/HadAuthority.png";
                 }
                 else
                 {
-                    btnTopIcon.UnSelectedImagePath = "Account/NotAuthority.png";
+                    btnTopIcon.UnSelectedImagePath = "Item/NotAuthority.png";
                 }
                 //鍙樻洿鏉冮檺鏂囧瓧
                 btnAuthority.TextID = memberInfo.AccountType == 1 ? R.MyInternationalizationString.uMemberHadActionAuthority : R.MyInternationalizationString.uMember;
 
                 //鎵撳紑鏄剧ず鎴愬姛鐨勭敾闈�
-                if (memberInfo.AccountType == 1)
-                {
-                    var form = new SubAccountLevelUpSuccessForm();
-                    this.AddForm(form, memberInfo);
-                }
+                var form = new SubAccountLevelUpSuccessForm();
+                form.AddForm(memberInfo);
             });
         }
 
@@ -326,7 +369,7 @@
         /// <summary>
         /// 鍒犻櫎瀛愯处鍙�
         /// </summary>
-        public async void DeleteSubAccount()
+        private async void DeleteSubAccount()
         {
             //寮�鍚繘搴︽潯
             this.ShowProgressBar();
@@ -334,7 +377,7 @@
             var pra = new DeleteSubAccountPra();
             pra.SubAccount = memberInfo.SubAccountDistributedMark;
 
-            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/DeletedSubAccount", pra);
+            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/DeletedSubAccount", false, pra);
             //鍏抽棴杩涘害鏉�
             this.CloseProgressBar();
 
@@ -343,12 +386,57 @@
                 return;
             }
 
-            Application.RunOnMainThread(() =>
+            //绉婚櫎缂撳瓨
+            UserCenterResourse.ListMemberInfo.RemoveAll((obj) =>
             {
-                //浠庢垚鍛樹竴瑙堢敾闈㈢Щ闄�
-                this.LoadFormMethodByName("MemberListForm", "DeleteRowByAccount", memberInfo.Account);
-                //鑷韩鍏抽棴
-                this.CloseForm();
+                if (obj.SubAccountDistributedMark == memberInfo.SubAccountDistributedMark)
+                {
+                    return true;
+                }
+                return false;
+            });
+            UserCenterLogic.SaveLocalMemberListInfo();
+
+            //浠庢垚鍛樹竴瑙堢敾闈㈢Щ闄�
+            this.LoadFormMethodByName("MemberListForm", "DeleteRowByAccount", memberInfo.Account);
+            //鑷韩鍏抽棴
+            this.CloseForm();
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇鎴愬憳澶村儚_______________________
+
+        /// <summary>
+        /// 鑾峰彇鎴愬憳澶村儚
+        /// </summary>
+        private void GetMemberIcon(ImageView btnUserIcon)
+        {
+            HdlThreadLogic.Current.RunThread(async () =>
+            {
+                var pra = new AccountInfoPra();
+                pra.Account = memberInfo.Account;
+                var result = await UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string>() { "NotSetAgain" });
+                if (result == null)
+                {
+                    return;
+                }
+                var revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResponsePack>(System.Text.Encoding.UTF8.GetString(result));
+                if (revertObj == null || revertObj.ResponseData == null)
+                {
+                    return;
+                }
+                var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(revertObj.ResponseData.ToString());
+                if (infoResult.HeadImage != null)
+                {
+                    //鍐欏叆澶村儚鍐呭
+                    string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, memberInfo.DistributedMark + ".png");
+                    Shared.IO.FileUtils.WriteFileByBytes(iconPath, infoResult.HeadImage);
+                    HdlThreadLogic.Current.RunMain(() =>
+                    {
+                        btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(iconPath);
+                    });
+                }
             });
         }
 

--
Gitblit v1.8.0