using System;
|
using System.IO;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public static class UserSettingView
|
{
|
public static void InitUserSettingView ()
|
{
|
#region
|
FrameLayout topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
UserMiddle.SettingBodyView.AddChidren (topView);
|
|
//Button LogoButton = new Button () {
|
// Y = Application.GetRealHeight (10),
|
// Width = Application.GetRealWidth (154),
|
// Height = Application.GetRealHeight (90),
|
// UnSelectedImagePath = MainPage.WiFiStatus,
|
//};
|
//topView.AddChidren (LogoButton);
|
//LogoButton.MouseUpEventHandler += (dd, ff) => {
|
// EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus, LogoButton);
|
//};
|
topView.AddChidren (UserMiddle.btnLinkStatus);
|
|
Button NameButton = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetMinReal (90),
|
TextID = R.MyInternationalizationString.Setting,
|
TextColor = SkinStyle.Current.TextColor1,
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 20,
|
//FontName = "TitilliumText25L"
|
};
|
topView.AddChidren (NameButton);
|
//try {
|
// Console.WriteLine ("3");
|
// UserMiddle.SettingBodyView.AddChidren (topView);
|
// Console.WriteLine ("3");
|
//} catch(Exception ex) {
|
// Console.WriteLine (ex.ToString ());
|
//}
|
|
FrameLayout topUserMsgView = new FrameLayout () {
|
Y = Application.GetRealHeight (126),
|
Height = Application.GetRealHeight (175),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (topUserMsgView);
|
|
Button btnUserIcon = new Button () {
|
X = Application.GetRealWidth (27),
|
Width = Application.GetRealWidth (96),
|
Height = Application.GetRealHeight (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,
|
Text = MainPage.LoginUser.Name == "" ? Language.StringByID (R.MyInternationalizationString.Account) : MainPage.LoginUser.Name,
|
//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 btnTopUserMsgRight = new Button () {
|
X = Application.GetRealWidth (570),
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
topUserMsgView.AddChidren (btnTopUserMsgRight);
|
|
|
EventHandler<MouseEventArgs> accountEventHandler = (sender, e) => {
|
new AccountLogin ().Show ();
|
};
|
btnUserName.MouseUpEventHandler += accountEventHandler;
|
btnUserAccount.MouseUpEventHandler += accountEventHandler;
|
topUserMsgView.MouseUpEventHandler += accountEventHandler;
|
btnTopUserMsgRight.MouseUpEventHandler += accountEventHandler;
|
Button btTopNull = new Button () {
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Height = Application.GetRealHeight (30),
|
};
|
UserMiddle.SettingView.AddChidren (btTopNull);
|
#endregion
|
|
|
#region ---进入后台---DeviceManagementView---
|
//if (true) {//调试账号
|
if (MainPage.LoginUser.AccountType == 0) {//调试账号
|
FrameLayout DeviceManagementView = new FrameLayout () {
|
Width = Application.GetRealWidth (640),
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (DeviceManagementView);
|
|
Button btnDevcieManagementIcon = new Button () {
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "AccountSettings/DeviceManagement.png",
|
IsSelected = false
|
};
|
DeviceManagementView.AddChidren (btnDevcieManagementIcon);
|
|
Button btnDeviceManagementTitle = new Button () {
|
X = btnDevcieManagementIcon.Right + Application.GetRealWidth (20),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = "Zones/Residences",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceManagementView.AddChidren (btnDeviceManagementTitle);
|
|
EventHandler<MouseEventArgs> SystemEventHandler = (sender, e) => {
|
var hl = new GuideAddResidence ();
|
UserMiddle.SettingPageView.AddChidren (hl);
|
hl.ShowHomeList ();
|
UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1;
|
|
//HomeListView hl = new HomeListView ();
|
//UserMiddle.SettingPageView.AddChidren (hl);
|
//hl.ShowHomeList ();
|
//UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1;
|
};
|
|
DeviceManagementView.MouseUpEventHandler += SystemEventHandler;
|
btnDevcieManagementIcon.MouseUpEventHandler += SystemEventHandler;
|
btnDeviceManagementTitle.MouseUpEventHandler += SystemEventHandler;
|
Button btnNull = new Button () {
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Height = Application.GetRealHeight (5)
|
};
|
UserMiddle.SettingView.AddChidren (btnNull);
|
}
|
#endregion
|
|
#region ---备份---
|
FrameLayout BackupView = new FrameLayout () {
|
Width = Application.GetRealWidth (640),
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (BackupView);
|
Button btnBackupIcon = new Button () {
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "AccountSettings/Backup.png"
|
};
|
BackupView.AddChidren (btnBackupIcon);
|
|
Button btnBackupTitle = new Button () {
|
X = btnBackupIcon.Right + Application.GetRealWidth (20),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.BackupManage,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
BackupView.AddChidren (btnBackupTitle);
|
EventHandler<MouseEventArgs> BackupEventHandler = (sender, e) => {
|
Databackup dataBackupView = new Databackup ();
|
UserMiddle.SettingPageView.AddChidren (dataBackupView);
|
dataBackupView.DatabackupShow ();
|
UserMiddle.SettingPageView.PageIndex = 1;
|
};
|
BackupView.MouseUpEventHandler += BackupEventHandler;
|
btnBackupIcon.MouseUpEventHandler += BackupEventHandler;
|
btnBackupTitle.MouseUpEventHandler += BackupEventHandler;
|
Button btnNull2 = new Button () {
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Height = Application.GetRealHeight (5)
|
};
|
UserMiddle.SettingView.AddChidren (btnNull2);
|
|
#endregion
|
|
#region ---msg---
|
//FrameLayout WarningMsgView = new FrameLayout () {
|
// Width = Application.GetRealWidth (640),
|
// Height = Application.GetRealHeight (100),
|
// BackgroundColor = SkinStyle.Current.ViewColor
|
//};
|
//UserMiddle.SettingView.AddChidren (WarningMsgView);
|
//Button btnWarningMsgIcon = new Button () {
|
// X = Application.GetRealWidth (30),
|
// Gravity = Gravity.CenterVertical,
|
// Width = Application.GetRealWidth (75),
|
// Height = Application.GetRealHeight (75),
|
// UnSelectedImagePath = "RemoteMsg/RemoteIcon.png",
|
// SelectedImagePath = "RemoteMsg/RemoteIconOn.png"
|
//};
|
//WarningMsgView.AddChidren (btnWarningMsgIcon);
|
|
//Button btnWarningMsgTitle = new Button () {
|
// X = btnWarningMsgIcon.Right + Application.GetRealWidth (20),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextID = R.MyInternationalizationString.MessageAlert,
|
// TextColor = SkinStyle.Current.TextColor1,
|
//};
|
//WarningMsgView.AddChidren (btnWarningMsgTitle);
|
//btnWarningMsgTitle.MouseLongEventHandler += (sd, ds) => {
|
// //var uc = UserConfig.Instance.RometoUserInfoKeys.Find ((obj) => obj.Contains ("HiddenJson"));
|
// //new Alert ("", uc, "close").Show ();
|
//};
|
|
//EventHandler<MouseEventArgs> WarningMsgEventHandler = (sender, e) => {
|
// var msgView = new WarningList ();
|
// UserMiddle.SettingPageView.AddChidren (msgView);
|
// msgView.ShowWarningListPage ();
|
// UserMiddle.SettingPageView.PageIndex = 1;
|
//};
|
//WarningMsgView.MouseUpEventHandler += WarningMsgEventHandler;
|
//btnWarningMsgIcon.MouseUpEventHandler += WarningMsgEventHandler;
|
//btnWarningMsgTitle.MouseUpEventHandler += WarningMsgEventHandler;
|
//Button btnNullWarningMsg = new Button () {
|
// Height = Application.GetRealHeight (5),
|
// BackgroundColor = SkinStyle.Current.MainColor
|
//};
|
//UserMiddle.SettingView.AddChidren (btnNullWarningMsg);
|
#endregion
|
|
#region ---Schedule---
|
FrameLayout ScheduleView = new FrameLayout () {
|
Width = Application.GetRealWidth (640),
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (ScheduleView);
|
Button btnScheduleIcon = new Button () {
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "CrabtreeAdd/Schedule.png",
|
};
|
ScheduleView.AddChidren (btnScheduleIcon);
|
|
Button btnScheduleTitle = new Button () {
|
X = Application.GetRealWidth (125),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.Schedule,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
ScheduleView.AddChidren (btnScheduleTitle);
|
EventHandler<MouseEventArgs> ScheduleEventHandler = (sender, e) => {
|
var scheduleShowView = new UserSchedule ();
|
UserMiddle.SettingPageView.AddChidren (scheduleShowView);
|
scheduleShowView.ShowPage ();
|
UserMiddle.SettingPageView.PageIndex = 1;
|
};
|
ScheduleView.MouseUpEventHandler += ScheduleEventHandler;
|
btnScheduleIcon.MouseUpEventHandler += ScheduleEventHandler;
|
btnScheduleTitle.MouseUpEventHandler += ScheduleEventHandler;
|
Button btnNullSchedule = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
UserMiddle.SettingView.AddChidren (btnNullSchedule);
|
#endregion
|
|
|
#region ---Alexa---
|
FrameLayout AlexaView = new FrameLayout () {
|
Width = Application.GetRealWidth (640),
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (AlexaView);
|
Button btnAlexaIcon = new Button () {
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "CrabtreeAdd/Alexa.png",
|
};
|
AlexaView.AddChidren (btnAlexaIcon);
|
|
Button btnAlexaTitle = new Button () {
|
X = Application.GetRealWidth (125),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = "Alexa Integration",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
AlexaView.AddChidren (btnAlexaTitle);
|
EventHandler<MouseEventArgs> AlexaEventHandler = (sender, e) => {
|
var alexaPage = new AlexaDeviceListPage ();
|
UserMiddle.SettingPageView.AddChidren (alexaPage);
|
alexaPage.ShowPage ();
|
UserMiddle.SettingPageView.PageIndex = 1;
|
};
|
AlexaView.MouseUpEventHandler += AlexaEventHandler;
|
btnAlexaIcon.MouseUpEventHandler += AlexaEventHandler;
|
btnAlexaTitle.MouseUpEventHandler += AlexaEventHandler;
|
Button btnNullAlexa = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
UserMiddle.SettingView.AddChidren (btnNullAlexa);
|
#endregion
|
|
#region subaccount
|
if (MainPage.LoginUser.AccountType == 0) {
|
FrameLayout subaccountView = new FrameLayout () {
|
Width = Application.GetRealWidth (640),
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (subaccountView);
|
Button btnSubaccountIcon = new Button () {
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "CrabtreeAdd/SubaccountIcon.png",
|
};
|
subaccountView.AddChidren (btnSubaccountIcon);
|
|
Button btnSubaccountTitle = new Button () {
|
X = Application.GetRealWidth (125),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = "User Management",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
subaccountView.AddChidren (btnSubaccountTitle);
|
Button btnNullSubaccount = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
UserMiddle.SettingView.AddChidren (btnNullSubaccount);
|
|
EventHandler<MouseEventArgs> SubaccountEventHandler = (sender, e) => {
|
if (UserConfig.Instance.internetStatus == 0) {
|
new Alert ("", "Unable to save data, please check the network.", "Close").Show ();
|
return;
|
}
|
MainPage.Loading.Start ("Please wait...");
|
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<System.Collections.Generic.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 += SubaccountEventHandler;
|
btnSubaccountIcon.MouseUpEventHandler += SubaccountEventHandler;
|
btnSubaccountTitle.MouseUpEventHandler += SubaccountEventHandler;
|
}
|
#endregion
|
|
|
#region ---测试按钮---
|
//if (UserConfig.Instance.internetStatus == 2) {
|
if (true) {
|
var ConmmunicationTestView = new FrameLayout () {
|
Width = Application.GetRealWidth (640),
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (ConmmunicationTestView);
|
var btnConmmunicationTestIcon = new Button () {
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "AccountSettings/DataShared.png"
|
};
|
ConmmunicationTestView.AddChidren (btnConmmunicationTestIcon);
|
var btnConmmunicationTestTitle = new Button () {
|
X = Application.GetRealWidth (125),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = "Communication test",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
ConmmunicationTestView.AddChidren (btnConmmunicationTestTitle);
|
EventHandler<MouseEventArgs> ConmmunicationTestEventHandler = (sender, e) => {
|
GoData ();
|
};
|
ConmmunicationTestView.MouseUpEventHandler += ConmmunicationTestEventHandler;
|
btnConmmunicationTestIcon.MouseUpEventHandler += ConmmunicationTestEventHandler;
|
btnConmmunicationTestTitle.MouseUpEventHandler += ConmmunicationTestEventHandler;
|
Button btnNull3 = new Button () {
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Height = Application.GetRealHeight (5)
|
};
|
UserMiddle.SettingView.AddChidren (btnNull3);
|
}
|
#endregion
|
|
|
|
#region ---help---
|
var helpView = new FrameLayout () {
|
Width = Application.GetRealWidth (640),
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
UserMiddle.SettingView.AddChidren (helpView);
|
var btnhelpIcon = new Button () {
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "CrabtreeAdd/Help.png",
|
SelectedImagePath = "CrabtreeAdd/HelpOn.png"
|
};
|
helpView.AddChidren (btnhelpIcon);
|
|
var btnhelpTitle = new Button () {
|
X = btnhelpIcon.Right + Application.GetRealWidth (20),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.Help,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
helpView.AddChidren (btnhelpTitle);
|
btnhelpTitle.MouseLongEventHandler += (sd, ds) => {
|
//var uc = UserConfig.Instance.RometoUserInfoKeys.Find ((obj) => obj.Contains ("HiddenJson"));
|
//new Alert ("", uc, "close").Show ();
|
};
|
|
EventHandler<MouseEventArgs> helpEventHandler = (sender, e) => {
|
var helpShowView = new HelpView ();
|
UserMiddle.SettingPageView.AddChidren (helpShowView);
|
helpShowView.ShowPage ();
|
UserMiddle.SettingPageView.PageIndex = 1;
|
};
|
helpView.MouseUpEventHandler += helpEventHandler;
|
btnhelpIcon.MouseUpEventHandler += helpEventHandler;
|
btnhelpTitle.MouseUpEventHandler += helpEventHandler;
|
Button btnNullhelp = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
UserMiddle.SettingView.AddChidren (btnNullhelp);
|
#endregion
|
|
|
Button btnNullSkin = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
UserMiddle.SettingView.AddChidren (btnNullSkin);
|
|
}
|
|
static void GoData ()
|
{
|
|
var localFileList = IO.FileUtils.ReadFiles ();
|
var gateWayList = localFileList.FindAll ((obj) => {
|
return (obj.StartsWith ("Equipment_")) && (
|
obj.Split ('_') [1].ToString () == DeviceType.OnePortBus.ToString () ||
|
obj.Split ('_') [1].ToString () == DeviceType.OnePortWirelessFR.ToString ());
|
});
|
GatewayBase common = null;
|
string gateWayString = "";
|
if (gateWayList.Count == 0) {
|
new Alert ("", "No gateway data was found on the phone.", "Close").Show ();
|
return;
|
}
|
if (gateWayList.Count > 0) {
|
foreach (var gatewayFileName in gateWayList) {
|
var tempStrings = gatewayFileName.Split ('_');
|
if (tempStrings [1].ToString () == DeviceType.OnePortBus.ToString () ||
|
tempStrings [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) {
|
gateWayString = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (gatewayFileName));
|
common = Newtonsoft.Json.JsonConvert.DeserializeObject<GatewayBase> (gateWayString);
|
|
if (common.MAC.Replace (".", "") == UserConfig.Instance.GatewayMAC.Replace (".", "")) {
|
if (!string.IsNullOrEmpty (common.Remote_UserName) && !string.IsNullOrEmpty (common.Remote_Password) &&
|
!string.IsNullOrEmpty (common.Remote_GroupName) && !string.IsNullOrEmpty (common.Remote_ProjectName)) {
|
break;
|
}
|
}
|
common = null;
|
}
|
}
|
} else {
|
return;
|
}
|
|
|
Dialog dialog = new Dialog ();
|
FrameLayout MianBody = new FrameLayout ();
|
dialog.AddChidren (MianBody);
|
|
FrameLayout bodyView = new FrameLayout () {
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (540),
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight (250),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 2,
|
BackgroundColor = SkinStyle.Current.DialogColor
|
};
|
MianBody.AddChidren (bodyView);
|
|
Button topButton = new Button () {
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextSize = 18,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
Text = "Conmmunication Test"
|
};
|
bodyView.AddChidren (topButton);
|
Button btnIP = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (50),
|
Y = topButton.Bottom,
|
TextAlignment = TextAlignment.CenterLeft,
|
Enable = false,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
bodyView.AddChidren (btnIP);
|
|
Button btnLocalTest = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (50),
|
Y = btnIP.Bottom,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
Enable = false,
|
IsMoreLines = true,
|
};
|
bodyView.AddChidren (btnLocalTest);
|
|
|
Button btnSeverTest = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (50),
|
Y = btnLocalTest.Bottom + Application.GetRealHeight (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
IsMoreLines = true,
|
Enable = false
|
};
|
bodyView.AddChidren (btnSeverTest);
|
|
Button btnCloseSharing = new Button () {
|
X = Application.GetRealWidth (50),
|
Y = btnSeverTest.Bottom + Application.GetRealHeight (40),
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (80),
|
SelectedBackgroundColor = SkinStyle.Current.ButtonColor,
|
BackgroundColor = SkinStyle.Current.SelectedColor,
|
TextSize = 16,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 2,
|
Text = "Close",
|
TextColor = SkinStyle.Current.DialogTextColor
|
};
|
bodyView.AddChidren (btnCloseSharing);
|
btnCloseSharing.MouseDownEventHandler += (sender2, e2) => {
|
btnCloseSharing.IsSelected = true;
|
};
|
btnCloseSharing.MouseUpEventHandler += (sender2, e2) => {
|
btnCloseSharing.IsSelected = false;
|
dialog.Close ();
|
};
|
dialog.Show ();
|
|
new System.Threading.Thread (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ();
|
});
|
|
//2020-07-23 连接WiFi才检测本地
|
if (UserConfig.Instance.internetStatus == 2) {
|
CommonPage.IsRemote = false;
|
CommonPage.FindGateway = true;
|
var result = Control.ControlBytesSendHasReturn (Command.ReadDeviceMac, common.SubnetID, common.DeviceID, new byte [] { }, false);
|
CommonPage.FindGateway = false;
|
if (result != null) {
|
Application.RunOnMainThread (() => {
|
btnLocalTest.Text = "Local UDP communication : succeeded.";
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
btnLocalTest.Text = "Local UDP communication : failed.";
|
});
|
}
|
|
}
|
|
//UDP communication to Sever : succeeded.
|
var gateWay = Newtonsoft.Json.JsonConvert.DeserializeObject<GatewayBase> (gateWayString);
|
|
try {
|
if (!SystemRemote.checeInternet ()) {
|
MainPage.AddTip (Language.StringByID (R.MyInternationalizationString.CheckInternet));
|
Application.RunOnMainThread (() => {
|
btnSeverTest.Text = "Http communication to Sever : failed.";
|
return;
|
});
|
} else {
|
CommonPage.IsRemote = true;
|
|
byte [] userNameBytes = CommonPage.MyEncodingGB2312.GetBytes (gateWay.Remote_UserName);
|
byte [] projectBytes = CommonPage.MyEncodingGB2312.GetBytes (gateWay.Remote_ProjectName);
|
byte [] firstBytes = new byte [28];
|
//用户名
|
System.Array.Copy (userNameBytes, 0, firstBytes, 0, 8 < userNameBytes.Length ? 8 : userNameBytes.Length);
|
//工程备注
|
System.Array.Copy (projectBytes, 0, firstBytes, 8, 20 < projectBytes.Length ? 20 : projectBytes.Length);
|
|
byte [] firstReturnBytes = Control.ControlBytesSendHasReturn (Command.RemoteFirst, 251, 251, firstBytes);
|
//连接不到远程服务器
|
if (firstReturnBytes == null) {
|
Application.RunOnMainThread (() => {
|
btnSeverTest.Text = "UDP communication to Sever : failed.";
|
return;
|
});
|
}
|
//从服务器获取用户远程连接的信息
|
else {
|
if (firstReturnBytes [0] == 0) {
|
Application.RunOnMainThread (() => {
|
btnSeverTest.Text = "Gateway UDP communication to Sever : failed.";
|
return;
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
btnSeverTest.Text = "UDP communication to Sever : succeeded.";
|
return;
|
});
|
}
|
}
|
//Application.RunOnMainThread (() => {
|
// btnSeverTest.Text = "UDP communication to Sever : succeeded.";
|
// return;
|
//});
|
}
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
}) { IsBackground = true }.Start ();
|
}
|
}
|
}
|