using System;
|
using Shared.Common;
|
using System.Text.RegularExpressions;
|
using System.Collections.Generic;
|
using System.Timers;
|
using Shared.Phone.UserView;
|
|
namespace Shared.Phone.Device.Account
|
{
|
/// <summary>
|
/// 验证码登录
|
/// </summary>
|
public class AccountLoginByCode: FrameLayout
|
{
|
/// <summary>
|
/// The phone string.
|
/// </summary>
|
public string phoneStr = "";
|
/// <summary>
|
/// 手机号输入是否符合规则
|
/// </summary>
|
public bool IsRightAccount = false;
|
/// <summary>
|
/// *****升级分布式后,Account 仅包含手机号,不再包含00区号。密码不再需要MD5加密。language为APP语
|
/// 下来选择手机区号 默认中国大陆为86
|
///发送国际 / 港澳台消息时,接收号码格式为00 + 国际区号 + 号码,如“008615899998888” 调用API时,Company字段请传入整型值:4。 。
|
///国内 调用API时,Company字段请传入整型值:0。
|
/// </summary>
|
public List<Common.ResponseEntity.AreaCodeOBJ> areaCodeList = new List<Common.ResponseEntity.AreaCodeOBJ>();
|
/// <summary>
|
/// Initializes a new instance of the <see cref="T:Shared.Phone.Device.Account.AccountLoginByCode"/> class.
|
/// </summary>
|
public AccountLoginByCode()
|
{
|
Tag = "Login";
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
}
|
/// <summary>
|
/// Show this instance.
|
/// </summary>
|
public async void Show()
|
{
|
CommonPage.Loading.Start();
|
try
|
{
|
var requestOBJ = new SendDataToServer.GetAreaCodeOBJ()
|
{
|
RequestVersion = CommonPage.RequestVersion
|
};
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestOBJ);
|
var revertOBJ = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/GetAreaCode", System.Text.Encoding.UTF8.GetBytes(requestJson));
|
if (revertOBJ == null)
|
{
|
return;
|
}
|
if (revertOBJ.StateCode.ToUpper() == "SUCCESS")
|
{
|
var responseData = revertOBJ.ResponseData;
|
areaCodeList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Common.ResponseEntity.AreaCodeOBJ>>(responseData.ToString());
|
}
|
}
|
catch { }
|
finally
|
{
|
CommonPage.Loading.Hide();
|
ShowLoginByCodeView();
|
}
|
|
}
|
/// <summary>
|
/// Shows the login by code view.
|
/// </summary>
|
public void ShowLoginByCodeView()
|
{
|
var t = new Timer();
|
var dateBegin = new DateTime();
|
|
#region midFrameLayout
|
var midFrameLayout = new FrameLayout()
|
{
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight(1920),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
};
|
AddChidren(midFrameLayout);
|
#endregion
|
|
#region 布局账户 注册 手机验证码登录
|
|
var registerBtn = new Button()
|
{
|
Width = Application.GetRealWidth(250),
|
Height = Application.GetRealHeight(80),
|
X = Application.GetRealWidth(1080 - 250 - 50),
|
Y = Application.GetRealHeight(100),
|
TextID = R.MyInternationalizationString.Register,
|
TextSize = 15,
|
TextColor = ZigbeeColor.Current.GXCTextBlueColor,
|
TextAlignment = TextAlignment.CenterRight
|
};
|
midFrameLayout.AddChidren(registerBtn);
|
|
var logoBtn = new Button()
|
{
|
Width = Application.GetMinRealAverage(270),
|
Height = Application.GetMinRealAverage(270),
|
Y = Application.GetRealHeight(150) + registerBtn.Bottom,
|
UnSelectedImagePath = "Logo/Logo.png",
|
Gravity = Gravity.CenterHorizontal
|
};
|
midFrameLayout.AddChidren(logoBtn);
|
|
var accountFL = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(700),
|
Height = Application.GetRealHeight(110),
|
Y = Application.GetRealHeight(200) + logoBtn.Bottom,
|
Radius = (uint)Application.GetRealHeight(55),
|
BorderColor = ZigbeeColor.Current.GXCBorderColor,
|
BorderWidth = 1,
|
Gravity = Gravity.CenterHorizontal
|
};
|
midFrameLayout.AddChidren(accountFL);
|
var accountZoneBtn = new Button()
|
{
|
Width = Application.GetRealWidth(200),
|
X = Application.GetRealWidth(20),
|
Text = "+" + CommonPage.PhoneZoneStr,
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor
|
};
|
accountFL.AddChidren(accountZoneBtn);
|
var accountZoneLine = new Button()
|
{
|
X = Application.GetRealWidth(10) + accountZoneBtn.Right,
|
Width = 1,
|
Height = Application.GetRealHeight(60),
|
Gravity=Gravity.CenterVertical,
|
BackgroundColor = ZigbeeColor.Current.GXCLineColor
|
};
|
accountFL.AddChidren(accountZoneLine);
|
var accountET = new EditText()
|
{
|
X = accountZoneLine.Right + Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(400),
|
PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum),
|
TextAlignment = TextAlignment.Center,
|
PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor
|
};
|
accountFL.AddChidren(accountET);
|
|
var verificationCodeFL = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(700),
|
Height = Application.GetRealHeight(110),
|
Y = accountFL.Bottom + Application.GetRealHeight(100),
|
Radius = (uint)Application.GetRealHeight(55),
|
BorderColor = ZigbeeColor.Current.GXCBorderColor,
|
BorderWidth = 1,
|
Gravity = Gravity.CenterHorizontal
|
};
|
midFrameLayout.AddChidren(verificationCodeFL);
|
var verificationCodeET = new EditText()
|
{
|
X = Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(350),
|
PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputVerificationCode),
|
TextAlignment = TextAlignment.Center,
|
PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor
|
};
|
verificationCodeFL.AddChidren(verificationCodeET);
|
|
var sendCodeLine = new Button()
|
{
|
X = Application.GetRealWidth(10) + verificationCodeET.Right,
|
Width = 1,
|
Height = Application.GetRealHeight(60),
|
Gravity=Gravity.CenterVertical,
|
BackgroundColor = ZigbeeColor.Current.GXCLineColor
|
};
|
verificationCodeFL.AddChidren(sendCodeLine);
|
|
var sendCodeBtn = new Button()
|
{
|
X = sendCodeLine.Right + Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(250),
|
TextID = R.MyInternationalizationString.SendVerificationCode,
|
TextColor = ZigbeeColor.Current.GXCTextUnselectedColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor,
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
IsSelected=false
|
};
|
verificationCodeFL.AddChidren(sendCodeBtn);
|
|
var loginBtn = new Button()
|
{
|
Width = Application.GetRealWidth(700),
|
Height = Application.GetRealHeight(110),
|
Y = Application.GetRealHeight(200) + verificationCodeFL.Bottom,
|
TextID = R.MyInternationalizationString.Login,
|
TextSize = 15,
|
TextColor = Shared.Common.ZigbeeColor.Current.GXCTextWhiteColor,
|
Radius = (uint)Application.GetRealHeight(55),
|
BorderWidth = 0,
|
BackgroundColor = ZigbeeColor.Current.GXCButtonUnselectedColor,
|
SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
Gravity = Gravity.CenterHorizontal,
|
Enable = false,
|
IsSelected=false
|
};
|
midFrameLayout.AddChidren(loginBtn);
|
|
//错误提示Btn
|
var loginErrorBtn = new Button()
|
{
|
Y = loginBtn.Bottom + Application.GetRealHeight(50),
|
Width = Application.GetRealWidth(1080 - 100),
|
Height = Application.GetRealHeight(110),
|
TextColor = ZigbeeColor.Current.GXCRedColor,
|
Gravity = Gravity.CenterHorizontal
|
};
|
midFrameLayout.AddChidren(loginErrorBtn);
|
|
var LoginByAccountPWDBtn = new Button()
|
{
|
Width = Application.GetRealWidth(500),
|
Height = Application.GetRealHeight(110),
|
Y = midFrameLayout.Bottom - Application.GetRealHeight(100 + 110),
|
TextID = R.MyInternationalizationString.LoginByAccountPWD,
|
TextColor = ZigbeeColor.Current.GXCTextBlueColor,
|
TextAlignment = TextAlignment.Center,
|
Gravity = Gravity.CenterHorizontal,
|
TextSize = 15
|
};
|
midFrameLayout.AddChidren(LoginByAccountPWDBtn);
|
#endregion
|
|
#region event
|
accountET.TextChangeEventHandler += (sender, e) =>
|
{
|
loginErrorBtn.Text = "";
|
//校验手机号
|
if (CommonPage.PhoneZoneStr != "86")
|
{
|
var reg = new Regex(CommonPage.PhoneForForeignRegexStr);
|
var mFalg = reg.Match(accountET.Text.Trim());
|
if (!mFalg.Success)
|
{
|
var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim));
|
aler.Show();
|
sendCodeBtn.Enable =sendCodeBtn.IsSelected= false;
|
IsRightAccount = false;
|
}
|
else
|
{
|
sendCodeBtn.Enable = sendCodeBtn.IsSelected= true;
|
IsRightAccount = true;
|
}
|
}
|
else
|
{
|
if (accountET.Text.Trim().Length == 11)
|
{
|
var reg = new Regex(CommonPage.PhoneRegexStr);
|
var mFalg = reg.Match(accountET.Text.Trim());
|
if (!mFalg.Success)
|
{
|
sendCodeBtn.Enable =sendCodeBtn.IsSelected= false;
|
IsRightAccount = false;
|
var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.OK));
|
aler.Show();
|
}
|
else
|
{
|
sendCodeBtn.Enable = sendCodeBtn.IsSelected= true;
|
IsRightAccount = true;
|
}
|
}
|
else if (accountET.Text.Trim().Length > 11)
|
{
|
accountET.Text = e.Remove(11);
|
}
|
else
|
{
|
sendCodeBtn.Enable = sendCodeBtn.IsSelected = false;
|
IsRightAccount = false;
|
//正则表达式判断是否数字
|
var reg = new Regex("^[0-9]*$");
|
if (!reg.IsMatch(accountET.Text))
|
{
|
var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim));
|
aler.Show();
|
accountET.Text = "";
|
}
|
|
}
|
}
|
};
|
verificationCodeET.TextChangeEventHandler += (sender, e) =>
|
{
|
loginErrorBtn.Text = "";
|
if (verificationCodeET.Text.Trim().Length > 0 && IsRightAccount)
|
{
|
loginBtn.IsSelected = loginBtn.Enable = true;
|
}
|
else
|
{
|
loginBtn.IsSelected = loginBtn.Enable = false;
|
}
|
};
|
sendCodeBtn.MouseUpEventHandler += async (sender, e) =>
|
{
|
string phoneNum = accountET.Text.Trim();
|
CommonPage.Loading.Start();
|
try
|
{
|
int companyInt = 0;
|
if (CommonPage.PhoneZoneStr == "86")
|
{
|
companyInt = CommonPage.Company;
|
phoneStr = phoneNum;
|
}
|
else
|
{
|
companyInt = CommonPage.CompanyForINTERNETION;
|
phoneStr = phoneNum;
|
}
|
var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj()
|
{
|
Account = phoneStr,
|
Company = companyInt,
|
AreaCode = int.Parse(CommonPage.PhoneZoneStr),
|
Language = CommonPage.ZigBeeLanguage
|
};
|
var requesetJson = Newtonsoft.Json.JsonConvert.SerializeObject(reqDtoSignPhone);
|
var requestRevertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/LoginSendVerCode", System.Text.Encoding.UTF8.GetBytes(requesetJson));
|
if (requestRevertObj == null)
|
{
|
CommonPage.Instance.FailureToServer();
|
return;
|
}
|
var stateCodeStr = requestRevertObj.StateCode.ToUpper();
|
if (stateCodeStr == "SUCCESS")
|
{
|
TimeBegin();
|
var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SendVerificationCodeSuccess), Language.StringByID(R.MyInternationalizationString.Confrim));
|
alert.Show();
|
}
|
else if (stateCodeStr == "PARAMETEROREMPTY")
|
{
|
//提供的参数错误
|
loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.PARAMETEROREMPTY);
|
}
|
else if (stateCodeStr == "ACCOUNTNOEXISTS")
|
{
|
//账号不存在
|
loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
|
accountET.Text = "";
|
IsRightAccount = false;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ACCOUNTNOEXISTS);
|
}
|
else if (stateCodeStr == "SENDFAIL")
|
{
|
//验证码发送失败
|
loginErrorBtn.TextID = R.MyInternationalizationString.SENDFAIL;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.SENDFAIL);
|
}
|
else
|
{
|
loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed);
|
}
|
}
|
catch
|
{
|
loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
|
}
|
finally
|
{
|
CommonPage.Loading.Hide();
|
}
|
};
|
|
loginBtn.MouseDownEventHandler += (sender, e) =>
|
{
|
loginBtn.IsSelected = true;
|
};
|
//login
|
loginBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
loginByCode();
|
};
|
void loginByCode()
|
{
|
Action action = async () =>
|
{
|
CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
|
try
|
{
|
var reqLoginByCode = new SendDataToServer.LoginValidCodeOBJ()
|
{
|
Account = accountET.Text.Trim(),
|
Code = verificationCodeET.Text.Trim(),
|
Language = CommonPage.ZigBeeLanguage,
|
AreaCode = int.Parse(CommonPage.PhoneZoneStr)
|
};
|
var requesLoginCodeJson = Newtonsoft.Json.JsonConvert.SerializeObject(reqLoginByCode);
|
|
var requestRevetLoginCodeOBJ = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/LoginValidCode", System.Text.Encoding.UTF8.GetBytes(requesLoginCodeJson));
|
if (requestRevetLoginCodeOBJ == null)
|
{
|
CommonPage.Instance.FailureToServer();
|
return;
|
}
|
var stateCodeStr = requestRevetLoginCodeOBJ.StateCode.ToUpper();
|
if (stateCodeStr == "SUCCESS")
|
{
|
if (requestRevetLoginCodeOBJ.ResponseData == null)
|
{
|
return;
|
}
|
this.RemoveFromParent();
|
Application.MainPage?.RemoveViewByTag("Login");
|
|
UserPage.Instance.Fresh();
|
|
new System.Threading.Thread(async () =>
|
{
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
|
var revertData = responseDataObj;
|
Config.ReFresh();
|
Config.Instance.UserID = revertData.UserID;
|
Config.Instance.MasterID = revertData.MainUserID;
|
Config.Instance.AccountType = revertData.UserType;
|
Config.Instance.Account = revertData.Account;
|
Config.Instance.MqttKey = revertData.MqttKey;
|
Config.Instance.Guid = revertData.Guid;
|
Config.Instance.LoginDateTime = DateTime.Now;
|
Config.Instance.ConnectZigbeeMqttBrokerPwd = revertData.ConnectZigbeeMqttBrokerPwd;
|
Config.Instance.ConnectZigbeeMqttClientId = revertData.ConnectZigbeeMqttClientId;
|
Config.Instance.ZigbeeMqttBrokerLoadSubDomain = revertData.ZigbeeMqttBrokerLoadSubDomain;
|
if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
|
{
|
Config.Instance.AccountList.Add(revertData.Account);
|
}
|
//需要把登录后返回的md5密码 赋值生成Token 因为用户没有输入密码
|
Config.Instance.MD5PWD = revertData.MD5PWD;
|
Config.Instance.Save();
|
var resultRegID = await CommonPage.Instance.PushRegID();
|
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 if (stateCodeStr == "NOTVERIFY")
|
{
|
CommonPage.Loading.Hide();
|
//未激活
|
loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTVERIFY);
|
}
|
else if (stateCodeStr == "NOTENABLE")
|
{
|
CommonPage.Loading.Hide();
|
//该用户属于调试账号,并未启用
|
loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTENABLE);
|
}
|
else if (stateCodeStr == "PARAMETEROREMPTY")
|
{
|
CommonPage.Loading.Hide();
|
//提供的参数错误
|
loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.PARAMETEROREMPTY);
|
}
|
else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL")
|
{
|
CommonPage.Loading.Hide();
|
//验证码错误
|
loginErrorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL);
|
}
|
else if (stateCodeStr == "YOUDATANOISLOCALREGION")
|
{
|
CommonPage.Loading.Hide();
|
//不在本区域,需要重定向区域后再次请求登录
|
if (requestRevetLoginCodeOBJ.ResponseData == null)
|
{
|
return;
|
}
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
|
CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
|
//再次登录
|
loginByCode();
|
}
|
else
|
{
|
CommonPage.Loading.Hide();
|
loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed);
|
}
|
}
|
catch
|
{
|
CommonPage.Loading.Hide();
|
CommonPage.Instance.FailureToServer();
|
}
|
finally
|
{
|
//CommonPage.Loading.Hide();
|
}
|
};
|
action();
|
}
|
|
//注册事件
|
registerBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
this.RemoveFromParent();
|
var registerPage = new RegistrationPhoneOREmail();
|
Shared.Common.CommonPage.Instance.AddChidren(registerPage);
|
registerPage.Show();
|
};
|
//账号密码登录
|
LoginByAccountPWDBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
this.RemoveFromParent();
|
var login = new AccountLogin();
|
Shared.Common.CommonPage.Instance.AddChidren(login);
|
login.Show();
|
};
|
|
void TimeBegin()
|
{
|
t.Interval = 1000;
|
t.AutoReset = true;
|
t.Enabled = true;
|
t.Elapsed += TimeOut;
|
//启动计时器倒计时-60s
|
t.Start();
|
dateBegin = DateTime.Now;
|
}
|
|
void TimeOut(object source, System.Timers.ElapsedEventArgs e)
|
{
|
var span = DateTime.Now - dateBegin;
|
if (span.TotalSeconds <= 61)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
sendCodeBtn.Text = Convert.ToInt16((60 - span.TotalSeconds)) + "s" + Language.StringByID(R.MyInternationalizationString.SendVerificationCode);
|
sendCodeBtn.Enable = false;
|
});
|
}
|
else
|
{
|
Application.RunOnMainThread(() =>
|
{
|
sendCodeBtn.Enable = true;
|
sendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode;
|
t.Stop();
|
t.Close();
|
});
|
}
|
}
|
|
Button tempClickZoneImgBtn = new Button();
|
Button tempClickZoneNameBtn = new Button();
|
EventHandler<MouseEventArgs> phoneZoneHandler = (senderZone, eZone) =>
|
{
|
//ZoneListView
|
var phoneZoneSelectedShowView = new Dialog()
|
{
|
Height = Application.GetRealHeight(1000),
|
Width = Application.GetRealWidth(700),
|
BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
Radius=(uint)Application.GetRealHeight(30)
|
};
|
phoneZoneSelectedShowView.Show();
|
|
var phoneZoneTitle = new Button()
|
{
|
Height = Application.GetRealHeight(110),
|
TextID = R.MyInternationalizationString.PleaseSelectAreaCode,
|
TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
|
TextSize = 15,
|
BackgroundColor=ZigbeeColor.Current.GXCButtonBlueColor
|
};
|
phoneZoneSelectedShowView.AddChidren(phoneZoneTitle);
|
|
var phoneZoneSelectedListView = new VerticalScrolViewLayout()
|
{
|
Y = phoneZoneTitle.Bottom,
|
Height = Application.GetRealHeight(1000-110*2),
|
BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
|
};
|
phoneZoneSelectedShowView.AddChidren(phoneZoneSelectedListView);
|
|
for (int i = 0; i < areaCodeList.Count; i++)
|
{
|
var zoneItemLName = areaCodeList[i].Name;
|
var zoneItemLCode = areaCodeList[i].Code;
|
var zoneItemFL = new FrameLayout()
|
{
|
Width = phoneZoneSelectedListView.Width,
|
Height = Application.GetRealHeight(110),
|
Tag = i + 10086
|
};
|
phoneZoneSelectedListView.AddChidren(zoneItemFL);
|
|
var zoneIsSelectedBtn = new Button()
|
{
|
Width = Application.GetMinReal(80),
|
Height = Application.GetMinReal(80),
|
UnSelectedImagePath = "Account/Check.png",
|
SelectedImagePath = "Account/CheckSelected.png",
|
Tag = i + 10086,
|
Gravity=Gravity.CenterVertical
|
};
|
zoneItemFL.AddChidren(zoneIsSelectedBtn);
|
|
var zoneItemNameBtn = new Button()
|
{
|
X = Application.GetRealWidth(20)+zoneIsSelectedBtn.Right,
|
Width = zoneItemFL.Width - Application.GetRealWidth(100),
|
Height = Application.GetRealHeight(110)-1,
|
Text = zoneItemLName,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
Tag = i + 10000
|
};
|
zoneItemFL.AddChidren(zoneItemNameBtn);
|
|
var zoneLine = new Button()
|
{
|
Y = zoneItemFL.Height - 1,
|
Width = zoneItemFL.Width,
|
Height = 1,
|
BackgroundColor = ZigbeeColor.Current.GXCPlaceHolderTextColor
|
};
|
zoneItemFL.AddChidren(zoneLine);
|
|
EventHandler<MouseEventArgs> selectedZone = (sender, e) =>
|
{
|
tempClickZoneImgBtn.IsSelected = false;
|
tempClickZoneNameBtn.IsSelected = false;
|
zoneItemNameBtn.IsSelected = true;
|
zoneIsSelectedBtn.IsSelected = true;
|
tempClickZoneImgBtn = zoneIsSelectedBtn;
|
tempClickZoneNameBtn = zoneItemNameBtn;
|
CommonPage.PhoneZoneStr = zoneItemLCode;
|
};
|
zoneIsSelectedBtn.MouseUpEventHandler += selectedZone;
|
zoneItemNameBtn.MouseUpEventHandler += selectedZone;
|
//默认
|
if(zoneItemLCode==CommonPage.PhoneZoneStr)
|
{
|
zoneItemNameBtn.IsSelected = true;
|
zoneIsSelectedBtn.IsSelected = true;
|
tempClickZoneImgBtn = zoneIsSelectedBtn;
|
tempClickZoneNameBtn = zoneItemNameBtn;
|
}
|
}
|
var cancleBtn = new Button()
|
{
|
Y = phoneZoneSelectedListView.Bottom,
|
Height = Application.GetRealHeight(110),
|
Width = Application.GetRealWidth(700 / 2),
|
BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
TextID = R.MyInternationalizationString.Cancel,
|
TextSize = 15
|
};
|
phoneZoneSelectedShowView.AddChidren(cancleBtn);
|
cancleBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
phoneZoneSelectedShowView.Close();
|
};
|
cancleBtn.MouseDownEventHandler += (sender, e) =>
|
{
|
cancleBtn.IsSelected = true;
|
};
|
|
var lineCancleOK = new Button()
|
{
|
X = cancleBtn.Right,
|
Y = phoneZoneSelectedListView.Bottom,
|
Height = Application.GetRealHeight(110),
|
Width = 1,
|
BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
|
};
|
phoneZoneSelectedShowView.AddChidren(lineCancleOK);
|
|
var okBtn = new Button()
|
{
|
X = lineCancleOK.Right+1,
|
Y = phoneZoneSelectedListView.Bottom,
|
Height = Application.GetRealHeight(110),
|
Width = Application.GetRealWidth(700 / 2)-1,
|
BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
TextID = R.MyInternationalizationString.Confrim,
|
TextSize = 15
|
};
|
phoneZoneSelectedShowView.AddChidren(okBtn);
|
okBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
accountZoneBtn.Text = "+" + CommonPage.PhoneZoneStr;
|
phoneZoneSelectedShowView.Close();
|
};
|
okBtn.MouseDownEventHandler += (sender, e) =>
|
{
|
okBtn.IsSelected = true;
|
};
|
};
|
accountZoneBtn.MouseUpEventHandler += phoneZoneHandler;
|
#endregion
|
}
|
}
|
}
|