HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-09-30 404cdc88627f942df7944af04ee05b9d527752d6
ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
@@ -7,18 +7,14 @@
    /// <summary>
    /// 成员管理★
    /// </summary>
    public class MemberListForm : UserCenterCommonForm
    public class MemberListForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalScrolViewLayout listView = null;
        /// <summary>
        /// TopFrameLayout
        /// </summary>
        private SpecialFrameLayout specialTopFrame = null;
        private VerticalListControl listView = null;
        #endregion
@@ -32,29 +28,26 @@
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.MenberManagement));
            //为了能够显示模块图样
            bodyFrameLayout.BackgroundColor = UserCenterColor.Current.TopFrameLayout;
            var titleIcon = new TopLayoutMostRightView();
            var titleIcon = new MostRightIconControl(69, 69);
            titleIcon.UnSelectedImagePath = "Item/Add.png";
            titleIcon.SelectedImagePath = "Item/AddSelected.png";
            topFrameLayout.AddChidren(titleIcon);
            titleIcon.MouseUpEventHandler += (sender, e) =>
            titleIcon.InitControl();
            titleIcon.ButtonClickEvent += (sender, e) =>
            {
                var menuContr = new TopRightMenuControl(this, 2);
                //扫描二维码
                string msg1 = Language.StringByID(R.MyInternationalizationString.uScanQRcode);
                menuContr.AddRowMenu(msg1, (obj) =>
                menuContr.AddRowMenu(msg1,"","", () =>
                {
                    var form = new AddMemberByIdForm();
                    form.AddForm(form);
                    form.AddForm();
                });
                //输入账号
                string msg2 = Language.StringByID(R.MyInternationalizationString.uInputAccount);
                menuContr.AddRowMenu(msg2, (obj) =>
                menuContr.AddRowMenu(msg2,"","", () =>
                {
                    var form = new AddMemberByIdForm();
                    form.AddForm(form);
                    form.AddForm();
                });
            };
@@ -68,6 +61,9 @@
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
            //初始化用户图标
            this.InitUserIconControl();
@@ -87,33 +83,35 @@
        /// </summary>
        private void InitUserIconControl()
        {
            this.specialTopFrame = new SpecialFrameLayout(400, 10);
            specialTopFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
            bodyFrameLayout.AddChidren(specialTopFrame);
            var frameBack = new FrameLayout();
            frameBack.BackgroundColor = UserCenterColor.Current.White;
            frameBack.Height = Application.GetRealHeight(438);
            bodyFrameLayout.AddChidren(frameBack);
            //用户图标
            var btnUserIcon = new ProfilePhotoControl();
            btnUserIcon.Y = Application.GetRealHeight(40);
            var btnUserIcon = new PicViewControl(207, 207);
            btnUserIcon.Y = Application.GetRealHeight(46);
            btnUserIcon.Radius = (uint)Application.GetMinRealAverage(207) / 2;
            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);
            btnUserIcon.UnSelectedImagePath = "Center/Admin.png";
            frameBack.AddChidren(btnUserIcon);
            //昵称
            var btnName = new ViewNormalControl(800, true);
            var btnName = new NormalViewControl(frameBack.Width, Application.GetRealHeight(60), false);
            btnName.TextAlignment = TextAlignment.Center;
            btnName.Y = btnAuthority.Bottom + Application.GetRealHeight(10);
            btnName.Gravity = Gravity.CenterHorizontal;
            btnName.Y = btnUserIcon.Bottom + Application.GetRealHeight(20);
            btnName.TextSize = 16;
            btnName.Text = UserCenterResourse.UserInfo.UserName; ;
            specialTopFrame.AddChidren(btnName, HeightAutoMode.IncreaseOnly);
            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.TextGrayColor;
            btnAuthority.Text = UserCenterResourse.UserInfo.AuthorityText;
            frameBack.AddChidren(btnAuthority);
        }
        #endregion
@@ -125,32 +123,24 @@
        /// </summary>
        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);
            var btnMenberTile = new NormalViewControl(800, 60, true);
            btnMenberTile.X = ControlCommonResourse.XXLeft;
            btnMenberTile.Y = Application.GetRealHeight(20);
            btnMenberTile.Y = Application.GetRealHeight(480);
            btnMenberTile.TextColor = UserCenterColor.Current.TextColor1;
            btnMenberTile.TextID = R.MyInternationalizationString.MenberList;
            frameLayout.AddChidren(btnMenberTile);
            btnMenberTile.TextSize = 15;
            bodyFrameLayout.AddChidren(btnMenberTile);
            //添加可以向下滚动的控件
            listView = new VerticalScrolViewLayout();
            listView.Y = btnMenberTile.Bottom + Application.GetRealHeight(20);
            listView.Height = frameLayout.Height - btnMenberTile.Bottom - Application.GetRealHeight(20);
            frameLayout.AddChidren(listView);
            listView = new VerticalListControl(12);
            listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(567);
            listView.BackgroundColor = UserCenterColor.Current.White;
            listView.Y = Application.GetRealHeight(567);
            bodyFrameLayout.AddChidren(listView);
            new System.Threading.Thread(() =>
            {
                //初始化成员列表
                this.InitMemberList();
            })
            { IsBackground = true }.Start();
            //初始化成员列表
            this.InitMemberList();
        }
        /// <summary>
