using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Shared.Phone.UserCenter.Member { /// /// 成员管理★ /// public class MemberListForm : UserCenterCommonForm { #region ■ 变量声明___________________________ /// /// 列表控件 /// private VerticalScrolViewLayout listView = null; /// /// TopFrameLayout /// private SpecialFrameLayout specialTopFrame = null; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设置标题信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.MenberManagement)); //为了能够显示模块图样 bodyFrameLayout.BackgroundColor = UserCenterColor.Current.TopFrameLayout; var titleIcon = new TopLayoutMostRightView(); titleIcon.UnSelectedImagePath = "Item/Add.png"; titleIcon.SelectedImagePath = "Item/AddSelected.png"; topFrameLayout.AddChidren(titleIcon); titleIcon.MouseUpEventHandler += (sender, e) => { var menuContr = new TopRightMenuControl(this, 2); //扫描二维码 string msg1 = Language.StringByID(R.MyInternationalizationString.uScanQRcode); menuContr.AddRowMenu(msg1, (obj) => { var form = new AddMemberByIdForm(); form.AddForm(form); }); //输入账号 string msg2 = Language.StringByID(R.MyInternationalizationString.uInputAccount); menuContr.AddRowMenu(msg2, (obj) => { var form = new AddMemberByIdForm(); form.AddForm(form); }); }; //初始化中部控件 this.InitMiddleFrame(); } /// /// 初始化中部控件 /// private void InitMiddleFrame() { //初始化用户图标 this.InitUserIconControl(); //初始化列表控件 this.InitMemberListControl(); //总之先清空共享文件夹准没错 HdlShardLogic.Current.ClearShardDirectory(); } #endregion #region ■ 初始化用户图标_____________________ /// /// 初始化用户图标 /// private void InitUserIconControl() { this.specialTopFrame = new SpecialFrameLayout(400, 10); specialTopFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout; bodyFrameLayout.AddChidren(specialTopFrame); //用户图标 var btnUserIcon = new ProfilePhotoControl(); btnUserIcon.Y = Application.GetRealHeight(40); btnUserIcon.Gravity = Gravity.CenterHorizontal; btnUserIcon.UnSelectedImagePath = "Account/Admin.png"; specialTopFrame.AddChidren(btnUserIcon); //身份 var btnAuthority = new ViewNormalControl(specialTopFrame.Width); btnAuthority.TextAlignment = TextAlignment.Center; btnAuthority.Y = btnUserIcon.Bottom + Application.GetRealHeight(10); btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor; btnAuthority.Gravity = Gravity.CenterHorizontal; btnAuthority.Text = UserCenterResourse.UserInfo.AuthorityText; specialTopFrame.AddChidren(btnAuthority); //昵称 var btnName = new ViewNormalControl(800, true); btnName.TextAlignment = TextAlignment.Center; btnName.Y = btnAuthority.Bottom + Application.GetRealHeight(10); btnName.Gravity = Gravity.CenterHorizontal; btnName.Text = UserCenterResourse.UserInfo.UserName; ; specialTopFrame.AddChidren(btnName, HeightAutoMode.IncreaseOnly); } #endregion #region ■ 初始化成员列表_____________________ /// /// 初始化成员列表 /// private void InitMemberListControl() { //创建一个FrameLayout var frameLayout = new FrameLayout(); frameLayout.Height = bodyFrameLayout.Height - specialTopFrame.Height - Application.GetRealHeight(50); frameLayout.BackgroundColor = UserCenterColor.Current.BodyFrameLayout; frameLayout.Y = this.specialTopFrame.Bottom + Application.GetRealHeight(50); bodyFrameLayout.AddChidren(frameLayout); //标题:成员列表 var btnMenberTile = new ViewNormalControl(800, true); btnMenberTile.X = ControlCommonResourse.XXLeft; btnMenberTile.Y = Application.GetRealHeight(20); btnMenberTile.TextID = R.MyInternationalizationString.MenberList; frameLayout.AddChidren(btnMenberTile); //添加可以向下滚动的控件 listView = new VerticalScrolViewLayout(); listView.Y = btnMenberTile.Bottom + Application.GetRealHeight(20); listView.Height = frameLayout.Height - btnMenberTile.Bottom - Application.GetRealHeight(20); frameLayout.AddChidren(listView); new System.Threading.Thread(() => { //初始化成员列表 this.InitMemberList(); }) { IsBackground = true }.Start(); } /// /// 初始化成员列表 /// private async void InitMemberList() { //开启进度条 this.ShowProgressBar(); var pra = new MemberListInfoPra(); string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", pra); if (result == null) { //关闭进度条 this.CloseProgressBar(ShowReLoadMode.YES); return; } if (this.Parent == null) { //关闭进度条 this.CloseProgressBar(); return; } List listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject>(result); if (listInfo == null) { //关闭进度条 this.CloseProgressBar(ShowReLoadMode.YES); } List listCheck = new List(); foreach (MemberInfoRes infoRes in listInfo) { if (listCheck.Contains(infoRes.DistributedMark) == true || infoRes.Account == UserCenterResourse.UserInfo.Phone || infoRes.Account == UserCenterResourse.UserInfo.Email) { continue; } listCheck.Add(infoRes.DistributedMark); Application.RunOnMainThread(() => { //添加成员行 this.AddRowLayout(infoRes); }); } //关闭进度条 this.CloseProgressBar(); } #endregion #region ■ 添加成员行_________________________ /// /// 添加成员行 /// /// Info. private void AddRowLayout(MemberInfoRes info) { var rowlayout = new MemberRow(); rowlayout.AccountId = info.Account; listView.AddChidren(rowlayout); //成员头像图标 var btnIcon = new IconViewControl(); btnIcon.Radius = (uint)btnIcon.IconSize / 2; btnIcon.X = ControlCommonResourse.XXLeft; btnIcon.Gravity = Gravity.CenterVertical; btnIcon.UnSelectedImagePath = "Account/ProfilePhotoMember.png"; btnIcon.SelectedImagePath = "Account/ProfilePhotoMemberSelected.png"; rowlayout.AddChidren(btnIcon); //成员昵称 var btnName = new RowCenterView(); btnName.Text = info.UserName; if (string.IsNullOrEmpty(info.UserName) == true) { btnName.Text = info.Account; } rowlayout.AddChidren(btnName); //权限 var btnAuthority = new RowSecondRightTextView(); btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor; if (info.AccountType == 1) { //管理员 btnAuthority.TextID = R.MyInternationalizationString.Administrator; } else { //成员 btnAuthority.TextID = R.MyInternationalizationString.uMember; } rowlayout.AddChidren(btnAuthority); //右图标 rowlayout.AddRightIconControl(); rowlayout.MouseUpEvent += (sender, e) => { var form = new MemberManagementForm(); this.AddForm(form, info); }; } #endregion #region ■ 删除指定行_________________________ /// /// 删除指定行 /// /// public void DeleteRowByAccount(string accountId) { for (int i = 0; ; i++) { var row = (MemberRow)listView.GetChildren(i); if (row == null) { break; } if (row.AccountId == accountId) { row.RemoveFromParent(); break; } } } #endregion #region ■ 界面重新激活事件___________________ /// /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件 /// public override void FormActionAgainEvent() { //清空共享文件夹 HdlShardLogic.Current.ClearShardDirectory(); this.listView.RemoveAll(); new System.Threading.Thread(() => { //初始化成员列表 this.InitMemberList(); }) { IsBackground = true }.Start(); } #endregion #region ■ 结构体_____________________________ /// /// 自定义控件 /// private class MemberRow : StatuRowLayout { /// /// 账号ID /// public string AccountId = string.Empty; } #endregion } }