using System;
using Shared.Common;
using Shared.Phone.UserView;
namespace Shared.Phone.Device.Account
{
///
/// 注册成功
///
public class RegisterSuccess:FrameLayout
{
///
/// 构造方法
///
public RegisterSuccess()
{
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
}
///
/// 显示界面
///
/// Name.
/// Password.
public void Show(string name,string password)
{
var midFL = new FrameLayout()
{
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
};
AddChidren(midFL);
var tip = new Button()
{
TextID = R.MyInternationalizationString.AccountRegisterSuccess,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 25,
TextAlignment = TextAlignment.Center,
Gravity=Gravity.CenterHorizontal,
Y=Application.GetRealHeight(300),
Height = Application.GetRealHeight(100),
Width=Application.GetRealWidth(700)
};
midFL.AddChidren(tip);
var logo = new Button()
{
Width = Application.GetMinRealAverage(210),
Height = Application.GetMinRealAverage(210),
Y = Application.GetRealHeight(200) + tip.Bottom,
UnSelectedImagePath = "Account/UserIMGSelected.png",
Gravity = Gravity.CenterHorizontal
};
midFL.AddChidren(logo);
var account = new Button()
{
Text=name,
Gravity=Gravity.CenterHorizontal,
Width=Application.GetRealWidth(500),
Height=Application.GetRealHeight(80),
Y=logo.Bottom+Application.GetRealHeight(50),
TextColor=ZigbeeColor.Current.GXCTextBlackColor,
TextAlignment=TextAlignment.Center,
TextSize=10
};
midFL.AddChidren(account);
//完成
//点击后直接登录,不需要用户再次回到登录页面登录了
var backToLogin = new Button()
{
Y = Application.GetRealHeight(1920 - 400),
Height = Application.GetRealHeight(110),
Width = Application.GetRealWidth(700),
Gravity = Gravity.CenterHorizontal,
BackgroundColor = ZigbeeColor.Current.GXCTextBlueColor,
TextID = R.MyInternationalizationString.Complete,
TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
Radius= (uint)Application.GetRealHeight(55)
};
midFL.AddChidren(backToLogin);
backToLogin.MouseUpEventHandler += (sender, e) =>
{
//注册成功,直接后台登录,不需要用户再次输入账号密码确认登录
this.RemoveFromParent();
CommonPage.Instance.RemoveViewByTag("Register");
try
{
UserPage.Instance.Fresh();
CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
Action action = async () => {
var loginSuccess = await HomePage.Instance.LoginByPWDAsync(name, password);
if (loginSuccess == 1)
{
new System.Threading.Thread(async () =>
{
ZigBee.Common.Application.Init();
//登录成功
var homes = await House.GetHomeLists();
//刷新个人中心的内存及线程
await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
Shared.Common.Room.canInitAllRoom = true;
Shared.Common.Room.InitAllRoom();
Application.RunOnMainThread(() =>
{
UserPage.Instance.Fresh();
CommonPage.Loading.Hide();
});
})
{ IsBackground = true }.Start();
}
else
{
//未登录成功弹出登录界面 同时需要标记为未登录状态
Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
Config.Instance.Save();
var login = new Device.Account.AccountLogin { };
CommonPage.Instance.AddChidren(login);
login.Show(name, password);
}
};
action();
}
catch
{ }
finally
{
CommonPage.Loading.Hide();
}
};
}
}
}