@@ -162,7 +152,7 @@
            this.ShowProgressBar();
            var pra = new MemberListInfoPra();
            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", pra);
            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
            if (result == null)
            {
                //关闭进度条
@@ -181,27 +171,70 @@
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return;
            }
            //关闭进度条
            this.CloseProgressBar();
            //先清空成员列表信息
            UserCenterResourse.ListMemberInfo.Clear();
            List<string> listCheck = new List<string>();
            foreach (MemberInfoRes infoRes in listInfo)
            {
                if (listCheck.Contains(infoRes.DistributedMark) == true
                    || infoRes.Account == UserCenterResourse.UserInfo.Phone
                    || infoRes.Account == UserCenterResourse.UserInfo.Email)
                    || infoRes.Account == UserCenterResourse.UserInfo.Email
                    || infoRes.AccountType != 0)
                {
                    //如果是它自己的话,或者权限等级比他高的,不显示
                    continue;
                }
                listCheck.Add(infoRes.DistributedMark);
                Application.RunOnMainThread(() =>
                {
                    //添加成员行
                    this.AddRowLayout(infoRes);
                });
                //添加成员信息的缓存
                UserCenterResourse.ListMemberInfo.Add(infoRes);
            }
            //关闭进度条
            this.CloseProgressBar();
            listInfo.Clear();
            //保存成员信息的缓存到本地文件
            UserCenterLogic.SaveLocalMemberListInfo();
            if (UserCenterResourse.ListMemberInfo.Count == 0)
            {
                return;
            }
            //添加成员列表
            this.AddMemberListRowByData();
        }
        /// <summary>
        /// 添加成员列表
        /// </summary>
        private void AddMemberListRowByData()
        {
            if (this.Parent == null)
            {
                return;
            }
            var listNewInfo = UserCenterResourse.ListMemberInfo;
            int count = listNewInfo.Count - 1;
            for (int i = 0; i < listNewInfo.Count; i++)
            {
                //添加成员行
                this.AddRowLayout(listNewInfo[i], i != count);
            }
            if (listNewInfo.Count == 0)
            {
                return;
            }
            //调整列表控件的高度
            var realHeight = listNewInfo.Count * listView.GetChildren(listView.ChildrenCount - 1).Height;
            realHeight += Application.GetRealHeight(23) - listView.rowSpace + Application.GetRealHeight(23);
            if (realHeight < listView.Height)
            {
                //缩小控件高度
                listView.Height = realHeight;
            }
        }
        #endregion
