黄学彪
2020-04-15 23532fa8ad34c89b6d24b01eaef6475fd0aad898
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -428,74 +428,22 @@
                        var actionForm = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
                        if (actionForm != null && actionForm is CommonFormBase)
                        {
                            //设置当前激活的画面ID
                            UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                            //追加条件一:关闭的界面为EditorCommonForm的时候才处理
                            if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                            string formId = ((CommonFormBase)actionForm).FormID;
                            //对应徐梅继承了底层,但是不初始化数据的问题
                            if (UserCenterResourse.listActionFormId.Contains(formId) == true)
                            {
                                try
                                {
                                    EditorCommonForm Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID] as EditorCommonForm;
                                    if (Myform != null)
                                    {
                                        //重置左滑使能
                                        Myform.ScrollEnabled = Myform.ScrollEnabled;
                                        //触发界面再次激活的事件
                                        int value = Myform.FormActionAgainEvent();
                                        if (value == 1)
                                        {
                                            //Log出力
                                            HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    //出现未知错误,数据丢失
                                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                                    alert.Show();
                                    //Log出力
                                    HdlLogLogic.Current.WriteLog(ex);
                                }
                                //调用界面重新激活的函数
                                CallFormActionAgainEvent(form, index);
                            }
                        }
                        else if (actionForm != null && actionForm is UserView.UserPage)
                        {
                            //这里它已经退到主页了,如果它包含个人中心主页的话
                            if (UserCenterResourse.listActionFormId.Contains("UserMainForm") == true)
                            //这里它已经退到主页了
                            if (UserCenterResourse.listActionFormId.Contains("UserMainForm") == true//个人中心
                                || UserCenterResourse.listActionFormId.Contains("HomeMainPageForm") == true)//
                            {
                                //设置当前激活的画面ID
                                UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                                //追加条件一:关闭的界面为EditorCommonForm的时候才处理
                                if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                                {
                                    try
                                    {
                                        EditorCommonForm Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID] as EditorCommonForm;
                                        if (Myform != null)
                                        {
                                            //重置左滑使能
                                            Myform.ScrollEnabled = Myform.ScrollEnabled;
                                            //触发界面再次激活的事件
                                            int value = Myform.FormActionAgainEvent();
                                            if (value == 1)
                                            {
                                                //Log出力
                                                HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        //出现未知错误,数据丢失
                                        var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                                        alert.Show();
                                        //Log出力
                                        HdlLogLogic.Current.WriteLog(ex);
                                    }
                                }
                                //调用界面重新激活的函数
                                CallFormActionAgainEvent(form, index);
                            }
                        }
                    }
@@ -504,6 +452,43 @@
                UserCenterResourse.listActionFormId.Remove(UserCenterResourse.DicActionForm[formName].FormID);
                //移除画面
                UserCenterResourse.DicActionForm.Remove(formName);
            }
        }
        /// <summary>
        /// 调用界面重新激活的函数
        /// </summary>
        /// <param name="form">关闭的界面对象</param>
        /// <param name="index">当前需要重新激活界面的索引</param>
        private static void CallFormActionAgainEvent(CommonFormBase form, int index)
        {
            //设置当前激活的画面ID
            UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
            //追加条件一:关闭的界面为EditorCommonForm的时候才处理
            if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
            {
                try
                {
                    var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID] as EditorCommonForm;
                    //重置左滑使能
                    Myform.ScrollEnabled = Myform.ScrollEnabled;
                    //触发界面再次激活的事件
                    int value = Myform.FormActionAgainEvent();
                    if (value == 1)
                    {
                        //Log出力
                        HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                    }
                }
                catch (Exception ex)
                {
                    //出现未知错误,数据丢失
                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                    alert.Show();
                    //Log出力
                    HdlLogLogic.Current.WriteLog(ex, "界面重新激活异常");
                }
            }
        }
@@ -675,11 +660,13 @@
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //收起左菜单
                    CommonPage.Instance.CloseLeftMenu();
                    //关闭所有打开了的界面
                    CloseAllOpenForm();
                    //显示登陆画面
                    var formLogin = new Shared.Phone.Device.Account.AccountLogin();
                    var formLogin = new Login.AccountLogin();
                    Shared.Common.CommonPage.Instance.AddChidren(formLogin);
                    formLogin.Show(account);
                });
