wxr
2019-12-06 9aa32bd5ed75d54b2141b6c91f163d43216a3643
HDL_ON/UI/UI2/4-PersonalCenter/BLL/PersonalCenterPageBLL.cs
@@ -1,7 +1,101 @@
using System;
using Shared;
namespace HDL_ON.UI2
{
    public partial class PersonalCenterPage
    {
        /// <summary>
        /// 加载事件列表
        /// </summary>
        void LoadEventList()
        {
            LoadEvent_SwitchHome();
        }
        /// <summary>
        /// 住宅列表点击事件
        /// </summary>
        void LoadEvent_SwitchHome()
        {
            btnCurResidenceName.MouseUpEventHandler += (sender, e) => {
                var dialog = new Dialog();
                var dialogBody = new FrameLayout();
                dialog.AddChidren(dialogBody);
                dialogBody.MouseUpEventHandler += (sender1, e1) => {
                    dialog.Close();
                };
                var dispalyView = new FrameLayout()
                {
                    X = Application.GetRealWidth(22),
                    Y = Application.GetRealHeight(268),
                    Width = Application.GetRealWidth(160),
                    Height = Application.GetRealHeight(190),
                    BackgroundImagePath = "PersonalCenter/HomeListbg.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),
                };
                dispalyView.AddChidren(contentView);
                foreach(var home in MainPage.LoginUser.HomeLists)
                {
                    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,
                        Text = home.Name,
                        TextSize = UI.CSS.CSS_FontSize.SubheadingFontSize,
                        IsSelected = UserConfig.Instance.CurrentRegion.RegionID == home.RegionID,
                        IsMoreLines = true,
                        Tag = home
                    };
                    contentView.AddChidren(btnHomeName);
                    var btnContentLine = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(112),
                        Height = Application.GetRealHeight(1),
                        BackgroundColor = UI.CSS.CSS_Color.SecondLevelTitleColor
                    };
                    contentView.AddChidren(btnContentLine);
                    btnHomeName.MouseUpEventHandler += (senderH, en) =>
                    {
                        var regionInfo = btnHomeName.Tag as RegionInfoRes;
                        //LoadMothed_SwitchHome(regionInfo);
                        UserConfig.Instance.CurrentRegion = regionInfo;
                        btnCurResidenceName.Text = regionInfo.Name;
                        UserConfig.Instance.SaveUserConfig();
                    };
                }
                dialog.Show();
            };
        }
        /// <summary>
        /// 切换住宅
        /// </summary>
        /// <param name="regionInfo"></param>
        void LoadMothed_SwitchHome(RegionInfoRes regionInfo)
        {
            UserConfig.Instance.CurrentRegion = regionInfo;
            btnCurResidenceName.Text = regionInfo.Name;
            UserConfig.Instance.SaveUserConfig();
        }
    }
}