@@ -212,51 +245,47 @@
        /// 添加成员行
        /// </summary>
        /// <param name="info">Info.</param>
        private void AddRowLayout(MemberInfoRes info)
        ///  <param name="addLine">addLine</param>
        private void AddRowLayout(MemberInfoRes info, bool addLine)
        {
            var rowlayout = new MemberRow();
            rowlayout.AccountId = info.Account;
            if (listView.ChildrenCount == 0)
            {
                //塞一个空白的进去占空间
                var rowTemp = new FrameRowControl();
                rowTemp.UseClickStatu = false;
                rowTemp.Height = Application.GetRealHeight(23) - listView.rowSpace;
                rowTemp.MainKeys = string.Empty;
                listView.AddChidren(rowTemp);
            }
            var rowlayout = new FrameRowControl(listView.rowSpace / 2);
            rowlayout.Height = Application.GetRealHeight(138);
            rowlayout.MainKeys = info.Account;
            listView.AddChidren(rowlayout);
            //成员头像图标
            var btnIcon = new IconViewControl();
            var btnIcon = rowlayout.AddLeftIcon(115);
            btnIcon.Radius = (uint)btnIcon.IconSize / 2;
            btnIcon.X = ControlCommonResourse.XXLeft;
            btnIcon.Gravity = Gravity.CenterVertical;
            btnIcon.UnSelectedImagePath = "Account/ProfilePhotoMember.png";
            btnIcon.SelectedImagePath = "Account/ProfilePhotoMemberSelected.png";
            btnIcon.UnSelectedImagePath = "Center/Admin.png";
            rowlayout.AddChidren(btnIcon);
            //成员昵称
            var btnName = new RowCenterView();
            btnName.Text = info.UserName;
            if (string.IsNullOrEmpty(info.UserName) == true)
            {
                btnName.Text = info.Account;
            }
            string memberName = string.IsNullOrEmpty(info.UserName) == true ? info.Account : info.UserName;
            var btnName = rowlayout.AddLeftCaption(memberName, 600, true);
            btnName.TextSize = 15;
            rowlayout.AddChidren(btnName);
            //权限
            var btnAuthority = new RowSecondRightTextView();
            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor;
            if (info.AccountType == 1)
            if (addLine == true)
            {
                //管理员
                btnAuthority.TextID = R.MyInternationalizationString.Administrator;
                //底线
                rowlayout.AddBottomLine();
            }
            else
            {
                //成员
                btnAuthority.TextID = R.MyInternationalizationString.uMember;
            }
            rowlayout.AddChidren(btnAuthority);
            //右图标
            rowlayout.AddRightIconControl();
            rowlayout.MouseUpEvent += (sender, e) =>
            rowlayout.AddRightArrow();
            rowlayout.ButtonClickEvent += (sender, e) =>
            {
                var form = new MemberManagementForm();
                this.AddForm(form, info);
                form.AddForm(info);
            };
        }
@@ -272,12 +301,12 @@
        {
            for (int i = 0; ; i++)
            {
                var row = (MemberRow)listView.GetChildren(i);
                var row = (FrameRowControl)listView.GetChildren(i);
                if (row == null)
                {
                    break;
                }
                if (row.AccountId == accountId)
                if (row.MainKeys == accountId)
                {
                    row.RemoveFromParent();
                    break;
@@ -298,28 +327,10 @@
            HdlShardLogic.Current.ClearShardDirectory();
            this.listView.RemoveAll();
            listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(567);
            new System.Threading.Thread(() =>
            {
                //初始化成员列表
                this.InitMemberList();
            })
            { IsBackground = true }.Start();
        }
        #endregion
        #region ■ 结构体_____________________________
        /// <summary>
        /// 自定义控件
        /// </summary>
        private class MemberRow : StatuRowLayout
        {
            /// <summary>
            /// 账号ID
            /// </summary>
            public string AccountId = string.Empty;
            //添加成员列表
            this.AddMemberListRowByData();
        }
        #endregion