using System;
|
using System.Collections.Generic;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class SubaccountListView : FrameLayout
|
{
|
List<SubAccountRes> subaccountList;
|
VerticalScrolViewLayout subaccountListView;
|
|
public SubaccountListView (List<SubAccountRes> SubaccountList)
|
{
|
BackgroundColor = SkinStyle.Current.MainColor;
|
subaccountList = SubaccountList;
|
}
|
|
public void ShowSubaccountListView ()
|
{
|
#region ---TopView---
|
FrameLayout topView = new FrameLayout () {
|
Height = Application.GetRealHeight (126),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (topView);
|
|
var back = new Button () {
|
Y = Application.GetRealHeight (30),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
(Parent as PageLayout).PageIndex -= 1;
|
};
|
|
Button NameButton = new Button () {
|
Width = Application.GetMinRealAverage (400),
|
Height = Application.GetMinRealAverage (90),
|
TextID = R.MyInternationalizationString.Subaccount,
|
TextColor = SkinStyle.Current.TextColor1,
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
Y = Application.GetRealHeight (30),
|
TextSize = 20,
|
};
|
topView.AddChidren (NameButton);
|
|
Button ItemButton = new Button () {
|
Width = Application.GetMinRealAverage (55),
|
Height = Application.GetMinRealAverage (55),
|
UnSelectedImagePath = "Item/+.png",
|
SelectedImagePath = "Item/+.png",
|
Y = Application.GetRealHeight (50),
|
X = Application.GetRealWidth (640 - 80),
|
};
|
topView.AddChidren (ItemButton);
|
#endregion
|
|
EventHandler<MouseEventArgs> addSubaccountHandler = (sender, e) => {
|
modifySubaccount (null);
|
};
|
ItemButton.MouseUpEventHandler += addSubaccountHandler;
|
|
FrameLayout topUserMsgView = new FrameLayout () {
|
Y = Application.GetRealHeight (126),
|
Height = Application.GetRealHeight (175),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
AddChidren (topUserMsgView);
|
|
Button btnUserIcon = new Button () {
|
X = Application.GetRealWidth (27),
|
Width = Application.GetMinRealAverage (96),
|
Height = Application.GetMinRealAverage (96),
|
Gravity = Gravity.CenterVertical,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
UnSelectedImagePath = "AccountSettings/User.png",
|
};
|
topUserMsgView.AddChidren (btnUserIcon);
|
|
Button btnUserName = new Button () {
|
X = btnUserIcon.Right + Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (50),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Account
|
};
|
topUserMsgView.AddChidren (btnUserName);
|
|
Button btnUserAccount = new Button () {
|
X = btnUserName.X,
|
Y = btnUserName.Bottom,
|
Width = btnUserName.Width,
|
Height = btnUserName.Height,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = "",
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
topUserMsgView.AddChidren (btnUserAccount);
|
if (MainPage.LoginUser != null) {
|
btnUserAccount.Text += MainPage.LoginUser.AccountString;
|
}
|
|
VerticalScrolViewLayout contentView = new VerticalScrolViewLayout () {
|
Y = topUserMsgView.Bottom,
|
Height = Application.GetRealHeight (Application.DesignHeight) - topUserMsgView.Bottom,
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
ScrollEnabled = false,
|
};
|
AddChidren (contentView);
|
|
var debugAccount = subaccountList.Find ((obj) => obj.UserType == 2);
|
if (debugAccount != null) {
|
Button debugViewTilte = new Button () {
|
Height = Application.GetRealHeight (50),
|
TextID = R.MyInternationalizationString.DebugAccount,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
Padding = new Padding(0,Application.GetRealWidth (40),0,0),
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
contentView.AddChidren (debugViewTilte);
|
|
FrameLayout debugView = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
contentView.AddChidren (debugView);
|
|
Button btnDebugTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
Text = debugAccount.Account,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
debugView.AddChidren (btnDebugTitle);
|
|
Button rightButton = new Button () {
|
X = Application.GetRealWidth (580),
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
debugView.AddChidren (rightButton);
|
|
EventHandler<MouseEventArgs> eHandler = (sender, e) => {
|
Dialog dialog = new Dialog ();
|
|
FrameLayout dialogBodyView = new FrameLayout () {
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (600),
|
Radius = 5,
|
BorderWidth = 0,
|
BorderColor = SkinStyle.Current.Transparent,
|
Gravity = Gravity.Center,
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
};
|
dialog.AddChidren (dialogBodyView);
|
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (80),
|
TextID = R.MyInternationalizationString.DebugAccount,
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
TextAlignment = TextAlignment.Center,
|
};
|
dialogBodyView.AddChidren (btnTitle);
|
|
Button btnAccountTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
Y = btnTitle.Bottom,
|
Width = Application.GetRealWidth (100),
|
Height = Application.GetRealHeight (80),
|
TextID = R.MyInternationalizationString.Account,
|
TextColor = SkinStyle.Current.TextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
dialogBodyView.AddChidren (btnAccountTitle);
|
|
TextView btnAccountText = new TextView () {
|
X = btnAccountTitle.Right,
|
Y = btnTitle.Bottom,
|
IsMoreLines = true,
|
Enable = false,
|
Width = Application.GetRealWidth (320),
|
Height = Application.GetRealHeight (100),
|
Text = debugAccount.Account,
|
TextColor = SkinStyle.Current.TextColor,
|
//TextAlignment = TextAlignment.CenterLeft,
|
};
|
dialogBodyView.AddChidren (btnAccountText);
|
|
FrameLayout enableIconView = new FrameLayout () {
|
X = Application.GetRealWidth (40),
|
Y = btnAccountTitle.Bottom + Application.GetRealHeight (30),
|
Width = Application.GetRealWidth (60),
|
Height = Application.GetRealWidth (59),
|
BackgroundColor = SkinStyle.Current.SubtitleView,
|
Radius = (uint)Application.GetRealWidth (30),
|
};
|
dialogBodyView.AddChidren (enableIconView);
|
|
Button btnEnableIcon = new Button () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (60),
|
Height = Application.GetRealWidth (59),
|
SelectedImagePath = "Light/CheckOn.png",
|
UnSelectedImagePath = "Light/Check.png",
|
IsSelected = debugAccount.IsEnable == 0 ? true : false
|
};
|
enableIconView.AddChidren (btnEnableIcon);
|
|
btnEnableIcon.MouseUpEventHandler += (sender2, e2) => {
|
btnEnableIcon.IsSelected = !btnEnableIcon.IsSelected;
|
MainPage.Loading.Start ("");
|
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
if (debugAccount.IsEnable == 1) {
|
var requestObj = new EnableDebugObj () { Account = debugAccount.Account };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("EnableDebug", requestJson);
|
if (revertObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SetSuccessfully),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
debugAccount.IsEnable = 0;
|
});
|
}
|
} else {
|
var requestObj = new DisableDebugObj () { Account = debugAccount.Account };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("DisableDebug", requestJson);
|
if (revertObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SetSuccessfully),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
debugAccount.IsEnable = 1;
|
});
|
}
|
}
|
} catch {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.FailureToServer),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
|
Button btnEnable = new Button () {
|
X = enableIconView.Right + Application.GetRealWidth (30),
|
Y = btnAccountTitle.Bottom + Application.GetRealHeight (30),
|
Width = Application.GetRealWidth (300),
|
Height = Application.GetRealHeight (59),
|
TextID = R.MyInternationalizationString.EnableDebugAccount,
|
TextColor = SkinStyle.Current.TextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
dialogBodyView.AddChidren (btnEnable);
|
|
|
Button btnModifypassword = new Button () {
|
X = Application.GetRealWidth (40),
|
Y = enableIconView.Bottom + Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (420),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.SubtitleView,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
TextID = R.MyInternationalizationString.ModifyPasswrod,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
};
|
dialogBodyView.AddChidren (btnModifypassword);
|
|
btnModifypassword.MouseUpEventHandler += (sender2, e2) => {
|
btnModifypassword.RemoveFromParent ();
|
EditText etPassword = new EditText () {
|
X = Application.GetRealWidth (40),
|
Y = enableIconView.Bottom + Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (420),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.DialogTitle,
|
BorderWidth = 2,
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterNewPassword),
|
TextAlignment = TextAlignment.Center
|
};
|
dialogBodyView.AddChidren (etPassword);
|
|
Button btnSaveSubaccountPassword = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = etPassword.Bottom + Application.GetRealHeight (20),
|
Width = Application.GetRealWidth (200),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.DialogTitle,
|
BorderWidth = 0,
|
TextID = R.MyInternationalizationString.SAVE,
|
};
|
dialogBodyView.AddChidren (btnSaveSubaccountPassword);
|
|
//Tip tipPasswordLength = new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PleaseEnterThe6DigitCode), Direction = AMPopTipDirection.Up, CloseTime = 3 };
|
|
btnSaveSubaccountPassword.MouseUpEventHandler += (sender3, e3) => {
|
MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
|
string newPassword = etPassword.Text.Trim ();
|
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
var requestObj = new EditSubAccountObj () { Id = debugAccount.UserID,Email = debugAccount.Account,Password = newPassword,Remark = ""};
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("EditSubAccount", requestJson);
|
if (revertObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
etPassword.RemoveFromParent ();
|
btnSaveSubaccountPassword.RemoveFromParent ();
|
dialogBodyView.AddChidren (btnModifypassword);
|
});
|
}
|
} catch {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.FailureToServer),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
};
|
Button btnClose = new Button () {
|
Y = Application.GetRealHeight (520),
|
Height = Application.GetRealHeight (85),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextID = R.MyInternationalizationString.Close,
|
TextAlignment = TextAlignment.Center,
|
};
|
dialogBodyView.AddChidren (btnClose);
|
btnClose.MouseUpEventHandler += (sender32, e32) => {
|
dialog.Close ();
|
};
|
dialog.Show ();
|
};
|
debugView.MouseUpEventHandler += eHandler;
|
rightButton.MouseUpEventHandler += eHandler;
|
btnDebugTitle.MouseUpEventHandler += eHandler;
|
|
}
|
|
FrameLayout subaccountView = new FrameLayout () {
|
Height = Application.GetRealHeight (50),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
contentView.AddChidren (subaccountView);
|
|
Button btnSubaccountText = new Button () {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (600),
|
TextID = R.MyInternationalizationString.Subaccount,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
subaccountView.AddChidren (btnSubaccountText);
|
|
//Button btnSubaccountAdd = new Button () {
|
// X = Application.GetRealWidth (550),
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (55),
|
// UnSelectedImagePath = "Item/+.png",
|
// SelectedImagePath = "Item/+Selected.png",
|
// Gravity = Gravity.CenterVertical,
|
//};
|
//subaccountView.AddChidren (btnSubaccountAdd);
|
|
|
//btnSubaccountAdd.MouseUpEventHandler += addSubaccountHandler;
|
//btnSubaccountText.MouseUpEventHandler += addSubaccountHandler;
|
Button btnSubaccountLine = new Button () {
|
Y = Application.GetRealHeight (105),
|
Height = Application.GetRealHeight (10),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
subaccountView.AddChidren (btnSubaccountLine);
|
|
subaccountListView = new VerticalScrolViewLayout () {
|
Height = Application.GetRealHeight(660),
|
};
|
contentView.AddChidren (subaccountListView);
|
|
addSubaccountList ();
|
|
}
|
|
void addSubaccountList ()
|
{
|
subaccountListView.RemoveAll ();
|
foreach (var subaccount in subaccountList) {
|
if (subaccount.UserType == 2)
|
continue;
|
RowLayout subaccountRowView = new RowLayout () {
|
Height = Application.GetRealHeight(110),
|
};
|
subaccountListView.AddChidren (subaccountRowView);
|
|
Button btnSubaccountReamrk = new Button () {
|
X = Application.GetRealWidth (40),
|
Height = Application.GetRealHeight(50),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = Language.StringByID(R.MyInternationalizationString.Remark) +": "+ subaccount.Remark,
|
};
|
subaccountRowView.AddChidren (btnSubaccountReamrk);
|
|
Button btnDebugTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
Y = btnSubaccountReamrk.Bottom,
|
Height = Application.GetRealHeight(50),
|
Text = Language.StringByID(R.MyInternationalizationString.Account) +": " + subaccount.Account,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
subaccountRowView.AddChidren (btnDebugTitle);
|
|
Button rightButton = new Button () {
|
X = Application.GetRealWidth (580),
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
subaccountRowView.AddChidren (rightButton);
|
|
EventHandler<MouseEventArgs> eHandler = (sender, e) => {
|
modifySubaccount (subaccount);
|
};
|
subaccountRowView.MouseUpEventHandler += eHandler;
|
btnDebugTitle.MouseUpEventHandler += eHandler;
|
rightButton.MouseUpEventHandler += eHandler;
|
|
Button btnRowLine = new Button () {
|
Y = Application.GetRealHeight(105),
|
Height = Application.GetRealHeight(5),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
subaccountRowView.AddChidren (btnRowLine);
|
|
Button btnDel = new Button () {
|
TextID = R.MyInternationalizationString.Del,
|
BackgroundColor = SkinStyle.Current.DelColor
|
};
|
subaccountRowView.AddRightView (btnDel);
|
btnDel.MouseUpEventHandler += (sender2, e2) => {
|
Alert delSubaccount = new Alert (Language.StringByID (R.MyInternationalizationString.Tip),
|
Language.StringByID (R.MyInternationalizationString.DeleteSubaccount),
|
Language.StringByID (R.MyInternationalizationString.cancel),
|
Language.StringByID (R.MyInternationalizationString.confirm));
|
delSubaccount.Show ();
|
delSubaccount.ResultEventHandler += (sender, e) => {
|
if (e) {
|
MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
|
try {
|
var requestObj = new RemoveSubAccountObj () { Email = subaccount.Account };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("RemoveSubAccount", requestJson);
|
if (revertObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
subaccountList.Remove (subaccount);
|
addSubaccountList ();
|
});
|
}
|
} catch {
|
MainPage.FailureToServer ();
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
}
|
};
|
};
|
}
|
}
|
|
void modifySubaccount (SubAccountRes subaccount)
|
{
|
bool isModify = true;
|
if (subaccount == null) {
|
subaccount = new SubAccountRes ();
|
isModify = false;
|
}
|
Dialog dialog = new Dialog ();
|
FrameLayout subaccountDialogView = new FrameLayout () {
|
Width = Application.GetMinRealAverage (500),
|
Height = Application.GetMinRealAverage (650),
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.Center,
|
};
|
dialog.AddChidren (subaccountDialogView);
|
|
Button btnTitle = new Button () {
|
Height = Application.GetMinRealAverage (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.AddSubaccount,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
};
|
subaccountDialogView.AddChidren (btnTitle);
|
if (isModify) {
|
btnTitle.TextID = R.MyInternationalizationString.Subaccount;
|
}
|
|
Button btnSubaccountReamrk = new Button () {
|
X = Application.GetMinRealAverage (40),
|
Y = btnTitle.Bottom + Application.GetMinRealAverage (30),
|
Width = Application.GetMinRealAverage (420),
|
Height = Application.GetMinRealAverage (40),
|
TextID = R.MyInternationalizationString.Remark,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
subaccountDialogView.AddChidren (btnSubaccountReamrk);
|
|
EditText etSubaccountReamrk = new EditText () {
|
X = Application.GetMinRealAverage (40),
|
Y = btnSubaccountReamrk.Bottom,
|
Width = Application.GetMinRealAverage (420),
|
Height = Application.GetMinRealAverage (80),
|
TextColor = SkinStyle.Current.TextColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.DialogTitle,
|
BorderWidth = 2,
|
TextAlignment = TextAlignment.Center,
|
Text = subaccount.Remark,
|
};
|
subaccountDialogView.AddChidren (etSubaccountReamrk);
|
|
Button btnEmail = new Button () {
|
X = Application.GetMinRealAverage (40),
|
Y = etSubaccountReamrk.Bottom + Application.GetMinRealAverage (20),
|
Width = Application.GetMinRealAverage (420),
|
Height = Application.GetMinRealAverage (40),
|
TextID = R.MyInternationalizationString.Account,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
subaccountDialogView.AddChidren (btnEmail);
|
|
EditText etEmail = new EditText () {
|
X = Application.GetMinRealAverage (40),
|
Y = btnEmail.Bottom,
|
Width = Application.GetMinRealAverage (420),
|
Height = Application.GetMinRealAverage (80),
|
TextColor = SkinStyle.Current.TextColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.DialogTitle,
|
BorderWidth = 2,
|
TextAlignment = TextAlignment.Center,
|
Text = subaccount.Account,
|
};
|
subaccountDialogView.AddChidren (etEmail);
|
|
Button btnSubaccountPassword = new Button () {
|
X = Application.GetMinRealAverage (40),
|
Y = etEmail.Bottom + Application.GetMinRealAverage (20),
|
Width = Application.GetMinRealAverage (420),
|
Height = Application.GetMinRealAverage (40),
|
TextID = R.MyInternationalizationString.Password,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
subaccountDialogView.AddChidren (btnSubaccountPassword);
|
|
EditText etSubaccountPassword = new EditText () {
|
X = Application.GetMinRealAverage (40),
|
Y = btnSubaccountPassword.Bottom,
|
Width = Application.GetMinRealAverage (420),
|
Height = Application.GetMinRealAverage (80),
|
TextColor = SkinStyle.Current.TextColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.DialogTitle,
|
BorderWidth = 2,
|
TextAlignment = TextAlignment.Center,
|
};
|
subaccountDialogView.AddChidren (etSubaccountPassword);
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = subaccountDialogView.Height - Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (90),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
};
|
subaccountDialogView.AddChidren (bottomView);
|
|
Button btnCancel = new Button () {
|
Width = Application.GetMinRealAverage (249),
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
TextID = R.MyInternationalizationString.cancel,
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender3, e3) => {
|
dialog.Close ();
|
};
|
|
Button btnBottomLine = new Button () {
|
X = btnCancel.Right,
|
Width = Application.GetMinRealAverage (2),
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
};
|
bottomView.AddChidren (btnBottomLine);
|
|
Button btnSaveSubaccount = new Button () {
|
X = btnBottomLine.Right,
|
Width = Application.GetMinRealAverage (248),
|
TextID = R.MyInternationalizationString.SAVE,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
TextAlignment = TextAlignment.Center,
|
};
|
bottomView.AddChidren (btnSaveSubaccount);
|
|
btnSaveSubaccount.MouseUpEventHandler += (sender3, e3) => {
|
string addSubaccount = etEmail.Text.Trim ();
|
string addSubaccountPassword = etSubaccountPassword.Text.Trim ();
|
string addSubaccountReamrk = etSubaccountReamrk.Text.Trim ();
|
if (string.IsNullOrEmpty (addSubaccount)) {
|
new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.TipEntrySubaccount), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etEmail);
|
return;
|
}
|
if (string.IsNullOrEmpty (addSubaccountPassword)) {
|
new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PleaseEnterPassword), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etSubaccountPassword);
|
return;
|
}
|
if(string.IsNullOrEmpty (addSubaccountReamrk)){
|
new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.TipEntrySubaccountRemark), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etSubaccountReamrk);
|
return;
|
}if (addSubaccountPassword.Length < 6) {
|
new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PasswordLenghtTip), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show (etSubaccountPassword);
|
return;
|
}
|
MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
|
|
subaccount.Account = addSubaccount;
|
subaccount.Remark = addSubaccountReamrk;
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
if (isModify) {
|
var requestObj = new EditSubAccountObj () { Id = subaccount.UserID, Email = addSubaccount, Password = addSubaccountPassword, Remark = addSubaccountReamrk };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("EditSubAccount", requestJson);
|
if (revertObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
addSubaccountList ();
|
dialog.Close ();
|
});
|
}
|
} else {
|
var requestObj = new SignSubAccountObj () { Email = addSubaccount, Password = addSubaccountPassword, Remark = addSubaccountReamrk };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("SignSubAccount", requestJson);
|
if (revertObj.StateCode == "SUCCESS") {
|
var requestObj2 = new GetSubAccountListObj ();
|
var requesetJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
|
var requesetRevertObj2 = MainPage.RequestHttps ("GetSubAccountList", requesetJson2);
|
if (requesetRevertObj2.StateCode == "SUCCESS") {
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SubAccountRes>> (requesetRevertObj2.ResponseData.ToString ());
|
subaccountList = responseDataObj;
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.addsuccess),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
addSubaccountList ();
|
dialog.Close ();
|
});
|
}
|
}
|
}
|
} catch (Exception ex) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.FailureToServer),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
Console.WriteLine (ex.ToString());
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
|
dialog.Show ();
|
}
|
}
|
}
|