using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class AccountView : FrameLayout
|
{
|
public AccountView ()
|
{
|
}
|
|
public void ShouwAccountView ()
|
{
|
#region 标题
|
var topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (topView);
|
|
Button NameButton = new Button () {
|
Width = Application.GetRealWidth (400),
|
TextID = R.MyInternationalizationString.Account,
|
TextColor = SkinStyle.Current.TextColor1,
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 20,
|
};
|
topView.AddChidren (NameButton);
|
|
var logo = new Button () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (logo);
|
var back = new Button () {
|
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;
|
};
|
#endregion
|
|
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/UserIcon.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;
|
}
|
|
Button btTopNull = new Button () {
|
Y = topUserMsgView.Bottom,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Height = Application.GetRealHeight (50),
|
};
|
AddChidren (btTopNull);
|
|
var contentView = new VerticalScrolViewLayout () {
|
Y = btTopNull.Bottom,
|
Height = Application.GetRealHeight (Application.DesignHeight - UserMiddle.userMenuItemHeight) - btTopNull.Bottom,
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
//ScrollEnabled = false,
|
};
|
AddChidren (contentView);
|
|
btnUserIcon.MouseUpEventHandler += (sender, e) => {
|
var userConfigBytes = IO.FileUtils.ReadFile ("AccountListDB");
|
var userConfigString = CommonPage.MyEncodingUTF8.GetString (userConfigBytes);
|
AccountListDB accountListDB = null;
|
if (userConfigString != null) {
|
accountListDB = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountListDB> (userConfigString);
|
}
|
if (accountListDB == null) {
|
accountListDB = new AccountListDB ();
|
}
|
|
|
Dialog dialog = new Dialog ();
|
|
var dialogView = new FrameLayout ();
|
dialog.AddChidren (dialogView);
|
|
var bodyView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (600),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
};
|
dialogView.AddChidren (bodyView);
|
|
#region scrollView 账号列表
|
var scrollView = new VerticalScrolViewLayout () {
|
Height = Application.GetRealHeight (500),
|
};
|
bodyView.AddChidren (scrollView);
|
|
foreach (var accountItem in accountListDB.AccountInfo) {
|
var rowView = new RowLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
scrollView.AddChidren (rowView);
|
|
var rowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor
|
};
|
scrollView.AddChidren (rowLine);
|
|
var btnAccountItem = new Button () {
|
X = Application.GetRealWidth (80),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = accountItem.Key,
|
TextColor = SkinStyle.Current.TextColor1,
|
IsMoreLines = true
|
};
|
rowView.AddChidren (btnAccountItem);
|
|
btnAccountItem.MouseUpEventHandler += (sed, ffe) => {
|
if (MainPage.LoginUser.AccountString == accountItem.Key) {
|
return;
|
}
|
string account = accountItem.Key;
|
string password = "";
|
AccountInfo db_AccountInfo = new AccountInfo ();
|
bool getLocalAccountPassword = accountListDB.AccountInfo.TryGetValue (accountItem.Key, out db_AccountInfo);
|
if (getLocalAccountPassword) {
|
password = db_AccountInfo.Password;
|
} else {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.NetworkAbnormal), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
accountListDB.AccountInfo.Remove (account);
|
LogIn (accountListDB, account);
|
}
|
MainPage.Loading.Start ("");
|
new System.Threading.Thread (() => {
|
try {
|
#region 存储当前账号的数据
|
try {
|
var backuplist = IO.FileUtils.ReadFiles ();
|
int index = 0;
|
string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.RegionID.ToString ());
|
IO.FileUtils.DeleteRegionFiles (oldRegionRootPath);
|
foreach (var fileName in backuplist) {
|
if (fileName == "linphonerc" || fileName == "AccountListDB")
|
continue;
|
System.IO.FileInfo fileInfo = new System.IO.FileInfo (IO.FileUtils.RootPath + fileName);
|
if (fileInfo == null)
|
continue;
|
if (fileInfo.Exists) {
|
fileInfo.MoveTo (oldRegionRootPath + fileName);
|
Console.WriteLine ("move file : " + fileName);
|
}
|
index++;
|
Application.RunOnMainThread (() => {
|
int pro = (int)(index * 1.0 / backuplist.Count * 50);
|
MainPage.Loading.Text = pro.ToString () + "%";
|
});
|
}
|
IO.FileUtils.DeleteAllFile ();
|
SmartHome.MqttCommon.DisConnectRemoteMqttClient ();
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
}
|
#endregion
|
|
new System.Threading.Thread (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
if (Language.CurrentLanguage == "Chinese") {
|
MainPage.Loading.Start ("登录中...");
|
} else {
|
MainPage.Loading.Start ("Login...");
|
}
|
});
|
if (UserConfig.Instance.internetStatus == 0 || !MainPage.checeInternet ()) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.NetworkAbnormal), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
return;
|
}
|
|
var revertConnectionObj = MainPage.RequestHttps ("Connection", "");
|
if (revertConnectionObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.LinkServerSuccessful));
|
});
|
|
var requestObj = new LoginObj () { Account = account, Password = password, Company = MainPage.SoftSmsType };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("Login", requestJson, false);
|
if (revertObj.StateCode == "SUCCESS") {
|
if (!accountListDB.account.Contains (account)) {
|
accountListDB.account.Add (account);
|
accountListDB.SaveAccountListDB ();
|
}
|
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes> (revertObj.ResponseData.ToString ());
|
var revertData = responseDataObj;
|
MainPage.LoginUser = new UserInfo {
|
ID = revertData.UserId, MasterID = revertData.MainUserId, AccountType = revertData.UserType, AccountString = account, Password = password, LastTime = DateTime.Now,
|
AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid,
|
};
|
string DeviceType = "android";
|
#if __IOS__
|
DeviceType = "iphone";
|
#endif
|
var mAddRegIDObj = new AddRegIDObj () {
|
RegID = UserConfig.Instance.tokenID,
|
Alias = UserConfig.Instance.phoneName,
|
Account = account,
|
UserMode = 2,
|
};
|
var mAddRegIDObjJson = Newtonsoft.Json.JsonConvert.SerializeObject (mAddRegIDObj);
|
MainPage.RequestHttps (@"AddRegID", mAddRegIDObjJson, true, false);
|
|
//string jsonString = "{" +
|
// "\"RegID\":" + "\"" + UserConfig.Instance.tokenID + "\"" + "," +
|
// "\"Alias\":" + "\"" + UserConfig.Instance.phoneName + "\"" + "," +
|
// "\"Account\":" + "\"" + account + "\"" +
|
// "}";
|
//MainPage.RequestHttps (@"AddRegID", jsonString, true);
|
#if wallon
|
#else
|
if (!string.IsNullOrEmpty (MainPage.LoginUser.AllVisionRegisterDevUserNameGuid)) {
|
//可视对讲
|
Application.RunOnMainThread (() => {
|
#if Android
|
(Application.Activity as BaseActivity).ReadWriteContact ((b) => {
|
if (b) {
|
com.freeview.global.Video.Init (MainPage.LoginUser.LoginTokenString, MainPage.LoginUser.AllVisionRegisterDevUserNameGuid);
|
}
|
});
|
#else
|
com.freeview.global.Video.Init (MainPage.LoginUser.LoginTokenString, MainPage.LoginUser.AllVisionRegisterDevUserNameGuid);
|
#endif
|
});
|
UserConfig.Instance.HideDeviceTypes.Distinct ().ToList ();
|
UserConfig.Instance.DeviceTypes.Distinct ().ToList ();
|
if (UserConfig.Instance.HideDeviceTypes.Contains (R.MyInternationalizationString.VideoIntercom))
|
UserConfig.Instance.HideDeviceTypes.Remove (R.MyInternationalizationString.VideoIntercom);
|
} else {
|
if (!UserConfig.Instance.HideDeviceTypes.Contains (R.MyInternationalizationString.VideoIntercom))
|
UserConfig.Instance.HideDeviceTypes.Add (R.MyInternationalizationString.VideoIntercom);
|
}
|
#endif
|
var requestObj2 = new HomeListObj ();
|
var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
|
var revertObj2 = MainPage.RequestHttps ("HomeList", requestJson2);
|
if (revertObj2.StateCode == "SUCCESS") {
|
UserConfig.Instance.HomeLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertObj2.ResponseData.ToString ());
|
MainPage.LoginUser.LastTime = DateTime.Now;
|
|
if (UserConfig.Instance.HomeLists.Count > 0) {
|
UserConfig.Instance.CurrentRegion = UserConfig.Instance.HomeLists [0];
|
foreach (var home in UserConfig.Instance.HomeLists) {
|
var sssd = IO.FileUtils.ExistRegion (home.RegionID.ToString ());
|
Console.WriteLine ("IO.FileUtils.ExistRegion (home.RegionID.ToString()); " + sssd.ToString ());
|
|
if (sssd) {
|
string newRegionRootPath = IO.FileUtils.CreateRegionBackup (home.RegionID.ToString ());
|
IO.FileUtils.RestoreRegionFiles (newRegionRootPath);
|
UserConfig.Instance.RefreshUserConfig ();
|
UserConfig.Instance.CurrentRegion = home;
|
break;
|
}
|
}
|
} else {
|
//创建默认住宅
|
var requestObj21 = new AddHomeAndGatewayByONObj () { Region = "Home", MAC = "" };
|
var requestJson21 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj21);
|
var revertObj21 = MainPage.RequestHttps ("AddHomeAndGatewayByON", requestJson21);
|
if (revertObj21.StateCode == "SUCCESS") {
|
revertObj2 = MainPage.RequestHttps ("HomeList", requestJson2);
|
if (revertObj2.StateCode == "SUCCESS") {
|
UserConfig.Instance.HomeLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertObj2.ResponseData.ToString ());
|
UserConfig.Instance.CurrentRegion = UserConfig.Instance.HomeLists [0];
|
}
|
}
|
}
|
accountListDB.AccountInfo.TryAdd (account.ToLower(), new AccountInfo () { Password = password, UserInfo = MainPage.LoginUser, RegionList = UserConfig.Instance.HomeLists });
|
accountListDB.SaveAccountListDB ();
|
|
|
UserConfig.Instance.SaveUserConfig ();
|
MainPage.LoginUser.SaveUserInfo ();
|
Room.InitAllRoom ();
|
Application.RunOnMainThread (() => {
|
UserMiddle.LinkStatusTip.BackgroundColor = SkinStyle.Current.LinkStatusTipColor;
|
UserMiddle.Init ();
|
EquipmentPublicClass.CheckLinkRemote (2);
|
});
|
}
|
}
|
}
|
} catch (Exception ex) {
|
MainPage.FailureToServer ();
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
}) { IsBackground = true }.Start ();
|
return;
|
} catch (Exception ex) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
dialog.Close ();
|
});
|
}
|
}) { IsBackground = true }.Start ();
|
};
|
|
var btnCurAccountFlag = new Button () {
|
X = Application.GetRealWidth (20),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (61),
|
SelectedImagePath = "Skin/Check.png",
|
UnSelectedImagePath = "Item/Transparent.png",
|
IsSelected = MainPage.LoginUser.AccountString == accountItem.Key ? true : false
|
};
|
rowView.AddChidren (btnCurAccountFlag);
|
|
if (MainPage.LoginUser.AccountString == accountItem.Key) { } else {
|
var btnDel = new Button () {
|
BackgroundColor = SkinStyle.Current.DelColor,
|
TextID = R.MyInternationalizationString.del,
|
};
|
rowView.AddRightView (btnDel);
|
btnDel.MouseUpEventHandler += (ddf, ffd) => {
|
try {
|
accountListDB.AccountInfo.Remove (accountItem.Key);
|
accountListDB.SaveAccountListDB ();
|
rowView.RemoveFromParent ();
|
} catch { }
|
};
|
}
|
}
|
#endregion
|
|
var bottomView = new FrameLayout () {
|
Y = scrollView.Bottom,
|
Height = Application.GetRealHeight (100),
|
};
|
bodyView.AddChidren (bottomView);
|
|
var btnClose = new Button () {
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
TextID = R.MyInternationalizationString.Close,
|
TextColor = SkinStyle.Current.TextColor,
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (250),
|
};
|
bottomView.AddChidren (btnClose);
|
btnClose.MouseUpEventHandler += (c, d) => {
|
dialog.Close ();
|
};
|
|
var btnAddAccount = new Button () {
|
X = btnClose.Right + 1,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
TextID = R.MyInternationalizationString.Add,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor,
|
Width = Application.GetRealWidth (250),
|
};
|
bottomView.AddChidren (btnAddAccount);
|
|
btnAddAccount.MouseUpEventHandler += (cc, dd) => {
|
dialog.Close ();
|
LogIn (accountListDB);
|
};
|
dialog.Show ();
|
};
|
|
if (MainPage.LoginUser.AccountType == 0) {
|
FrameLayout SubaccountView = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
contentView.AddChidren (SubaccountView);
|
|
Button btnSubaccountTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
TextID = R.MyInternationalizationString.Subaccount,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
SubaccountView.AddChidren (btnSubaccountTitle);
|
|
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",
|
};
|
SubaccountView.AddChidren (rightButton);
|
|
EventHandler<MouseEventArgs> eHandler = (sender, e) => {
|
MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load));
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
var requestObj = new GetSubAccountListObj ();
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("GetSubAccountList", requestJson);
|
if (revertObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SubAccountRes>> (revertObj.ResponseData.ToString ());
|
SubaccountListView subView = new SubaccountListView (responseDataObj);
|
UserMiddle.SettingPageView.AddChidren (subView);
|
subView.ShowSubaccountListView ();
|
UserMiddle.SettingPageView.PageIndex += 1;
|
});
|
}
|
} catch (Exception ex) {
|
MainPage.FailureToServer ();
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
SubaccountView.MouseUpEventHandler += eHandler;
|
rightButton.MouseUpEventHandler += eHandler;
|
btnSubaccountTitle.MouseUpEventHandler += eHandler;
|
|
Button btnLineNull = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
contentView.AddChidren (btnLineNull);
|
}
|
#region PasswordView
|
FrameLayout ModifyPasswordView = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
contentView.AddChidren (ModifyPasswordView);
|
|
Button btnModifyPasswordTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
TextID = R.MyInternationalizationString.ModifyPasswrod,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
ModifyPasswordView.AddChidren (btnModifyPasswordTitle);
|
|
Button btnModifyPasswordRight = 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",
|
};
|
ModifyPasswordView.AddChidren (btnModifyPasswordRight);
|
|
EventHandler<MouseEventArgs> modifyPasswordHandler = (sender, e) => {
|
AccountModifyPassword am = new AccountModifyPassword ();
|
UserMiddle.SettingPageView.AddChidren (am);
|
am.ShowAccountModifyPassword ();
|
UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1;
|
};
|
ModifyPasswordView.MouseUpEventHandler += modifyPasswordHandler;
|
btnModifyPasswordTitle.MouseUpEventHandler += modifyPasswordHandler;
|
btnModifyPasswordRight.MouseUpEventHandler += modifyPasswordHandler;
|
|
Button btnModifyNullLine = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
contentView.AddChidren (btnModifyNullLine);
|
#endregion
|
|
#region ClearData
|
FrameLayout ClearDataView = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
contentView.AddChidren (ClearDataView);
|
|
Button btnClearDataTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
TextID = R.MyInternationalizationString.ClearData,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
ClearDataView.AddChidren (btnClearDataTitle);
|
|
Button btnClearDataRight = 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",
|
};
|
ClearDataView.AddChidren (btnClearDataRight);
|
|
EventHandler<MouseEventArgs> ClearDataHandler = (sender, e) => {
|
var alertDialog = new Dialog ();
|
|
var alertBodyView = new FrameLayout ();
|
alertDialog.AddChidren (alertBodyView);
|
alertBodyView.MouseUpEventHandler += (d, f) => {
|
alertDialog.Close ();
|
};
|
|
var tipView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (250),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
};
|
alertBodyView.AddChidren (tipView);
|
|
var btnTipMsg = new TextView () {
|
X = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (130),
|
Width = Application.GetRealWidth (460),
|
IsMoreLines = true,
|
TextColor = SkinStyle.Current.TextColor2,
|
TextID = R.MyInternationalizationString.ClearAllDate,
|
TextSize = 16
|
};
|
tipView.AddChidren (btnTipMsg);
|
|
var bottomView = new FrameLayout () {
|
Y = btnTipMsg.Bottom,
|
Height = Application.GetRealHeight (123),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
tipView.AddChidren (bottomView);
|
|
var btnYes = new Button () {
|
X = Application.GetRealWidth (40),
|
Y = Application.GetRealHeight (20),
|
Height = Application.GetRealHeight (70),
|
Width = Application.GetRealWidth (200),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Yes,
|
TextAlignment = TextAlignment.Center,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
};
|
bottomView.AddChidren (btnYes);
|
|
|
var btnNo = new Button () {
|
X = btnYes.Right + Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (20),
|
Height = Application.GetRealHeight (70),
|
Width = Application.GetRealWidth (200),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.No,
|
TextAlignment = TextAlignment.Center,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
};
|
bottomView.AddChidren (btnNo);
|
|
btnYes.MouseUpEventHandler += (sdd, ff) => {
|
alertDialog.Close ();
|
IO.FileUtils.DeleteAllFile ();
|
foreach (var tempHome in UserConfig.Instance.HomeLists) {
|
IO.FileUtils.DeleteRegionFiles (IO.FileUtils.CreateRegionBackup (tempHome.RegionID.ToString ()));
|
}
|
MainPage.LoginUser.LastTime = DateTime.Now;
|
MainPage.LoginUser.SaveUserInfo ();
|
UserConfig.Instance.SaveUserConfig ();
|
Room.Lists.Clear ();
|
|
UserMiddle.LinkStatusTip.BackgroundColor = SkinStyle.Current.LinkStatusTipColor;
|
};
|
|
btnNo.MouseUpEventHandler += (sdd, ff) => {
|
alertDialog.Close ();
|
};
|
|
alertDialog.Show ();
|
};
|
ClearDataView.MouseUpEventHandler += ClearDataHandler;
|
btnClearDataTitle.MouseUpEventHandler += ClearDataHandler;
|
btnClearDataRight.MouseUpEventHandler += ClearDataHandler;
|
Button btnClearData = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
contentView.AddChidren (btnClearData);
|
#endregion
|
|
#region 语言选择
|
FrameLayout SetLanguageView = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
contentView.AddChidren (SetLanguageView);
|
|
Button btnSetLanguageTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
TextID = R.MyInternationalizationString.LanguageSettings,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
SetLanguageView.AddChidren (btnSetLanguageTitle);
|
|
Button btnSetLanguageRight = 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",
|
};
|
SetLanguageView.AddChidren (btnSetLanguageRight);
|
|
EventHandler<MouseEventArgs> SetLanguageHandler = (sender, e) => {
|
Dialog dialogSetLanguage = new Dialog ();
|
string setLanguage = UserConfig.Instance.SetLanguage;
|
|
FrameLayout dialogSetLanguageView = new FrameLayout () {
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (270 + 180 + 70),
|
Gravity = Gravity.Center,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
};
|
dialogSetLanguage.AddChidren (dialogSetLanguageView);
|
|
Button setLanguageTitle = new Button () {
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextID = R.MyInternationalizationString.LanguageSettings,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
TextAlignment = TextAlignment.Center,
|
};
|
dialogSetLanguageView.AddChidren (setLanguageTitle);
|
|
VerticalScrolViewLayout setLanguageScrolView = new VerticalScrolViewLayout () {
|
Y = setLanguageTitle.Bottom,
|
Height = Application.GetRealHeight (330),
|
ScrollEnabled = false,
|
};
|
dialogSetLanguageView.AddChidren (setLanguageScrolView);
|
|
#region 简体中文
|
RowLayout rowChinese = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
setLanguageScrolView.AddChidren (rowChinese);
|
|
Button btnPoint = new Button () {
|
X = Application.GetMinRealAverage (30),
|
Width = Application.GetMinRealAverage (10),
|
Height = Application.GetMinRealAverage (10),
|
Radius = (uint)Application.GetMinRealAverage (5),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.CenterVertical,
|
};
|
rowChinese.AddChidren (btnPoint);
|
|
Button btnChineseName = new Button () {
|
X = btnPoint.Right + Application.GetRealWidth (20),
|
Width = Application.GetRealWidth (350),
|
TextColor = SkinStyle.Current.TextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.SimplifiedChinese
|
};
|
rowChinese.AddChidren (btnChineseName);
|
|
Button btnCheckChinese = new Button () {
|
X = btnChineseName.Right + Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (15),
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (61),
|
SelectedImagePath = "Skin/Check.png",
|
UnSelectedImagePath = "Item/Transparent.png",
|
IsSelected = setLanguage == "Chinese" ? true : false
|
};
|
rowChinese.AddChidren (btnCheckChinese);
|
|
|
#endregion
|
|
#region 英文
|
RowLayout rowEnglish = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
setLanguageScrolView.AddChidren (rowEnglish);
|
|
Button btnPointEnglish = new Button () {
|
X = Application.GetMinRealAverage (30),
|
Width = Application.GetMinRealAverage (10),
|
Height = Application.GetMinRealAverage (10),
|
Radius = (uint)Application.GetMinRealAverage (5),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
Gravity = Gravity.CenterVertical,
|
BorderWidth = 0,
|
};
|
rowEnglish.AddChidren (btnPointEnglish);
|
|
Button btnEnglish = new Button () {
|
X = btnPointEnglish.Right + Application.GetRealWidth (20),
|
Width = Application.GetRealWidth (350),
|
TextColor = SkinStyle.Current.TextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.English
|
};
|
rowEnglish.AddChidren (btnEnglish);
|
|
Button btnCheckEnglish = new Button () {
|
X = btnEnglish.Right + Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (15),
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (61),
|
SelectedImagePath = "Skin/Check.png",
|
UnSelectedImagePath = "Item/Transparent.png",
|
IsSelected = setLanguage == "English" ? true : false
|
};
|
rowEnglish.AddChidren (btnCheckEnglish);
|
|
#endregion
|
|
#region 捷克语
|
RowLayout rowCzech = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
setLanguageScrolView.AddChidren (rowCzech);
|
|
Button btnPointCzech = new Button () {
|
X = Application.GetMinRealAverage (30),
|
Width = Application.GetMinRealAverage (10),
|
Height = Application.GetMinRealAverage (10),
|
Radius = (uint)Application.GetMinRealAverage (5),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
Gravity = Gravity.CenterVertical,
|
BorderWidth = 0,
|
};
|
rowCzech.AddChidren (btnPointCzech);
|
|
Button btnCzech = new Button () {
|
X = btnPointCzech.Right + Application.GetRealWidth (20),
|
Width = Application.GetRealWidth (350),
|
TextColor = SkinStyle.Current.TextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.Czech
|
};
|
rowCzech.AddChidren (btnCzech);
|
|
Button btnCheckCzech = new Button () {
|
X = btnCzech.Right + Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (15),
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (61),
|
SelectedImagePath = "Skin/Check.png",
|
UnSelectedImagePath = "Item/Transparent.png",
|
IsSelected = setLanguage == "Czech" ? true : false
|
};
|
rowCzech.AddChidren (btnCheckCzech);
|
#endregion
|
|
EventHandler<MouseEventArgs> ChangeChineseEventHandler = (sender2, e2) => {
|
setLanguage = "Chinese";
|
btnCheckChinese.IsSelected = true;
|
btnCheckCzech.IsSelected = false;
|
btnCheckEnglish.IsSelected = false;
|
};
|
btnChineseName.MouseUpEventHandler += ChangeChineseEventHandler;
|
btnCheckChinese.MouseUpEventHandler += ChangeChineseEventHandler;
|
rowChinese.MouseUpEventHandler += ChangeChineseEventHandler;
|
EventHandler<MouseEventArgs> ChangeEnglish = (sender2, e2) => {
|
setLanguage = "English";
|
btnCheckChinese.IsSelected = false;
|
btnCheckEnglish.IsSelected = true;
|
btnCheckCzech.IsSelected = false;
|
};
|
btnEnglish.MouseUpEventHandler += ChangeEnglish;
|
btnCheckEnglish.MouseUpEventHandler += ChangeEnglish;
|
rowEnglish.MouseUpEventHandler += ChangeEnglish;
|
|
EventHandler<MouseEventArgs> LanguageChangeCzech = (sender2, e2) => {
|
setLanguage = "Czech";
|
btnCheckChinese.IsSelected = false;
|
btnCheckEnglish.IsSelected = false;
|
btnCheckCzech.IsSelected = true;
|
};
|
btnCzech.MouseUpEventHandler += LanguageChangeCzech;
|
btnCheckCzech.MouseUpEventHandler += LanguageChangeCzech;
|
rowCzech.MouseUpEventHandler += LanguageChangeCzech;
|
|
|
FrameLayout skinDialogBottom = new FrameLayout () {
|
Y = setLanguageScrolView.Bottom,
|
Height = Application.GetRealHeight (80 + 30),
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
};
|
dialogSetLanguageView.AddChidren (skinDialogBottom);
|
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (250),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextID = R.MyInternationalizationString.cancel,
|
TextAlignment = TextAlignment.Center,
|
};
|
skinDialogBottom.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (ssd, de) => {
|
dialogSetLanguage.Close ();
|
};
|
|
Button btnConfrim = new Button () {
|
X = btnCancel.Right + 1,
|
Width = Application.GetRealWidth (250),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextID = R.MyInternationalizationString.Confrim,
|
TextAlignment = TextAlignment.Center,
|
};
|
skinDialogBottom.AddChidren (btnConfrim);
|
btnConfrim.MouseUpEventHandler += (ssd, de) => {
|
if (UserConfig.Instance.SetLanguage != setLanguage) {
|
UserConfig.Instance.SetLanguage = setLanguage;
|
Language.CurrentLanguage = setLanguage;
|
UserConfig.Instance.SaveUserConfig ();
|
this.RemoveFromParent ();
|
UserMiddle.Init ();
|
}
|
dialogSetLanguage.Close ();
|
};
|
dialogSetLanguage.Show ();
|
};
|
SetLanguageView.MouseUpEventHandler += SetLanguageHandler;
|
btnSetLanguageTitle.MouseUpEventHandler += SetLanguageHandler;
|
btnSetLanguageRight.MouseUpEventHandler += SetLanguageHandler;
|
Button btnSetLanguageLine = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
contentView.AddChidren (btnSetLanguageLine);
|
#endregion
|
|
#region 菜单配置
|
FrameLayout SetFunctionListView = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
contentView.AddChidren (SetFunctionListView);
|
|
Button btnSetFunctionListTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
TextID = R.MyInternationalizationString.FunctionCatalogueManagement,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
SetFunctionListView.AddChidren (btnSetFunctionListTitle);
|
|
Button btnSetFunctionListRight = 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",
|
};
|
SetFunctionListView.AddChidren (btnSetFunctionListRight);
|
|
|
|
|
EventHandler<MouseEventArgs> SetFunctionListHandler = (sender, e) => {
|
Dialog dialogSetFunctionList = new Dialog ();
|
string setLanguage = UserConfig.Instance.SetLanguage;
|
|
FrameLayout dialogSetFunctionListView = new FrameLayout () {
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (270 + 180 + 70 + 200),
|
Gravity = Gravity.Center,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
};
|
dialogSetFunctionList.AddChidren (dialogSetFunctionListView);
|
|
Button setFunctionList = new Button () {
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextID = R.MyInternationalizationString.FunctionCatalogueManagement,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
TextAlignment = TextAlignment.Center,
|
};
|
dialogSetFunctionListView.AddChidren (setFunctionList);
|
|
VerticalScrolViewLayout setFunctionListScrolView = new VerticalScrolViewLayout () {
|
Y = setFunctionList.Bottom,
|
Height = Application.GetRealHeight (330 + 200),
|
};
|
dialogSetFunctionListView.AddChidren (setFunctionListScrolView);
|
|
|
UserConfig.Instance.HideDeviceTypes.Distinct ().ToList ();
|
UserConfig.Instance.DeviceTypes.Distinct ().ToList ();
|
foreach (var functionIndex in UserConfig.Instance.DeviceTypes) {
|
if (functionIndex == R.MyInternationalizationString.VideoIntercom)
|
continue;
|
#region 简体中文
|
RowLayout functionRow = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
setFunctionListScrolView.AddChidren (functionRow);
|
|
Button btnPoint = new Button () {
|
X = Application.GetMinRealAverage (30),
|
Width = Application.GetMinRealAverage (10),
|
Height = Application.GetMinRealAverage (10),
|
Radius = (uint)Application.GetMinRealAverage (5),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.CenterVertical,
|
};
|
functionRow.AddChidren (btnPoint);
|
|
Button btnChineseName = new Button () {
|
X = btnPoint.Right + Application.GetRealWidth (20),
|
Width = Application.GetRealWidth (350),
|
TextColor = SkinStyle.Current.TextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = Language.StringByID (functionIndex)
|
};
|
functionRow.AddChidren (btnChineseName);
|
|
Button btnCheck = new Button () {
|
X = btnChineseName.Right + Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (15),
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (61),
|
SelectedImagePath = "Skin/Check.png",
|
UnSelectedImagePath = "Item/Transparent.png",
|
IsSelected = !UserConfig.Instance.HideDeviceTypes.Contains (functionIndex)
|
};
|
functionRow.AddChidren (btnCheck);
|
|
|
#endregion
|
|
EventHandler<MouseEventArgs> EventHandler = (sender2, e2) => {
|
btnCheck.IsSelected = !btnCheck.IsSelected;
|
if (btnCheck.IsSelected) {
|
UserConfig.Instance.HideDeviceTypes.Remove (functionIndex);
|
} else {
|
UserConfig.Instance.HideDeviceTypes.Add (functionIndex);
|
}
|
UserConfig.Instance.SaveUserConfig ();
|
};
|
functionRow.MouseUpEventHandler += EventHandler;
|
btnCheck.MouseUpEventHandler += EventHandler;
|
btnChineseName.MouseUpEventHandler += EventHandler;
|
}
|
|
FrameLayout skinDialogBottom = new FrameLayout () {
|
Y = setFunctionListScrolView.Bottom,
|
Height = Application.GetRealHeight (80 + 30),
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
};
|
dialogSetFunctionListView.AddChidren (skinDialogBottom);
|
|
|
Button btnConfrim = new Button () {
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextID = R.MyInternationalizationString.Confrim,
|
TextAlignment = TextAlignment.Center,
|
};
|
skinDialogBottom.AddChidren (btnConfrim);
|
btnConfrim.MouseUpEventHandler += (ssd, de) => {
|
dialogSetFunctionList.Close ();
|
};
|
dialogSetFunctionList.Show ();
|
};
|
|
|
SetFunctionListView.MouseUpEventHandler += SetFunctionListHandler;
|
btnSetFunctionListTitle.MouseUpEventHandler += SetFunctionListHandler;
|
btnSetFunctionListRight.MouseUpEventHandler += SetFunctionListHandler;
|
Button btnSetFunctionListLine = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
contentView.AddChidren (btnSetFunctionListLine);
|
|
#endregion
|
|
#region 切换服务器
|
//暂时隐藏
|
//FrameLayout SelectServerView = new FrameLayout () {
|
// Height = Application.GetRealHeight (100),
|
//};
|
//contentView.AddChidren (SelectServerView);
|
|
//Button btnSelectServerTitle = new Button () {
|
// X = Application.GetRealWidth (40),
|
// TextID = R.MyInternationalizationString.SelectServer,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1,
|
//};
|
//SelectServerView.AddChidren (btnSelectServerTitle);
|
|
//Button btnSelectServerRight = 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",
|
//};
|
//SelectServerView.AddChidren (btnSelectServerRight);
|
|
|
//EventHandler<MouseEventArgs> SelectServerHandler = (sender, e) => {
|
// //跳转选择服务器页面
|
// AccountSelectServer mAccountSelectServer = new AccountSelectServer ();
|
// UserMiddle.SettingPageView.AddChidren (mAccountSelectServer);
|
// mAccountSelectServer.ShowView ();
|
// UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1;
|
//};
|
|
|
//SelectServerView.MouseUpEventHandler += SelectServerHandler;
|
//btnSelectServerTitle.MouseUpEventHandler += SelectServerHandler;
|
//btnSelectServerRight.MouseUpEventHandler += SelectServerHandler;
|
//Button btnSelectServerLine = new Button () {
|
// Height = Application.GetRealHeight (5),
|
// BackgroundColor = SkinStyle.Current.MainColor,
|
//};
|
//contentView.AddChidren (btnSelectServerLine);
|
|
#endregion
|
|
|
|
var logoutButtonView = new FrameLayout () {
|
Y = contentView.Bottom,
|
Height = Application.GetRealHeight (UserMiddle.userMenuItemHeight + 3),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (logoutButtonView);
|
|
var btnLogout = new Button () {
|
Height = Application.GetRealHeight (90),
|
TextColor = SkinStyle.Current.TextColor1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextID = R.MyInternationalizationString.LogoutAccount,
|
TextAlignment = TextAlignment.Center
|
};
|
logoutButtonView.AddChidren (btnLogout);
|
|
|
btnLogout.MouseUpEventHandler += (sender1, e1) => {
|
btnLogout.IsSelected = false;
|
if (MainPage.LoginUser == null) {
|
new AccountLogin ().Show ();
|
} else {
|
Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.LogoutAccountTip), Language.StringByID (R.MyInternationalizationString.No), Language.StringByID (R.MyInternationalizationString.Yes));
|
alert.Show ();
|
alert.ResultEventHandler += (sender, e) => {
|
if (e) {
|
LogoutAccount ();
|
}
|
};
|
return;
|
}
|
};
|
|
}
|
|
void LogoutAccount ()
|
{
|
MainPage.LoginUser.LastTime = DateTime.MinValue;
|
MainPage.LoginUser.SaveUserInfo ();
|
Room.Lists.Clear ();
|
new AccountLogin (MainPage.LoginUser.AccountString, "").Show ();
|
MainPage.LoginUser.LastTime = System.DateTime.MinValue;
|
this.RemoveFromParent ();
|
SharedMethod.SharedMethod.CurPageLayout = null;
|
new System.Threading.Thread (async () => {
|
try {
|
if (CommonPage.IsRemote) {
|
CommonPage.IsRemote = false;
|
await SmartHome.MqttCommon.DisConnectRemoteMqttClient ("LogoutAccount");
|
}
|
//删除推送数据
|
new System.Net.WebClient ().DownloadData ("https://global.hdlcontrol.com/HangZhouHdlCloudApi/ZigbeeUsers/SignOut");
|
Application.RunOnMainThread (() => {
|
UserMiddle.LinkStatusTip.BackgroundColor = SkinStyle.Current.LinkStatusTipColor;
|
});
|
} catch { }
|
}) { IsBackground = true }.Start() ;
|
#if HDL
|
#if wallon
|
#else
|
if (!String.IsNullOrEmpty (MainPage.LoginUser.AllVisionRegisterDevUserNameGuid)) {
|
com.freeview.global.Video.Logout ();
|
}
|
#endif
|
#endif
|
}
|
|
void SubaccountListView ()
|
{
|
FrameLayout subAccView = new FrameLayout ();
|
UserMiddle.SettingPageView.AddChidren (subAccView);
|
UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1;
|
}
|
|
|
void LogIn (AccountListDB accountListDB, string account = "")
|
{
|
var dgLogin = new Dialog ();
|
|
var loginView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (550),
|
Height = Application.GetRealHeight (480),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
Radius = 5,
|
};
|
dgLogin.AddChidren (loginView);
|
|
var btnLoginTilte = new Button () {
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.AccoutLogin,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
loginView.AddChidren (btnLoginTilte);
|
|
var accountView = new FrameLayout () {
|
Width = Application.GetRealWidth (510),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (20),
|
Y = btnLoginTilte.Bottom + Application.GetRealHeight (30),
|
BackgroundImagePath = "Register/Register_Email_Address.png",
|
Radius = (uint)Application.GetRealHeight (0),
|
};
|
loginView.AddChidren (accountView);
|
|
var etAccount = new EditText () {
|
Width = Application.GetRealWidth (400),
|
X = Application.GetRealWidth (100),
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.Account),
|
PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
Radius = (uint)Application.GetRealHeight (0),
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = account
|
};
|
accountView.AddChidren (etAccount);
|
|
var passwrodView = new FrameLayout () {
|
Width = Application.GetRealWidth (510),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (20),
|
Y = accountView.Bottom + Application.GetRealHeight (50),
|
BackgroundImagePath = "Register/Register_Password_kuang.png",
|
};
|
loginView.AddChidren (passwrodView);
|
|
var etPasswrod = new EditText () {
|
Width = Application.GetRealWidth (400 - 73),
|
X = Application.GetRealWidth (100),
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterPassword),
|
PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
SecureTextEntry = true,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
passwrodView.AddChidren (etPasswrod);
|
|
Button btnShowPassword = new Button () {
|
X = etPasswrod.Right,
|
Y = etPasswrod.Y + Application.GetRealHeight (12),
|
Width = Application.GetRealWidth (73),
|
Height = Application.GetRealHeight (60),
|
SelectedImagePath = "CrabtreeAdd/ShowPW.png",
|
UnSelectedImagePath = "CrabtreeAdd/HidePW.png",
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 2,
|
Radius = 1
|
};
|
passwrodView.AddChidren (btnShowPassword);
|
btnShowPassword.MouseUpEventHandler += (d2d, ff) => {
|
btnShowPassword.IsSelected = !btnShowPassword.IsSelected;
|
etPasswrod.SecureTextEntry = !btnShowPassword.IsSelected;
|
};
|
|
etAccount.EditorEnterAction += (obj) => {
|
Application.HideSoftInput ();
|
etPasswrod.Foucs = true;
|
};
|
etPasswrod.EditorEnterAction += (obj) => {
|
Application.HideSoftInput ();
|
};
|
|
var btnCloseLogin = new Button () {
|
Width = Application.GetRealWidth (274),
|
Height = Application.GetRealHeight (89),
|
Y = passwrodView.Bottom + Application.GetRealHeight (70),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.cancel,
|
TextSize = 15,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
loginView.AddChidren (btnCloseLogin);
|
btnCloseLogin.MouseUpEventHandler += (sende2r, e2) => {
|
dgLogin.Close ();
|
};
|
|
Button btnLogin = new Button () {
|
Width = Application.GetRealWidth (274),
|
Height = Application.GetRealHeight (89),
|
X = btnCloseLogin.Right + 1,
|
Y = btnCloseLogin.Y,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.Login,
|
TextSize = 15,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
loginView.AddChidren (btnLogin);
|
btnLogin.MouseDownEventHandler += (sende2r, e2) => {
|
btnLogin.IsSelected = true;
|
};
|
|
btnLogin.MouseUpEventHandler += (sender2, e2) => {
|
btnLogin.IsSelected = false;
|
account = etAccount.Text.Trim ().ToLower();
|
var password = etPasswrod.Text.Trim ();
|
|
if (accountListDB.AccountInfo.ContainsKey (account)) {
|
new Tip () { Text = Language.StringByID (R.MyInternationalizationString.AccountHasBeenSaved_NoNeedToAddAgain), Direction = AMPopTipDirection.Up, CloseTime = 3 }.Show (etAccount);
|
//提示用户,该账号已经保存
|
return;
|
}
|
|
new System.Threading.Thread (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
if (Language.CurrentLanguage == "Chinese") {
|
MainPage.Loading.Start ("登录中...");
|
} else {
|
MainPage.Loading.Start ("Login...");
|
}
|
});
|
if (UserConfig.Instance.internetStatus == 0 || !MainPage.checeInternet ()) {
|
Application.RunOnMainThread (() => {
|
new Tip () { Text = Language.StringByID (R.MyInternationalizationString.NetworkAbnormal), Direction = AMPopTipDirection.Up, CloseTime = 3 }.Show (btnLogin);
|
});
|
return;
|
}
|
|
var revertConnectionObj = MainPage.RequestHttps ("Connection", "");
|
if (revertConnectionObj.StateCode == "SUCCESS") {
|
var requestObj = new LoginObj () { Account = account, Password = password, Company = MainPage.SoftSmsType };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("Login", requestJson, false);
|
if (revertObj.StateCode == "SUCCESS") {
|
#region 退出当前账号
|
if (CommonPage.IsRemote)
|
SmartHome.MqttCommon.DisConnectRemoteMqttClient ();
|
//删除推送数据
|
new System.Net.WebClient ().DownloadData ("https://global.hdlcontrol.com/HangZhouHdlCloudApi/ZigbeeUsers/SignOut");
|
|
Application.RunOnMainThread (() => {
|
UserMiddle.LinkStatusTip.BackgroundColor = SkinStyle.Current.LinkStatusTipColor;
|
});
|
#if HDL
|
|
#if wallon
|
#else
|
if (!String.IsNullOrEmpty (MainPage.LoginUser.AllVisionRegisterDevUserNameGuid)) {
|
com.freeview.global.Video.Logout ();
|
}
|
#endif
|
#endif
|
#endregion
|
#region 存储账号密码
|
accountListDB.account.Add (account);
|
accountListDB.AccountInfo.TryAdd (account.ToLower (), new AccountInfo () { Password = password, UserInfo = MainPage.LoginUser, RegionList = UserConfig.Instance.HomeLists });
|
accountListDB.SaveAccountListDB ();
|
#endregion
|
|
#region 存储当前账号的数据
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ("");
|
});
|
try {
|
var backuplist = IO.FileUtils.ReadFiles ();
|
int index = 0;
|
string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.RegionID.ToString ());
|
IO.FileUtils.DeleteRegionFiles (oldRegionRootPath);
|
foreach (var fileName in backuplist) {
|
if (fileName == "linphonerc" || fileName == "AccountListDB")
|
continue;
|
System.IO.FileInfo fileInfo = new System.IO.FileInfo (IO.FileUtils.RootPath + fileName);
|
if (fileInfo == null)
|
continue;
|
if (fileInfo.Exists) {
|
fileInfo.MoveTo (oldRegionRootPath + fileName);
|
Console.WriteLine ("move file : " + fileName);
|
}
|
index++;
|
Application.RunOnMainThread (() => {
|
int pro = (int)(index * 1.0 / backuplist.Count * 50);
|
MainPage.Loading.Text = pro.ToString () + "%";
|
});
|
}
|
SmartHome.MqttCommon.DisConnectRemoteMqttClient ();
|
IO.FileUtils.DeleteAllFile ();
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
}
|
#endregion
|
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes> (revertObj.ResponseData.ToString ());
|
var revertData = responseDataObj;
|
MainPage.LoginUser = new UserInfo {
|
ID = revertData.UserId, MasterID = revertData.MainUserId, AccountType = revertData.UserType, AccountString = account, Password = password, LastTime = DateTime.Now,
|
AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid,
|
};
|
string DeviceType = "android";
|
#if __IOS__
|
DeviceType = "iphone";
|
#endif
|
var mAddRegIDObj = new AddRegIDObj () {
|
RegID = UserConfig.Instance.tokenID,
|
Alias = UserConfig.Instance.phoneName,
|
Account = account,
|
UserMode = 2,
|
};
|
var mAddRegIDObjJson = Newtonsoft.Json.JsonConvert.SerializeObject (mAddRegIDObj);
|
MainPage.RequestHttps (@"AddRegID", mAddRegIDObjJson, true, false);
|
|
//string jsonString = "{" +
|
// "\"RegID\":" + "\"" + UserConfig.Instance.tokenID + "\"" + "," +
|
// "\"Alias\":" + "\"" + UserConfig.Instance.phoneName + "\"" + "," +
|
// "\"Account\":" + "\"" + account + "\"" +
|
// "}";
|
//MainPage.RequestHttps (@"AddRegID", jsonString, true);
|
#if wallon
|
#else
|
if (!string.IsNullOrEmpty (MainPage.LoginUser.AllVisionRegisterDevUserNameGuid)) {
|
//可视对讲
|
Application.RunOnMainThread (() => {
|
#if Android
|
(Application.Activity as BaseActivity).ReadWriteContact ((b) => {
|
if (b) {
|
com.freeview.global.Video.Init (MainPage.LoginUser.LoginTokenString, MainPage.LoginUser.AllVisionRegisterDevUserNameGuid);
|
}
|
});
|
#else
|
com.freeview.global.Video.Init (MainPage.LoginUser.LoginTokenString, MainPage.LoginUser.AllVisionRegisterDevUserNameGuid);
|
#endif
|
});
|
UserConfig.Instance.HideDeviceTypes.Distinct ().ToList ();
|
UserConfig.Instance.DeviceTypes.Distinct ().ToList ();
|
if (UserConfig.Instance.HideDeviceTypes.Contains (R.MyInternationalizationString.VideoIntercom))
|
UserConfig.Instance.HideDeviceTypes.Remove (R.MyInternationalizationString.VideoIntercom);
|
} else {
|
if (!UserConfig.Instance.HideDeviceTypes.Contains (R.MyInternationalizationString.VideoIntercom))
|
UserConfig.Instance.HideDeviceTypes.Add (R.MyInternationalizationString.VideoIntercom);
|
}
|
#endif
|
var requestObj2 = new HomeListObj ();
|
var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
|
var revertObj2 = MainPage.RequestHttps ("HomeList", requestJson2);
|
if (revertObj2.StateCode == "SUCCESS") {
|
UserConfig.Instance.HomeLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertObj2.ResponseData.ToString ());
|
|
if (UserConfig.Instance.HomeLists.Count > 0) {
|
UserConfig.Instance.CurrentRegion = UserConfig.Instance.HomeLists [0];
|
foreach (var home in UserConfig.Instance.HomeLists) {
|
var sssd = IO.FileUtils.ExistRegion (home.RegionID.ToString ());
|
Console.WriteLine ("IO.FileUtils.ExistRegion (home.RegionID.ToString()); " + sssd.ToString ());
|
|
if (sssd) {
|
string newRegionRootPath = IO.FileUtils.CreateRegionBackup (home.RegionID.ToString ());
|
IO.FileUtils.RestoreRegionFiles (newRegionRootPath);
|
UserConfig.Instance.RefreshUserConfig ();
|
UserConfig.Instance.CurrentRegion = home;
|
break;
|
}
|
}
|
} else {
|
//创建默认住宅
|
var requestObj21 = new AddHomeAndGatewayByONObj () { Region = "Home", MAC = "" };
|
var requestJson21 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj21);
|
var revertObj21 = MainPage.RequestHttps ("AddHomeAndGatewayByON", requestJson21);
|
if (revertObj21.StateCode == "SUCCESS") {
|
revertObj2 = MainPage.RequestHttps ("HomeList", requestJson2);
|
if (revertObj2.StateCode == "SUCCESS") {
|
UserConfig.Instance.HomeLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertObj2.ResponseData.ToString ());
|
UserConfig.Instance.CurrentRegion = UserConfig.Instance.HomeLists [0];
|
}
|
}
|
}
|
|
|
MainPage.LoginUser.LastTime = DateTime.Now;
|
UserConfig.Instance.SaveUserConfig ();
|
MainPage.LoginUser.SaveUserInfo ();
|
Room.InitAllRoom ();
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SwitchRegionSuccessfully),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
UserMiddle.Init ();
|
EquipmentPublicClass.CheckLinkRemote (2);
|
});
|
}
|
}
|
}
|
} catch (Exception ex) {
|
MainPage.FailureToServer ();
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
dgLogin.Close ();
|
});
|
}
|
}) { IsBackground = true }.Start ();
|
|
};
|
dgLogin.Show ();
|
}
|
|
}
|
}
|