| | |
| | | Height = Application.GetRealHeight (50), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | Text = MainPage.LoginUser.Name == "" ? Language.StringByID(R.MyInternationalizationString.Account) : MainPage.LoginUser.Name, |
| | | Text = MainPage.LoginUser.Name == "" ? Language.StringByID (R.MyInternationalizationString.Account) : MainPage.LoginUser.Name, |
| | | //TextID = R.MyInternationalizationString.Account |
| | | }; |
| | | topUserMsgView.AddChidren (btnUserName); |
| | |
| | | }; |
| | | topUserMsgView.AddChidren (btnTopUserMsgRight); |
| | | |
| | | |
| | | |
| | | EventHandler<MouseEventArgs> accountEventHandler = (sender, e) => { |
| | | new AccountLogin ().Show (); |
| | | }; |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region ---数据接收--- |
| | | //if (MainPage.LoginUser.AccountType == 2 || MainPage.LoginUser.AccountString == @"464027401@qq.com") { |
| | | // var DataReceptionView = new FrameLayout () { |
| | | // Width = Application.GetRealWidth (640), |
| | | // Height = Application.GetRealHeight (100), |
| | | // BackgroundColor = SkinStyle.Current.ViewColor |
| | | // }; |
| | | // UserMiddle.SettingView.AddChidren (DataReceptionView); |
| | | // var btnDataReceptionIcon = new Button () { |
| | | // X = Application.GetRealWidth (30), |
| | | // Gravity = Gravity.CenterVertical, |
| | | // Width = Application.GetRealWidth (75), |
| | | // Height = Application.GetRealHeight (75), |
| | | // UnSelectedImagePath = "AccountSettings/DataShared.png" |
| | | // }; |
| | | // DataReceptionView.AddChidren (btnDataReceptionIcon); |
| | | // var btnDataReceptionTitle = new Button () { |
| | | // X = Application.GetRealWidth (125), |
| | | // TextAlignment = TextAlignment.CenterLeft, |
| | | // TextID = R.MyInternationalizationString.DataReception, |
| | | // TextColor = SkinStyle.Current.TextColor1, |
| | | // }; |
| | | // DataReceptionView.AddChidren (btnDataReceptionTitle); |
| | | // EventHandler<MouseEventArgs> DataReceptionEventHandler = (sender, e) => { |
| | | // GoData (); |
| | | // }; |
| | | // DataReceptionView.MouseUpEventHandler += DataReceptionEventHandler; |
| | | // btnDataReceptionIcon.MouseUpEventHandler += DataReceptionEventHandler; |
| | | // btnDataReceptionTitle.MouseUpEventHandler += DataReceptionEventHandler; |
| | | // Button btnNull3 = new Button () { |
| | | // BackgroundColor = SkinStyle.Current.MainColor, |
| | | // Height = Application.GetRealHeight (5) |
| | | // }; |
| | | // UserMiddle.SettingView.AddChidren (btnNull3); |
| | | //} |
| | | #endregion |
| | | |
| | | |
| | | #region ---msg--- |
| | | //FrameLayout WarningMsgView = new FrameLayout () { |
| | | // Width = Application.GetRealWidth (640), |
| | |
| | | Gravity = Gravity.CenterVertical, |
| | | Width = Application.GetRealWidth (75), |
| | | Height = Application.GetRealHeight (75), |
| | | UnSelectedImagePath = "CrabtreeAdd/Alexa.png", |
| | | UnSelectedImagePath = "CrabtreeAdd/Alexa.png", |
| | | }; |
| | | AlexaView.AddChidren (btnAlexaIcon); |
| | | |
| | |
| | | Button btnSubaccountTitle = new Button () { |
| | | X = Application.GetRealWidth (125), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text= "User Management", |
| | | Text = "User Management", |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | }; |
| | | subaccountView.AddChidren (btnSubaccountTitle); |
| | |
| | | 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 |
| | | |
| | |
| | | |
| | | 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 (430), |
| | | Height = Application.GetRealHeight (540), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight (250), |
| | | Radius = 5, |
| | |
| | | TextSize = 18, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextColor = SkinStyle.Current.DialogTextColor, |
| | | Text = "Conmmunication Test" |
| | | }; |
| | | bodyView.AddChidren (topButton); |
| | | Button btnIP = new Button () { |
| | |
| | | }; |
| | | bodyView.AddChidren (btnIP); |
| | | |
| | | EditText etIP = new EditText () { |
| | | 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 = btnIP.Bottom, |
| | | TextAlignment = TextAlignment.Center, |
| | | Y = btnLocalTest.Bottom + Application.GetRealHeight (30), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = SkinStyle.Current.TextColor, |
| | | Radius = 5, |
| | | BorderColor = SkinStyle.Current.BorderColor, |
| | | BorderWidth = 2, |
| | | IsMoreLines = true, |
| | | Enable = false |
| | | }; |
| | | bodyView.AddChidren (etIP); |
| | | |
| | | CommonPage.InitHttpListener (); |
| | | topButton.TextID = R.MyInternationalizationString.DataReception; |
| | | |
| | | string ipAddressString = new Net.NetWiFi ().IpAddress == null ? "null" : new Net.NetWiFi ().IpAddress.ToString (); |
| | | btnIP.TextID = R.MyInternationalizationString.IPAddresses; |
| | | etIP.Text = ipAddressString; |
| | | bodyView.AddChidren (btnSeverTest); |
| | | |
| | | Button btnCloseSharing = new Button () { |
| | | X = Application.GetRealWidth (50), |
| | | Y = etIP.Bottom + Application.GetRealHeight (40), |
| | | Y = btnSeverTest.Bottom + Application.GetRealHeight (40), |
| | | Width = Application.GetRealWidth (400), |
| | | Height = Application.GetRealHeight (80), |
| | | SelectedBackgroundColor = SkinStyle.Current.ButtonColor, |
| | |
| | | Radius = 5, |
| | | BorderColor = SkinStyle.Current.Transparent, |
| | | BorderWidth = 2, |
| | | TextID = R.MyInternationalizationString.CloseDataSharing, |
| | | Text = "Close", |
| | | TextColor = SkinStyle.Current.DialogTextColor |
| | | }; |
| | | bodyView.AddChidren (btnCloseSharing); |
| | |
| | | }; |
| | | btnCloseSharing.MouseUpEventHandler += (sender2, e2) => { |
| | | btnCloseSharing.IsSelected = false; |
| | | CommonPage.CloseHttpListener (); |
| | | Room.InitAllRoom (); |
| | | 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 (); |
| | | } |
| | | } |
| | | } |