using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Shared.Phone.UserCenter.Member { /// /// 成员管理★ /// public class MemberListForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 列表控件 /// private VerticalListControl listView = null; /// /// 成员头像控件 /// private Dictionary dicIconControl = new Dictionary(); /// /// 成员的账号(获取头像用) /// private Dictionary dicMemberAccount = new Dictionary(); #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设置标题信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.MenberManagement)); var titleIcon = new MostRightIconControl(69, 69); titleIcon.UnSelectedImagePath = "Item/Add.png"; topFrameLayout.AddChidren(titleIcon); titleIcon.InitControl(); titleIcon.ButtonClickEvent += (sender, e) => { var menuContr = new TopRightMenuControl(2, 2); //扫描二维码 string msg1 = Language.StringByID(R.MyInternationalizationString.uScanQRcode); menuContr.AddRowMenu(msg1, "Item/ScanQRcodeIcon.png", "Item/ScanQRcodeIconSelected.png", () => { QRCode.ScanQRcode((qrCode) => { if (string.IsNullOrEmpty(qrCode) == true) { return; } //搜索ID HdlThreadLogic.Current.RunThread(() => { this.SearchMemberInfo(qrCode); }); }, Language.StringByID(R.MyInternationalizationString.uCancel), Language.StringByID(R.MyInternationalizationString.uFlashlamp), msg1); }); //输入账号 string msg2 = Language.StringByID(R.MyInternationalizationString.uInputAccount); menuContr.AddRowMenu(msg2, "Item/InputAccountIcon.png", "Item/InputAccountIconSelected.png", () => { var form = new AddMemberByIdForm(); form.AddForm(); }); }; //初始化中部控件 this.InitMiddleFrame(); } /// /// 初始化中部控件 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); //初始化用户图标 this.InitUserIconControl(); //初始化列表控件 this.InitMemberListControl(); } #endregion #region ■ 初始化用户图标_____________________ /// /// 初始化用户图标 /// private void InitUserIconControl() { var frameBack = new FrameLayout(); frameBack.BackgroundColor = UserCenterColor.Current.White; frameBack.Height = Application.GetRealHeight(438); bodyFrameLayout.AddChidren(frameBack); //用户图标 var btnUserIcon = new ImageView(); btnUserIcon.Height = this.GetPictrueRealSize(207); btnUserIcon.Width = this.GetPictrueRealSize(207); btnUserIcon.Radius = (uint)this.GetPictrueRealSize(207) / 2; btnUserIcon.ImagePath = HdlFileNameResourse.UserHeadIconFile; btnUserIcon.Y = Application.GetRealHeight(46); btnUserIcon.Gravity = Gravity.CenterHorizontal; frameBack.AddChidren(btnUserIcon); //昵称 var btnName = new NormalViewControl(frameBack.Width, Application.GetRealHeight(60), false); btnName.TextAlignment = TextAlignment.Center; btnName.Y = btnUserIcon.Bottom + Application.GetRealHeight(20); btnName.TextSize = 16; btnName.Text = HdlUserCenterResourse.UserInfo.NickName; ; frameBack.AddChidren(btnName); //身份 var btnAuthority = new NormalViewControl(frameBack.Width, Application.GetRealHeight(55), false); btnAuthority.TextAlignment = TextAlignment.Center; btnAuthority.Y = btnName.Bottom + Application.GetRealHeight(10); btnAuthority.TextSize = 12; btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor1; btnAuthority.Text = HdlUserCenterResourse.ResidenceOption.AuthorityText; frameBack.AddChidren(btnAuthority); } #endregion #region ■ 初始化成员列表_____________________ /// /// 初始化成员列表 /// private void InitMemberListControl() { //标题:成员列表 var btnMenberTile = new NormalViewControl(800, 60, true); btnMenberTile.X = HdlControlResourse.XXLeft; btnMenberTile.Y = Application.GetRealHeight(480); btnMenberTile.TextColor = UserCenterColor.Current.TextColor1; btnMenberTile.TextID = R.MyInternationalizationString.MenberList; btnMenberTile.TextSize = 15; bodyFrameLayout.AddChidren(btnMenberTile); var frameBack = new FrameLayout(); frameBack.Y = btnMenberTile.Bottom + Application.GetRealHeight(23); frameBack.Height = Application.GetRealHeight(11); frameBack.BackgroundColor = UserCenterColor.Current.White; bodyFrameLayout.AddChidren(frameBack); //添加可以向下滚动的控件 listView = new VerticalListControl(12); listView.Height = bodyFrameLayout.Height - frameBack.Bottom; listView.BackgroundColor = UserCenterColor.Current.White; listView.Y = frameBack.Bottom; bodyFrameLayout.AddChidren(listView); HdlThreadLogic.Current.RunThread(() => { //总之先清空共享文件夹准没错 HdlShardLogic.Current.Dispone(); //初始化成员列表 this.InitMemberList(); }); } /// /// 初始化成员列表 /// private void InitMemberList() { //开启进度条 this.ShowProgressBar(); var listShowInfo = HdlMemberLogic.Current.GetMemberListInfo(); if (listShowInfo == null) { //关闭进度条 this.CloseProgressBar(ShowReLoadMode.YES); return; } //关闭进度条 this.CloseProgressBar(); if (listShowInfo.Count == 0) { return; } HdlThreadLogic.Current.RunMain(() => { //添加成员列表 this.AddMemberListRowByData(listShowInfo); }); } /// /// 添加成员列表 /// private void AddMemberListRowByData(List listNewInfo) { if (this.Parent == null) { return; } int count = listNewInfo.Count - 1; for (int i = 0; i < listNewInfo.Count; i++) { //添加成员行 this.AddRowLayout(listNewInfo[i], i != count); } //调整列表控件的高度 listView.AdjustRealHeight(Application.GetRealHeight(23)); //获取成员头像 this.GetMemberIcon(); } #endregion #region ■ 添加成员行_________________________ /// /// 添加成员行 /// /// Info. /// addLine private void AddRowLayout(MemberInfoRes info, bool addLine) { var rowlayout = new FrameRowControl(listView.rowSpace / 2); rowlayout.Height = Application.GetRealHeight(138); rowlayout.MainKeys = info.Account; listView.AddChidren(rowlayout); //成员头像图标 string iconPath = System.IO.Path.Combine(HdlFileNameResourse.UserPictrueDirectory, info.ChildAccountId + ".png"); var btnIcon = new ImageView(); btnIcon.X = HdlControlResourse.XXLeft; btnIcon.Gravity = Gravity.CenterVertical; btnIcon.Height = this.GetPictrueRealSize(115); btnIcon.Width = this.GetPictrueRealSize(115); btnIcon.Radius = (uint)this.GetPictrueRealSize(115) / 2; if (System.IO.File.Exists(iconPath) == true) { btnIcon.ImagePath = iconPath; } else { btnIcon.ImagePath = "Center/Admin.png"; this.dicIconControl[info.ChildAccountId] = btnIcon; this.dicMemberAccount[info.ChildAccountId] = info.Account; } rowlayout.AddChidren(btnIcon); //成员昵称 string memberName = info.ShowName; var btnName = rowlayout.AddLeftCaption(memberName, 600, true); btnName.X = HdlControlResourse.XXLeft + btnIcon.Height + Application.GetRealWidth(35); btnName.TextSize = 15; rowlayout.AddChidren(btnName); if (addLine == true) { //底线 rowlayout.AddBottomLine(); } //右图标 rowlayout.AddRightArrow(); rowlayout.ButtonClickEvent += (sender, e) => { var form = new MemberManagementForm(); form.AddForm(info); }; } /// /// 添加成员行(外部调用) /// /// public void AddRowLayoutByOtherForm(MemberInfoRes info) { var myRow = listView.GetChildren(listView.ChildrenCount - 1); if (myRow != null) { //最后一行加底线 ((FrameRowControl)myRow).AddBottomLine(); } this.AddRowLayout(info, false); //调整列表控件的高度 listView.AdjustRealHeight(Application.GetRealHeight(23)); } #endregion #region ■ 获取成员头像_______________________ /// /// 获取成员头像 /// private void GetMemberIcon() { if (dicIconControl.Count == 0) { return; } HdlThreadLogic.Current.RunThread(() => { foreach (var keys in dicMemberAccount.Keys) { if (this.Parent == null) { return; } var imageData = HdlAccountLogic.Current.DownLoadAccountPictrue(dicMemberAccount[keys]); if (imageData != null && imageData.Length > 0) { //写入头像内容 string iconPath = System.IO.Path.Combine(HdlFileNameResourse.UserPictrueDirectory, keys + ".png"); Shared.IO.FileUtils.WriteFileByBytes(iconPath, imageData); HdlThreadLogic.Current.RunMain(() => { dicIconControl[keys].ImageBytes = Shared.IO.FileUtils.ReadFile(iconPath); }); } } }); } #endregion #region ■ 删除指定行_________________________ /// /// 删除指定行(外部调用) /// /// public void DeleteRowByAccount(string accountId) { for (int i = 0; ; i++) { var row = (FrameRowControl)listView.GetChildren(i); if (row == null) { break; } if (row.MainKeys == accountId) { row.RemoveFromParent(); //调整列表控件的高度 listView.AdjustRealHeight(Application.GetRealHeight(23)); break; } } } #endregion #region ■ 搜索ID_____________________________ /// /// 搜索指定ID的信息 /// /// 成员ID /// 信息控件 private void SearchMemberInfo(string accountId) { //开启进度条 this.ShowProgressBar(); var result = HdlMemberLogic.Current.SearchNormalInfoByAccount(accountId); //关闭进度条 this.CloseProgressBar(); if (result == null) { return; } if (result.Account == string.Empty) { HdlThreadLogic.Current.RunMain(() => { //成员不存在 var form = new MemberNotEsixtForm(); form.AddForm(Language.StringByID(R.MyInternationalizationString.uMemberInformation)); }); return; } HdlThreadLogic.Current.RunMain(() => { var form = new AddMemberInfoForm(); form.AddForm(result); }); } #endregion #region ■ 界面重新激活事件___________________ /// /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件 /// public override int FormActionAgainEvent() { //清空共享文件夹 HdlShardLogic.Current.Dispone(); return 1; } #endregion } }