@@ -696,11 +683,18 @@
        /// 关闭所有打开了的界面
        /// </summary>
        /// <param name="tagetFrom">目标界面,如果指定了的话,则关闭目标界面上层的全部界面(它自身不关闭)</param>
        public static void CloseAllOpenForm(string tagetFrom = "")
        public static void CloseAllOpenForm(string tagetFrom = null)
        {
            while (UserView.HomePage.Instance.ChildrenCount > 0)
            {
                var view = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
                //(因底层控件修改了, 父控件移除时, 不触发子控件的移除事件)
                if (view is ViewGroup)
                {
                    //关闭加载在ViewGroup里面的自定义界面Form
                    CloseViewGroupChildren((ViewGroup)view);
                }
                if (view is CommonFormBase)
                {
                    if (((CommonFormBase)view).FormID == tagetFrom)
@@ -721,38 +715,20 @@
            }
        }
        #endregion
        #region ■ 子控件的Y轴坐标____________________
        /// <summary>
        /// 指定位置类型获取Rowlayout的子控件的Y轴坐标(请确保子控件不大于父容器)
        /// 关闭加载在ViewGroup里面的自定义界面Form(因底层控件修改了,父控件移除时,不触发子控件的移除事件)
        /// </summary>
        /// <param name="fatherCtrHeight">父控件的真实高度</param>
        /// <param name="ctrHeight">子控件的真实高度</param>
        /// <param name="alignment">位置对齐方式</param>
        /// <param name="Space">上下间的空白间距,省略时,取行控件共通变量的值。设置为-1时,不计算空白间距</param>
        /// <returns></returns>
        public static int GetControlChidrenYaxis(int fatherCtrHeight, int ctrHeight, UViewAlignment alignment, int Space = 0)
        /// <param name="group"></param>
        private static void CloseViewGroupChildren(ViewGroup group)
        {
            if (Space < 0)
            for (int i = 0; i < group.ChildrenCount; i++)
            {
                //不计算间距值
                Space = 0;
            }
            if (alignment == UViewAlignment.Center)
            {
                return fatherCtrHeight / 2 - ctrHeight / 2;
            }
            else if (alignment == UViewAlignment.Top)
            {
                return (fatherCtrHeight / 2 - Space / 2) / 2 - ctrHeight / 2;
            }
            else
            {
                int top = fatherCtrHeight / 2 + Space / 2;
                return top + (fatherCtrHeight - top) / 2 - ctrHeight / 2;
                var view = group.GetChildren(i);
                if (view is CommonFormBase)
                {
                    ((CommonFormBase)view).CloseForm();
                    i--;
                }
            }
        }
@@ -841,7 +817,7 @@
        {
            //APP缓存加载开始
            UserCenterResourse.AccountOption.AppCanSignout = false;
            //还原远程连接变量
            //还原远程连接权限变量
            ZigBee.Device.ZbGateway.AllowRemoteCtrl = true;
            //只有在住宅ID不一样的时候才做这个操作
@@ -855,17 +831,8 @@
                }
                catch { }
                //消息记录重新读取及检测
                ControlCommonResourse.ReadMessageAgain = true;
                ControlCommonResourse.HadNewMessage = false;
                HdlThreadLogic.Current.RunMain(() =>
                {
                    for (int i = 0; i < ControlCommonResourse.listMessageManaContr.Count; i++)
                    {
                        //显示角标特效
                        ControlCommonResourse.listMessageManaContr[i].IsSelected = false;
                    }
                });
                //清空所有成员缓存
                ClearAllMemberMemory();
                //加载账号配置信息
                var optionInfo = UserCenterResourse.AccountOption.Load();
@@ -916,14 +883,14 @@
                //初始化本地的设备信息
                Common.LocalDevice.Current.ReFreshByLocal();
                //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
                HdlRoomLogic.Current.RefreshAllRoomByLocation();
                if (hadNet == true)
                {
                    //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
                    HdlGatewayLogic.Current.SynchronizeDbGateway();
                }
                //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
                HdlRoomLogic.Current.RefreshAllRoomByLocation();
                //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用)
                HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
@@ -943,6 +910,29 @@
            return true;
        }
        /// <summary>
        /// 清空所有成员缓存
        /// </summary>
        private static void ClearAllMemberMemory()
        {
            //消息记录重新读取及检测
            ControlCommonResourse.ReadMessageAgain = true;
            ControlCommonResourse.HadNewMessage = false;
            HdlThreadLogic.Current.RunMain(() =>
            {
                for (int i = 0; i < ControlCommonResourse.listMessageManaContr.Count; i++)
                {
                    //显示角标特效
                    ControlCommonResourse.listMessageManaContr[i].IsSelected = false;
                }
            });
            //当前主页,场景和功能所选择的分支 1:场景 2:功能
            UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex = 1;
            //当前分类,场景和功能所选择的分支 0:场景 1:功能 2:自动化
            UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 0;
        }
        #endregion
        #region ■ 初始化登陆账号的信息_______________