黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberSuccessForm.cs
@@ -7,111 +7,136 @@
    /// <summary>
    /// 添加成员成功的画面
    /// </summary>
    public class AddMemberSuccessForm : UserCenterCommonForm
    public class AddMemberSuccessForm : DialogCommonForm
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 成员账号信息
        /// 界面关闭事件
        /// </summary>
        private AccountInfoResult memberAccountResult = null;
        public Action FormCloseEvent = null;
        /// <summary>
        /// 成员信息
        /// </summary>
        private MemberInfoRes memberResult = null;
        /// <summary>
        /// 清空事件
        /// </summary>
        private bool clearEvent = true;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_accountInfoResult">成员账号信息</param>
        /// <param name="i_memberResult">成员信息</param>
        public void ShowForm(AccountInfoResult i_accountInfoResult, MemberInfoRes i_memberResult)
        {
            this.memberAccountResult = i_accountInfoResult;
            this.memberResult = i_memberResult;
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uMemberInformation));
            //初始化中部控件
            this.InitMiddleFrame();
        }
        /// <param name="i_memberResult">成员信息</param>
        /// <param name="i_iconMark">头像的Mark</param>
        public void ShowForm(MemberInfoRes i_memberResult, string i_iconMark)
        {
            this.memberResult = i_memberResult;
            //初始化中部控件
            this.InitMiddleFrame(i_iconMark);
        }
        /// <summary>
        /// 初始化中部控件
        /// </summary>
        private void InitMiddleFrame()
        /// </summary>
        private void InitMiddleFrame(string i_iconMark)
        {
            //家族成员添加成功!
            var btnSuccess = new ViewNormalControl(800, true);
            btnSuccess.Y = Application.GetRealHeight(100);
            btnSuccess.TextAlignment = TextAlignment.Center;
            btnSuccess.TextID = R.MyInternationalizationString.uAddMemberSuccess;
            btnSuccess.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(btnSuccess);
            //头像
            var btnIcon = new ProfilePhotoControl();
            btnIcon.UnSelectedImagePath = "Account/Admin.png";
            btnIcon.Y = Application.GetRealHeight(300);
            btnIcon.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(btnIcon);
            //背景框
            var frame = new FrameLayout();
            frame.Width = Application.GetRealWidth(838);
            frame.Height = Application.GetRealHeight(1097);
            frame.BackgroundColor = UserCenterColor.Current.White;
            frame.Gravity = Gravity.Center;
            frame.Radius = (uint)Application.GetRealHeight(17);
            bodyFrameLayout.AddChidren(frame);
            //成员ID
            var btnUserId = new ViewNormalControl(800, true);
            btnUserId.Y = btnIcon.Bottom + Application.GetRealHeight(20);
            btnUserId.Gravity = Gravity.CenterHorizontal;
            btnUserId.Text = memberResult.Account;
            btnUserId.TextAlignment = TextAlignment.Center;
            bodyFrameLayout.AddChidren(btnUserId);
            //用户图标
            string iconPath = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, i_iconMark + ".png");
            var btnUserIcon = new ImageView();
            btnUserIcon.Height = this.GetPictrueRealSize(207);
            btnUserIcon.Width = this.GetPictrueRealSize(207);
            btnUserIcon.Radius = (uint)this.GetPictrueRealSize(207) / 2;
            btnUserIcon.Y = Application.GetRealHeight(104);
            btnUserIcon.Gravity = Gravity.CenterHorizontal;
            if (System.IO.File.Exists(iconPath) == true)
            {
                btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(iconPath);
            }
            else
            {
                btnUserIcon.ImagePath = "Center/Admin.png";
            }
            frame.AddChidren(btnUserIcon);
            //昵称
            var btnName = new ViewNormalControl(800, true);
            btnName.Y = btnUserId.Bottom + Application.GetRealHeight(20);
            btnName.Gravity = Gravity.CenterHorizontal;
            btnName.Text = memberResult.UserName;
            var btnName = new NormalViewControl(frame.Width, Application.GetRealHeight(55), false);
            btnName.IsBold = true;
            btnName.TextAlignment = TextAlignment.Center;
            bodyFrameLayout.AddChidren(btnName);
            if (string.IsNullOrEmpty(btnName.Text) == true)
            btnName.Y = Application.GetRealHeight(334);
            btnName.TextColor = UserCenterColor.Current.TextColor2;
            btnName.TextSize = 16;
            btnName.Text = memberResult.UserName;
            if (string.IsNullOrEmpty(memberResult.UserName) == true)
            {
                //如果它本身就没名字的话,把他的ID作为昵称
                btnName.Text = memberResult.Account;
            }
            frame.AddChidren(btnName);
            //房间里面有设备才会显示共享设备菜单
            if (this.CheckIsCanShard() == true)
            //权限
            var btnAuthority = new NormalViewControl(frame.Width, Application.GetRealHeight(50), false);
            btnAuthority.TextAlignment = TextAlignment.Center;
            btnAuthority.Y = Application.GetRealHeight(400);
            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnAuthority.TextID = R.MyInternationalizationString.uMember;
            btnAuthority.TextSize = 12;
            frame.AddChidren(btnAuthority);
            //家族成员添加成功
            var btnSuccess = new NormalViewControl(frame.Width, Application.GetRealHeight(82), false);
            btnSuccess.IsBold = true;
            btnSuccess.Y = Application.GetRealHeight(547);
            btnSuccess.TextAlignment = TextAlignment.Center;
            btnSuccess.TextID = R.MyInternationalizationString.uAddMemberSuccess;
            btnSuccess.TextSize = 20;
            frame.AddChidren(btnSuccess);
            //完成
            var btnFinish = new BottomClickButton(688);
            btnFinish.Y = Application.GetRealHeight(867);
            btnFinish.TextID = R.MyInternationalizationString.uFinish;
            frame.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += (sender, e) =>
            {
                //配置共享内容
                var btnmsg = new MsgViewControl(800, true);
                btnmsg.Gravity = Gravity.CenterHorizontal;
                btnmsg.Y = Application.GetRealHeight(1200);
                btnmsg.TextColor = UserCenterColor.Current.TextGrayColor;
                btnmsg.Text = Language.StringByID(R.MyInternationalizationString.uConfigureSharedContent) + " >>";
                btnmsg.MouseUpEventHandler += (sender, e) =>
                {
                    //先清空共享文件夹
                    HdlShardLogic.Current.ClearShardDirectory();
                this.clearEvent = false;
                    var memberInfo = new MemberShardInfoData();
                    var form = new SharedContent.ConfigureNewSharedListRoomForm();
                    this.AddFromAndRemoveNowForm(form, memberResult, memberInfo);
                };
                bodyFrameLayout.AddChidren(btnmsg);
            }
                this.CloseForm();
                FormCloseEvent?.Invoke();
                FormCloseEvent = null;
            };
        }
        #endregion
        #region ■ 界面关闭___________________________
        /// <summary>
        /// 检测能否分享
        /// 界面关闭
        /// </summary>
        /// <returns></returns>
        private bool CheckIsCanShard()
        public override void CloseFormBefore()
        {
            foreach (var room in Shared.Common.Room.Lists)
            if (clearEvent == true)
            {
                if (room.DeviceUIList.Count > 0)
                {
                    return true;
                }
                FormCloseEvent = null;
            }
            return false;
            base.CloseFormBefore();
        }
        #endregion
    }
}