using Shared.SimpleControl.Phone;
|
using System;
|
using System.Collections.Generic;
|
using service.hdlcontrol.com_push;
|
|
namespace Shared.SimpleControl.Pad
|
{
|
public class Register : Dialog
|
{
|
public EditText Register_Email_Address;
|
EditText Register_Password;
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public Register ()
|
{
|
RegisterShow ();
|
Width = Application.GetRealWidth (870);
|
Height = Application.GetRealHeight (1000);
|
BackgroundColor = SkinStyle.Current.MainColor;
|
}
|
|
void RegisterShow ()
|
{
|
var userInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (UserInfo.GlobalRegisterFile)));
|
if (userInfo != null) {
|
if ((System.DateTime.Now - userInfo.LastTime).TotalDays < 7) {
|
Close ();
|
return;
|
}
|
}
|
|
#region Bottom
|
Button Register_logo = new Button () {
|
Width = Application.GetRealWidth (230),
|
Height = Application.GetRealHeight (201),
|
X = Application.GetRealWidth(310),
|
Y = Application.GetRealHeight(67),
|
UnSelectedImagePath = MainPage.RegisterLogoString,
|
};
|
AddChidren (Register_logo);
|
|
Register_Email_Address = new EditText () {
|
Width = Application.GetRealWidth (620),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (120),
|
Y = Application.GetRealHeight (380),
|
UnSelectedImagePath = "Register/Register_Email_Address.png",
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.EmailAddress),
|
PlaceholderTextColor = 0xFB757575,
|
TextAlignment = TextAlignment.Center,
|
Radius = (uint)Application.GetRealHeight (0),
|
};
|
Register_Email_Address.MouseUpEventHandler += (sender, e) => {
|
};
|
AddChidren (Register_Email_Address);
|
|
Register_Password = new EditText () {
|
Width = Application.GetRealWidth (620),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (120),
|
Y = Register_Email_Address.Bottom + Application.GetRealHeight (50),
|
UnSelectedImagePath = "Register/Register_Password_kuang.png",
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterPassword),
|
PlaceholderTextColor = 0xFB757575,
|
TextAlignment = TextAlignment.Center,
|
Radius = (uint)Application.GetRealHeight (0),
|
SecureTextEntry = true
|
};
|
Register_Password.MouseUpEventHandler += (sender, e) => {
|
};
|
AddChidren (Register_Password);
|
|
Button register = new Button () {
|
Width = Application.GetRealWidth (500 / 2),
|
Height = Application.GetRealHeight (85),
|
X = Application.GetRealWidth (120),
|
Y = Register_Password.Bottom + Application.GetRealHeight (10),
|
//BackgroundColor = SkinStyle.Current.SelectedBackgroundColor,
|
TextID = R.MyInternationalizationString.Register,
|
TextSize = 15,
|
TextColor = 0xFFDBDDDF,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
register.MouseUpEventHandler += (sender, e) => {
|
this.Close ();
|
new Register_info ().Show ();
|
};
|
AddChidren (register);
|
|
Button forgot_password = new Button () {
|
Width = Application.GetRealWidth (500 / 2),
|
Height = Application.GetRealHeight (85),
|
X = register.Right + Application.GetRealWidth(120),
|
Y = Register_Password.Bottom + Application.GetRealHeight (10),
|
TextID = R.MyInternationalizationString.ForgotPassword,
|
TextSize = 15,
|
//BackgroundColor = SkinStyle.Current.SelectedBackgroundColor,
|
TextColor = 0xFFDBDDDF,
|
TextAlignment = TextAlignment.CenterRight,
|
};
|
forgot_password.MouseUpEventHandler += (sender, e) => {
|
this.Close ();
|
new ForgotPassword ().Show ();
|
};
|
AddChidren (forgot_password);
|
#endregion
|
|
#region save
|
Button btnOK = new Button () {
|
Width = Application.GetRealWidth (300),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (100),
|
Y = Application.GetRealHeight(810),
|
BackgroundColor = 0xFF333333,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.Login,
|
TextSize = 15,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
AddChidren (btnOK);
|
btnOK.MouseDownEventHandler += (sender, e) => {
|
btnOK.IsSelected = true;
|
};
|
|
btnOK.MouseUpEventHandler += (sender, e) => {
|
try {
|
btnOK.IsSelected = false;
|
|
WebServiceLogin service_login = new WebServiceLogin ();
|
var result = Newtonsoft.Json.JsonConvert.DeserializeObject<ResultStatus> (service_login.Login2_0 (Register_Email_Address.Text.Trim (), Register_Password.Text.Trim (), MainPage.SoftSmsType));
|
/// <summary>
|
/// 0:成功
|
/// -1:账号未激活
|
/// -2:账户或者密码错误
|
/// </summary>
|
if (result.Code == -1) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.AccountHasNotBeenActivated),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else if (result.Code == -2) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.AccountOrPasswordIsWrong),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else {
|
var _userInfo = new UserInfo { ID = result.ID,MasterID = result.MasterID, AccountString = Register_Email_Address.Text.Trim (), Password = Register_Password.Text.Trim (), LastTime = DateTime.Now };
|
IO.FileUtils.WriteFileByBytes (UserInfo.GlobalRegisterFile, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (_userInfo)));
|
var se = new service.hdlcontrol.com_push.WebServicePush ();
|
se.VerifySoapHeaderValue = new service.hdlcontrol.com_push.VerifySoapHeader () { Email = _userInfo.AccountString, UserMode = 0 };
|
se.AddRegId (UserConfig.Instance.tokenID, UserConfig.Instance.phoneName);
|
Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote (2);
|
MainPage.LoginUser = new UserInfo { ID = result.ID, MasterID = result.MasterID, AccountType = result.AccountType, AccountString = Register_Email_Address.Text.Trim (), Password = Register_Password.Text.Trim (), LastTime = DateTime.Now };
|
Close ();
|
}
|
} catch (Exception ex) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
string mess = ex.Message;
|
}
|
};
|
|
Button cancel = new Button () {
|
Width = Application.GetRealWidth (300),
|
Height = Application.GetRealHeight (100),
|
X = btnOK.Right + Application.GetRealWidth (60),
|
Y = btnOK.Y,
|
BackgroundColor = 0xFF333333,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.Cancel,
|
TextSize = 15,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
AddChidren (cancel);
|
cancel.MouseDownEventHandler += (sender, e) => {
|
cancel.IsSelected = true;
|
};
|
|
cancel.MouseUpEventHandler += (sender, e) => {
|
cancel.IsSelected = false;
|
Close ();
|
};
|
#endregion
|
}
|
}
|
}
|