using System;
|
using System.Collections.Generic;
|
using service.hdlcontrol.com_push;
|
|
namespace Shared.SimpleControl.Pad
|
{
|
public class AccountManagement : Dialog
|
{
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public AccountManagement ()
|
{
|
AccountManagementShow ();
|
}
|
|
void AccountManagementShow ()
|
{
|
#region
|
FrameLayout FrameLayoutView = new FrameLayout () {
|
Width = Application.GetRealWidth (840),
|
Height = Application.GetRealHeight (1120),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Gravity = Gravity.Center
|
};
|
AddChidren (FrameLayoutView);
|
|
Button topButton = new Button () {
|
Height = Application.GetRealHeight (120),
|
BackgroundColor = 0xFF333333,
|
Text = MainPage.LoginUser.AccountString,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 18,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
FrameLayoutView.AddChidren (topButton);
|
|
EditText originalPassword = new EditText () {
|
Width = Application.GetRealWidth (680),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (80),
|
Y = topButton.Bottom + Application.GetRealHeight (80),
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterOldPassword),
|
UnSelectedImagePath = "Register/Register_Password_kuang.png",
|
PlaceholderTextColor = 0xFF333333,
|
TextAlignment = TextAlignment.Center,
|
Radius = (uint)Application.GetRealHeight (0),
|
SecureTextEntry = true
|
};
|
FrameLayoutView.AddChidren (originalPassword);
|
|
EditText newPasswordEditText = new EditText () {
|
Width = Application.GetRealWidth (680),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (80),
|
Y = originalPassword.Bottom + Application.GetRealHeight (80),
|
UnSelectedImagePath = "Register/Register_Password_kuang.png",
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseSetNewPasword),
|
PlaceholderTextColor = 0xFF333333,
|
TextAlignment = TextAlignment.Center,
|
Radius = (uint)Application.GetRealHeight (0),
|
SecureTextEntry = true
|
};
|
FrameLayoutView.AddChidren (newPasswordEditText);
|
|
EditText confirmNewPasswordEditText = new EditText () {
|
Width = Application.GetRealWidth (680),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (80),
|
Y = newPasswordEditText.Bottom + Application.GetRealHeight (80),
|
UnSelectedImagePath = "Register/Register_Password_kuang.png",
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseConfirmNewPassword),
|
PlaceholderTextColor = 0xFF333333,
|
TextAlignment = TextAlignment.Center,
|
Radius = (uint)Application.GetRealHeight (0),
|
SecureTextEntry = true
|
};
|
FrameLayoutView.AddChidren (confirmNewPasswordEditText);
|
|
#endregion
|
Button btnClose = new Button () {
|
X = Application.GetRealWidth (80),
|
Y = confirmNewPasswordEditText.Bottom + Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (300),
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = 0xFF2f2f2f,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.Close
|
};
|
FrameLayoutView.AddChidren (btnClose);
|
btnClose.MouseUpEventHandler += (sender, e) => {
|
this.Close ();
|
};
|
|
Button btnOK = new Button () {
|
Width = Application.GetRealWidth (300),
|
Height = Application.GetRealHeight (89),
|
X = btnClose.Right + Application.GetRealWidth (80),
|
Y = btnClose.Y,
|
BackgroundColor = 0xFF2f2f2f,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.OK
|
};
|
FrameLayoutView.AddChidren (btnOK);
|
btnOK.MouseDownEventHandler += (sender, e) => {
|
btnOK.IsSelected = true;
|
};
|
btnOK.MouseUpEventHandler += (sender, e) => {
|
try {
|
btnOK.IsSelected = false;
|
if (MainPage.LoginUser == null) {
|
return;
|
}
|
|
if (string.IsNullOrEmpty (newPasswordEditText.Text.Trim ())) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.NewPasswordIsEmpty),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else if (newPasswordEditText.Text.Trim () != confirmNewPasswordEditText.Text.Trim ()) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseConfirmPasswordIsCorrect),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else {
|
var _userInfo = new UserInfo { AccountString = MainPage.LoginUser.AccountString, OriginalPassword = originalPassword.Text.Trim (), Password = newPasswordEditText.Text.Trim (), LastTime = DateTime.Now };
|
//Close ();
|
//new Register ().Show ();
|
var result = -88;
|
/// <summary>
|
/// 0:成功
|
/// 1:内容为空
|
/// 2.操作失败
|
/// 3.原密码不正确
|
/// </summary>
|
if (result == 1) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseWriteTheCompleteContent),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else if (result == 2) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SendEmaiFailed),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else if (result == 3) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.OldPasswordIsError),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else {
|
|
IO.FileUtils.WriteFileByBytes (UserInfo.GlobalRegisterFile, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (_userInfo)));
|
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 btnLogout = new Button () {
|
Height = Application.GetRealHeight (90),
|
Y = btnClose.Bottom + Application.GetRealHeight (80),
|
TextID = R.MyInternationalizationString.LogoutAccount,
|
TextSize = 15,
|
TextAlignment = TextAlignment.Center
|
};
|
FrameLayoutView.AddChidren (btnLogout);
|
btnLogout.MouseDownEventHandler += (sender, e) => {
|
btnLogout.IsSelected = true;
|
};
|
btnLogout.MouseUpEventHandler += (sender1, e1) => {
|
btnLogout.IsSelected = false;
|
if (MainPage.LoginUser == null) {
|
new Register ().Show ();
|
} else {
|
Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CloseYourAccount), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
|
alert.Show ();
|
alert.ResultEventHandler += (sender2, e2) => {
|
if (e2) {
|
IO.FileUtils.DeleteFile (UserInfo.GlobalRegisterFile);
|
Close ();
|
WebServicePush webPush = new WebServicePush ();
|
webPush.DeleteToken_Push (UserConfig.Instance.tokenID);
|
if (string.IsNullOrEmpty (UserConfig.Instance.RemoteModeFile))
|
return;
|
var gateWayString = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (UserConfig.Instance.RemoteModeFile));
|
if (gateWayString == null || gateWayString.Split ('_').Length < 2) {
|
return;
|
}
|
var common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (gateWayString);
|
if (UserConfig.Instance.RemoteModeFile.Split ('_') [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) {
|
var gateWay = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortWirelessFR> (gateWayString);
|
if (gateWay != null)
|
SystemRemote.LinkRemote (gateWay.Remote_UserName, gateWay.Remote_ProjectName, gateWay.Remote_Password, false);
|
} else if (UserConfig.Instance.RemoteModeFile.Split ('_') [1].ToString () == DeviceType.OnePortBus.ToString ()) {
|
var gateWay = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortBus> (gateWayString);
|
if (gateWay != null)
|
SystemRemote.LinkRemote (gateWay.Remote_UserName, gateWay.Remote_ProjectName, gateWay.Remote_Password, false);
|
}
|
}
|
};
|
}
|
};
|
}
|
}
|
}
|