From a715181089be0d31cd737a5367ffd02690b9d77f Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 12 十一月 2020 13:36:01 +0800 Subject: [PATCH] 20201112 --- HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs | 316 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 281 insertions(+), 35 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs index 56aed70..4bcc52c 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs @@ -1,10 +1,13 @@ 锘縰sing System; +using HDL_ON.Entity; using Shared; namespace HDL_ON.UI { public partial class PersonalCenterPage { + + /// <summary> /// 鍔犺浇浜嬩欢鍒楄〃 /// </summary> @@ -12,8 +15,15 @@ { LoadEvent_SwitchHome(); LoadEvent_GoPersonalDataPage(); + LoadEvent_SkipAboutOnPage(); + LoadEvent_SkipGetSupportPage(); + if (!DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) + { + LoadEvent_SkipResdentialManagePage(); + LoadEvent_GoMemberManagement(); + LoadEvent_SkipbtnAddFunctionPage(); + } } - #region 鍒囨崲浣忓畢 /// <summary> @@ -21,86 +31,322 @@ /// </summary> void LoadEvent_SwitchHome() { - btnCurResidenceName.MouseUpEventHandler += (sender, e) => { + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { var dialog = new Dialog(); var dialogBody = new FrameLayout(); dialog.AddChidren(dialogBody); - dialogBody.MouseUpEventHandler += (sender1, e1) => { + dialogBody.MouseUpEventHandler = (sender1, e1) => + { dialog.Close(); }; var dispalyView = new FrameLayout() { - X = Application.GetRealWidth(22), + X = Application.GetRealWidth(10), Y = Application.GetRealHeight(268), Width = Application.GetRealWidth(160), - Height = Application.GetRealHeight(190), - BackgroundImagePath = "PersonalCenter/HomeListbg.png", + Height = Application.GetRealHeight(110), + BackgroundImagePath = "PersonalCenter/HomeList1bg.png", }; dialogBody.AddChidren(dispalyView); - var contentView = new VerticalScrolViewLayout() { - X = Application.GetRealWidth(8), - Y = Application.GetRealHeight(16), - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(45*4), + var contentView = new VerticalScrolViewLayout() + { + X = Application.GetRealWidth(22), + Y = Application.GetRealHeight(15), + Width = Application.GetRealWidth(150), + Height = Application.GetRealHeight(45), + ScrollEnabled = false }; dispalyView.AddChidren(contentView); - foreach(var home in MainPage.LoginUser.HomeLists) + if (MainPage.LoginUser.regionList.Count < 3) + { + } + else if (MainPage.LoginUser.regionList.Count < 4) + { + dispalyView = new FrameLayout() + { + X = Application.GetRealWidth(10), + Y = Application.GetRealHeight(268), + Width = Application.GetRealWidth(160), + Height = Application.GetRealHeight(155), + BackgroundImagePath = "PersonalCenter/HomeList2bg.png", + }; + dialogBody.AddChidren(dispalyView); + + contentView.Height = Application.GetRealHeight(45 * 3); + dispalyView.AddChidren(contentView); + } + else if (MainPage.LoginUser.regionList.Count < 5) + { + dispalyView = new FrameLayout() + { + X = Application.GetRealWidth(10), + Y = Application.GetRealHeight(268), + Width = Application.GetRealWidth(160), + Height = Application.GetRealHeight(200), + BackgroundImagePath = "PersonalCenter/HomeList3bg.png", + }; + dialogBody.AddChidren(dispalyView); + + contentView.Height = Application.GetRealHeight(45 * 4); + dispalyView.AddChidren(contentView); + } + else + { + dispalyView = new FrameLayout() + { + X = Application.GetRealWidth(10), + Y = Application.GetRealHeight(268), + Width = Application.GetRealWidth(160), + Height = Application.GetRealHeight(245), + BackgroundImagePath = "PersonalCenter/HomeList4bg.png", + }; + dialogBody.AddChidren(dispalyView); + + contentView.Height = Application.GetRealHeight(45 * 5); + contentView.ScrollEnabled = true; + dispalyView.AddChidren(contentView); + } + + + + foreach (var home in MainPage.LoginUser.regionList) { var btnHomeName = new Button() { - Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(44), TextAlignment = TextAlignment.CenterLeft, - TextColor = UI.CSS.CSS_Color.MainBackgroundColor, - SelectedTextColor = UI.CSS.CSS_Color.MainColor, + TextColor = CSS.CSS_Color.FirstLevelTitleColor, + SelectedTextColor = CSS.CSS_Color.MainColor, Text = home.Name, - TextSize = UI.CSS.CSS_FontSize.SubheadingFontSize, - IsSelected = UserConfig.Instance.CurrentRegion.RegionID == home.RegionID, + TextSize = home.Name.Length > 14 ? CSS.CSS_FontSize.TextFontSize : CSS.CSS_FontSize.SubheadingFontSize, + IsSelected = DB_ResidenceData.residenceData.residecenInfo.RegionID == home.RegionID, IsMoreLines = true, - Tag = home + Tag = home.RegionID }; contentView.AddChidren(btnHomeName); - var btnContentLine = new Button() + + if (MainPage.LoginUser.regionList.IndexOf(home) < MainPage.LoginUser.regionList.Count - 1) { - Gravity = Gravity.CenterHorizontal, - Width = Application.GetRealWidth(112), - Height = Application.GetRealHeight(1), - BackgroundColor = UI.CSS.CSS_Color.SecondLevelTitleColor - }; - contentView.AddChidren(btnContentLine); + contentView.AddChidren(new Button() + { + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS.CSS_Color.BackgroundColor + }); + } btnHomeName.MouseUpEventHandler += (senderH, en) => { - var regionInfo = btnHomeName.Tag as RegionInfoRes; + var regionId = (string)btnHomeName.Tag; dialog.Close(); - - UserConfig.Instance.CurrentRegion = regionInfo; - btnCurResidenceName.Text = regionInfo.Name; - UserConfig.Instance.SaveUserConfig(); + //DB_ResidenceData.residenceData.CurReginID = regionId; + LoadEvent_ChangeCurHome(MainPage.LoginUser.regionList.Find((obj) => obj.RegionID == regionId)); + LoadContentView(); }; } - dialog.Show(); }; - } + btnResidenceDownIcon.MouseUpEventHandler = eventHandler; + btnCurResidenceName.MouseUpEventHandler = eventHandler; + } + /// <summary> + /// 鏇存崲褰撳墠閫変腑浣忓畢 + /// </summary> + /// <param name="homeTemp"></param> + void LoadEvent_ChangeCurHome(RegionInfoRes homeTemp) + { + if (DB_ResidenceData.residenceData.CurReginID == homeTemp.RegionID) + { + return; + } + string oldRegionRootPath = FileUtils.CreateRegionBackup(DB_ResidenceData.residenceData.CurReginID.ToString()); + string newRegionRootPath = FileUtils.CreateRegionBackup(homeTemp.RegionID.ToString()); + DB_ResidenceData.residenceData.CurReginID = homeTemp.RegionID; + DB_ResidenceData.residenceData.SaveResidenceData(); + var waitPage = new Loading(); + new System.Threading.Thread(() => + { + try + { + var backuplist = FileUtils.ReadFiles(); + int index = 0; + FileUtils.DeleteRegionFiles(oldRegionRootPath); + //绉诲姩鏂囦欢 + foreach (var fileName in backuplist) + { + System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileUtils.RootPath + fileName); + if (fileName == "headImage.png") + { + continue; + } + if (fileInfo.Exists) + { + fileInfo.MoveTo(oldRegionRootPath + fileName); + MainPage.Log("move file : " + fileName); + } + index++; + Application.RunOnMainThread(() => + { + int pro = (int)(index * 1.0 / backuplist.Count * 50); + waitPage.Text = pro.ToString() + "%"; + }); + } + //鍒犻櫎鏈湴鏂囦欢 + foreach (var fileName in backuplist) + { + if (fileName == "headImage.png") + { + continue; + } + FileUtils.DeleteFile(fileName); + } + //鍊掑嚭鏂颁綇瀹呮暟鎹� + FileUtils.RestoreRegionFiles(newRegionRootPath); + MainPage.LoginUser.SaveUserInfo(); + DB_ResidenceData.residenceData.EixtAccount(); + DB_ResidenceData.residenceData.CurReginID = homeTemp.RegionID; + OnAppConfig.Instance.SaveUserConfig(); + DB_ResidenceData.InitRoomFunction(); + DB_ResidenceData.residenceData.SaveResidenceData(); + Application.RunOnMainThread(() => + { + btnCurResidenceName.Text = DB_ResidenceData.residenceData.residecenInfo.Name; + }); + } + catch (Exception ex) + { + Application.RunOnMainThread(() => + { + new Alert(Language.StringByID(StringId.Tip), Language.StringByID(StringId.OperationFailed), + Language.StringByID(StringId.Close)).Show(); + }); + MainPage.Log(ex.Message); + } + finally + { + Application.RunOnMainThread(() => + { + waitPage.Hide(); + waitPage.RemoveFromParent(); + }); + } + }) + { IsBackground = true }.Start(); + } #endregion + #region 浣忓畢绠$悊 + void LoadEvent_SkipResdentialManagePage() + { + if (!DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) + { + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + Action updateResidenceName = () => + { + btnCurResidenceName.Text = DB_ResidenceData.residenceData.residecenInfo.Name; + }; + var residentialManagePage = new ResidentialManagePage(updateResidenceName); + MainPage.BasePageView.AddChidren(residentialManagePage); + residentialManagePage.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + btnResidenceManageIcon.MouseUpEventHandler = eventHandler; + btnResidenceManageText.MouseUpEventHandler = eventHandler; + } + } + #endregion #region 涓汉涓績 void LoadEvent_GoPersonalDataPage() { - btnUserHeadPortrait.MouseUpEventHandler += (sender, e) => { - var personalDataView = new PersonalDataPage(); + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + Action updataHeadImage = () => + { + userHeadImageView.ImagePath = MainPage.LoginUser.headImagePagePath; + }; + Action updataUserName = () => + { + btnUserName.Text = MainPage.LoginUser.userName; + }; + + var personalDataView = new PersonalDataPage(updataHeadImage, updataUserName); MainPage.BasePageView.AddChidren(personalDataView); personalDataView.LoadView(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; + userHeadImageView.MouseUpEventHandler = eventHandler; + btnUserName.MouseUpEventHandler = eventHandler; + btnEmail.MouseUpEventHandler = eventHandler; + } #endregion + + #region 鎴愬憳绠$悊 + void LoadEvent_GoMemberManagement() + { + EventHandler<MouseEventArgs> eHandler = (sender, e) => { + var mmp = new MemberManagementPage(); + MainPage.BasePageView.AddChidren(mmp); + mmp.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + btnResidenceMemberIcon.MouseUpEventHandler = eHandler; + btnResidenceMemberText.MouseUpEventHandler = eHandler; + } + + #endregion + + #region 娣诲姞璁惧 + void LoadEvent_SkipbtnAddFunctionPage() + { + EventHandler<MouseEventArgs> eventHandler = (sender, e) => { + var page = new SearchDevicePage(); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + btnResidenceAddFunctionIcon.MouseUpEventHandler = eventHandler; + btnResidenceAddFunctionText.MouseUpEventHandler = eventHandler; + } + #endregion + + #region 鍏充簬On銆佽幏鍙栨敮鎸� + /// <summary> + /// 璺宠浆鑷冲叧浜嶰n椤甸潰 + /// </summary> + void LoadEvent_SkipAboutOnPage() + { + btnAboutOnText.MouseUpEventHandler = (sender, e) => + { + var aboutOnPage = new AboutOnPage(); + MainPage.BasePageView.AddChidren(aboutOnPage); + aboutOnPage.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + } + /// <summary> + /// 璺宠浆鑷宠幏鍙栨敮鎸侀〉闈� + /// </summary> + void LoadEvent_SkipGetSupportPage() + { + btnSupportText.MouseUpEventHandler = (sender, e) => + { + var getsupportPage = new GetSupportPage(); + MainPage.BasePageView.AddChidren(getsupportPage); + getsupportPage.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + } + #endregion + + } -} +} \ No newline at end of file -- Gitblit v1.8.0