//using System;
|
|
//namespace Shared.SimpleControl.Phone
|
//{
|
// public class SysGatewayBasePage : FrameLayout
|
// {
|
// public override void RemoveFromParent ()
|
// {
|
// SystemMiddle.curGatewayMAC = "";
|
// SystemMiddle.curGatewayIP = "";
|
// base.RemoveFromParent ();
|
// }
|
|
// public void ShowOnePortBus (GatewayBase gatewayDevice)
|
// {
|
// byte [] gatewayInfo;
|
// if (!CommonPage.IsRemote) {
|
// CommonPage.FindGatewayChilrenIPAddress = gatewayDevice.IPAddress;
|
// }
|
// System.Threading.Tasks.Task.Run (() => {
|
// gatewayInfo = Control.ControlBytesSendHasReturn (Command.ReadGateway, gatewayDevice.SubnetID, gatewayDevice.DeviceID, new byte [] { CommonPage.RandomHigh, CommonPage.RandomLow });
|
// });
|
|
// SystemMiddle.curGatewayMAC = gatewayDevice.MAC;
|
// SystemMiddle.curGatewayIP = gatewayDevice.IPAddress;
|
|
// FrameLayout topView = new FrameLayout () {
|
// Height = Application.GetRealHeight (126),
|
// };
|
// AddChidren (topView);
|
|
// Button btnBack = new Button () {
|
// Y = Application.GetRealHeight (35),
|
// Height = Application.GetRealHeight (90),
|
// Width = Application.GetRealWidth (85),
|
// UnSelectedImagePath = "Item/Back.png",
|
// SelectedImagePath = "Item/BackSelected.png",
|
// };
|
|
// topView.AddChidren (btnBack);
|
// btnBack.MouseUpEventHandler += (sender, e) => {
|
// (Parent as PageLayout).PageIndex -= 1;
|
// };
|
|
// Button btnPageTitle = new Button () {
|
// Width = Application.GetRealWidth (400),
|
// Height = Application.GetMinReal (90),
|
// Text = gatewayDevice.Name,// = UserConfig.Instance.CurrentRegion.RegionName,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// Gravity = Gravity.CenterHorizontal,
|
// TextAlignment = TextAlignment.Center,
|
// Y = Application.GetRealHeight (30),
|
// TextSize = 20,
|
// };
|
// topView.AddChidren (btnPageTitle);
|
|
// var logo = new Button () {
|
// X = Application.GetRealWidth (640 - 70 - 30),
|
// Height = Application.GetRealHeight (90),
|
// Width = Application.GetRealWidth (70),
|
// UnSelectedImagePath = "Item/Editor.png",
|
// SelectedImagePath = "Item/EditorSelected.png",
|
// Gravity = Gravity.CenterVertical,
|
// };
|
// topView.AddChidren (logo);
|
// #region statusView
|
// RowLayout statusView = new RowLayout () {
|
// Height = Application.GetRealHeight (100),
|
// Width = LayoutParams.MatchParent,
|
// BackgroundColor = SkinStyle.Current.MainColor
|
// };
|
// AddChidren (statusView);
|
|
|
// Button btnStatusText = new Button () {
|
// X = Application.GetRealWidth(60),
|
// Width = Application.GetRealWidth(400),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// Text = "当前状态",
|
// };
|
// statusView.AddChidren (btnStatusText);
|
|
// Button btnStatus = new Button () {
|
// X = btnStatusText.Right,
|
// Width = Application.GetRealWidth(180),
|
// Text = "Online",
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.OnlineColor,
|
// };
|
// statusView.AddChidren (btnStatus);
|
|
// #endregion
|
|
|
// #region GatewayID
|
// RowLayout gatewayIdView = new RowLayout () {
|
// Y = statusView.Bottom,
|
// Height = Application.GetRealHeight (110),
|
// Width = LayoutParams.MatchParent,
|
// BackgroundColor = SkinStyle.Current.MainColor
|
// };
|
// AddChidren (gatewayIdView);
|
|
// Button gatewayIDText = new Button () {
|
// X = Application.GetRealWidth (15),
|
// Height = Application.GetRealHeight (66),
|
// Width = Application.GetRealWidth (66),
|
// UnSelectedImagePath = "Item/OnePort.png",
|
// SelectedImagePath = "Item/OnePortSelected.png",
|
// Gravity = Gravity.CenterVertical,
|
// };
|
// gatewayIdView.AddChidren (gatewayIDText);
|
// Button gatewayIDName = new Button () {
|
// X = Application.GetRealWidth (60),
|
// Width = Application.GetRealWidth (400),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// TextID = R.MyInternationalizationString.GatewayID,
|
// Gravity = Gravity.CenterVertical,
|
// };
|
// gatewayIdView.AddChidren (gatewayIDName);
|
// Button btnGatewayId = new Button () {
|
// X = btnStatusText.Right,
|
// Width = Application.GetRealWidth (180),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.OnlineColor,
|
// Text = gatewayDevice.SubnetID.ToString (),
|
// };
|
// gatewayIdView.AddChidren (btnGatewayId);
|
|
// EventHandler<MouseEventArgs> editGatewayId = (sender, e) => {
|
// var dgGatewayId = new Dialog ();
|
|
// FrameLayout dgGatewayIdView = new FrameLayout () {
|
// Width = Application.GetRealWidth (400),
|
// Height = Application.GetRealHeight (270 + 100),
|
// Gravity = Gravity.Center,
|
// Radius = 5,
|
// BorderColor = SkinStyle.Current.Transparent,
|
// BorderWidth = 0,
|
// BackgroundColor = SkinStyle.Current.DialogColor,
|
// };
|
// dgGatewayId.AddChidren (dgGatewayIdView);
|
|
|
// Button btnTitle = new Button () {
|
// Height = Application.GetRealHeight (80),
|
// BackgroundColor = SkinStyle.Current.DialogTitle,
|
// TextID = R.MyInternationalizationString.GatewayID,
|
// TextColor = SkinStyle.Current.DialogTextColor,
|
// TextAlignment = TextAlignment.Center,
|
// };
|
// dgGatewayIdView.AddChidren (btnTitle);
|
|
|
// EditText etGatewayId = new EditText () {
|
// Gravity = Gravity.Center,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (300),
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// TextAlignment = TextAlignment.Center,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor
|
// };
|
// dgGatewayIdView.AddChidren (etGatewayId);
|
|
// FrameLayout dgGatewayBottomView = new FrameLayout () {
|
// Y = Application.GetRealHeight (270 + 20),
|
// Height = Application.GetRealHeight (83),
|
// BackgroundColor = SkinStyle.Current.LineColor,
|
// };
|
// dgGatewayIdView.AddChidren (dgGatewayBottomView);
|
|
// Button btnCancel = new Button () {
|
// Width = Application.GetRealWidth (200),
|
// BackgroundColor = SkinStyle.Current.DialogTitle,
|
// TextID = R.MyInternationalizationString.cancel,
|
// TextAlignment = TextAlignment.Center,
|
// };
|
// dgGatewayBottomView.AddChidren (btnCancel);
|
// btnCancel.MouseUpEventHandler += (ssd, de) => {
|
// dgGatewayId.Close ();
|
// };
|
|
// Button btnConfrim = new Button () {
|
// X = btnCancel.Right + 1,
|
// Width = Application.GetRealWidth (200),
|
// BackgroundColor = SkinStyle.Current.DialogTitle,
|
// TextID = R.MyInternationalizationString.Confrim,
|
// TextAlignment = TextAlignment.Center,
|
// };
|
// dgGatewayBottomView.AddChidren (btnConfrim);
|
|
// btnConfrim.MouseUpEventHandler += (sende2r, e2) => {
|
// string [] macAddress = gatewayDevice.MAC.Split ('.');
|
// byte [] setDeviceSubnetIdBytes = new byte [10];
|
// for (int i = 0; i < macAddress.Length; i++) {
|
// setDeviceSubnetIdBytes [i] = Convert.ToByte (macAddress [i], 16);
|
// }
|
// setDeviceSubnetIdBytes [8] = Convert.ToByte (Convert.ToInt32 (btnGatewayId.Text.Trim ()));
|
// if (setDeviceSubnetIdBytes [8] < 0 || setDeviceSubnetIdBytes [8] > 255) {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipPleaseEnterTheCorrectData), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// return;
|
// }
|
|
// Control.ControlBytesSend (Command.SetDeviceSubnetID, gatewayDevice.SubnetID, gatewayDevice.DeviceID, setDeviceSubnetIdBytes);
|
// foreach (string ss in IO.FileUtils.ReadFiles ()) {
|
// if (ss.Contains ("Equipment_")) {
|
// if (ss.Contains ("_" + setDeviceSubnetIdBytes [8].ToString () + "_") || ss.Contains ("_" + gatewayDevice.SubnetID.ToString () + "_")) {
|
// IO.FileUtils.DeleteFile (ss);
|
// }
|
// }
|
// }
|
// gatewayDevice.SubnetID = setDeviceSubnetIdBytes [8];
|
// };
|
// dgGatewayId.Show ();
|
// };
|
// #endregion
|
|
// #region--------------NetWork--------------------------
|
// RowLayout networkRow = new RowLayout () {
|
// Y = gatewayIdView.Bottom,
|
// Height = Application.GetRealHeight (110),
|
// Width = LayoutParams.MatchParent,
|
// BackgroundColor = SkinStyle.Current.MainColor
|
// };
|
// AddChidren (networkRow);
|
|
|
// Button btnNetwork = new Button () {
|
// X = Application.GetRealWidth(60),
|
// Width = Application.GetRealWidth (300),
|
// TextID = R.MyInternationalizationString.NetwordParameters,
|
// Gravity = Gravity.CenterVertical,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// networkRow.AddChidren (btnNetwork);
|
// Button btnNetWorkHelp = new Button () {
|
// Height = Application.GetMinRealAverage (100),
|
// Width = Application.GetMinRealAverage (76),
|
// UnSelectedImagePath = "Item/Help.png",
|
// SelectedImagePath = "Item/HelpSelected.png",
|
// Gravity = Gravity.CenterVertical,
|
// X = Application.GetRealWidth(540),
|
// };
|
// btnNetWorkHelp.MouseUpEventHandler += (sender, e) => {
|
// new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.HelpNetWork), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
|
// };
|
// networkRow.AddChidren (btnNetWorkHelp);
|
|
// btnNetwork.MouseUpEventHandler += (senderNet, eNet) => {
|
// var dgNetwork = new Dialog ();
|
// var frameLayout2 = new FrameLayout () {
|
// Height = Application.GetRealHeight (798),
|
// Width = Application.GetRealWidth (600),
|
// Gravity = Gravity.Center,
|
// Radius = 5,
|
// BorderColor = SkinStyle.Current.Transparent,
|
// BorderWidth = 0,
|
// BackgroundColor = SkinStyle.Current.DialogColor,
|
// };
|
// dgNetwork.AddChidren (frameLayout2);
|
// Button btnDHCP = new Button () {
|
// X = Application.GetRealWidth (100),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (60),
|
// Width = Application.GetRealWidth (360),
|
// Text = "DHCP:",
|
// Y = Application.GetRealHeight (20),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (btnDHCP);
|
// Button btnDHCPCheck = new Button () {
|
// X = Application.GetRealWidth (640 - 176),
|
// Height = Application.GetMinRealAverage (98),
|
// Width = Application.GetMinRealAverage (76),
|
// UnSelectedImagePath = "Item/Check.png",
|
// SelectedImagePath = "Item/CheckSelected.png",
|
// IsSelected = gatewayDevice.DHCP,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (btnDHCPCheck);
|
|
// Button lblIPAddresses = new Button () {
|
// X = Application.GetRealWidth (100),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (239),
|
// TextID = R.MyInternationalizationString.IPAddresses,
|
// Y = btnDHCP.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (lblIPAddresses);
|
|
// EditText etIPAddresses = new EditText () {
|
// X = btnDHCP.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// Text = " " + gatewayDevice.IPAddress,
|
// Y = lblIPAddresses.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// };
|
// frameLayout2.AddChidren (etIPAddresses);
|
// CommonPage.FindGatewayChilrenIPAddress = gatewayDevice.IPAddress;
|
|
// Button lblSubnetMask = new Button () {
|
// X = btnDHCP.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// TextID = R.MyInternationalizationString.SubnetMask,
|
// Y = etIPAddresses.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (lblSubnetMask);
|
|
// EditText etSubnetMask = new EditText () {
|
// X = btnDHCP.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// Text = " " + gatewayDevice.SubnetMask,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// Y = lblSubnetMask.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (etSubnetMask);
|
|
// Button lblRoutingIP = new Button () {
|
// X = btnDHCP.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// TextID = R.MyInternationalizationString.RoutingIP,
|
// Y = etSubnetMask.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (lblRoutingIP);
|
|
// EditText etRoutingIP = new EditText () {
|
// X = btnDHCP.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// Text = " " + gatewayDevice.RouteIPAddress,
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// Y = lblRoutingIP.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (etRoutingIP);
|
|
// Button btnDHCPSave = new Button () {
|
// X = (Application.CurrentWidth / 2 - 30),
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (100),
|
// BackgroundColor = SkinStyle.Current.ButtonColor,
|
// SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// BorderColor = SkinStyle.Current.Transparent,
|
// TextID = R.MyInternationalizationString.SAVE,
|
// Y = etRoutingIP.Bottom + Application.GetRealHeight (10),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// frameLayout2.AddChidren (btnDHCPSave);
|
// frameLayout2.Height = btnDHCPSave.Bottom + Application.GetRealHeight (20);
|
|
// btnDHCPCheck.MouseUpEventHandler += (sender, e) => {
|
// if (btnDHCPCheck.IsSelected) {
|
// btnDHCPCheck.IsSelected = false;
|
// etIPAddresses.Enable = etSubnetMask.Enable = etRoutingIP.Enable = true;
|
// btnDHCPSave.Visible = true;
|
// } else {
|
// btnDHCPCheck.IsSelected = true;
|
// etIPAddresses.Enable = etSubnetMask.Enable = etRoutingIP.Enable = false;
|
// btnDHCPSave.Visible = false;
|
// }
|
// //gatewayDevice.IPAddress = etIPAddresses.Text.Trim ();
|
// //gatewayDevice.SubnetMask = etSubnetMask.Text.Trim ();
|
// //gatewayDevice.RouteIPAddress = etRoutingIP.Text.Trim ();
|
// gatewayDevice.DHCP = btnDHCPCheck.IsSelected;
|
// try {
|
// byte [] bytes = new byte [21];
|
// bytes [20] = gatewayDevice.DHCP == true ? (byte)1 : (byte)0;
|
// System.Net.IPAddress address;
|
// if (System.Net.IPAddress.TryParse (gatewayDevice.IPAddress, out address)) {
|
// string [] ipAddress = gatewayDevice.IPAddress.Split ('.');
|
// for (int i = 0; i < ipAddress.Length; i++) {
|
// bytes [i] = byte.Parse (ipAddress [i]);
|
// }
|
// } else {
|
// throw new Exception ();
|
// }
|
|
// if (System.Net.IPAddress.TryParse (gatewayDevice.RouteIPAddress, out address)) {
|
// string [] r = gatewayDevice.RouteIPAddress.Split ('.');
|
// for (int i = 0; i < r.Length; i++) {
|
// bytes [i + 4] = byte.Parse (r [i]);
|
// }
|
// } else {
|
// throw new Exception ();
|
// }
|
// string [] ipMac = gatewayDevice.IPMAC.Split ('.');
|
// //ipMAC前三位HDL 需要特殊处理
|
// bytes [0 + 8] = (byte)(ipMac [0].ToCharArray () [0]);
|
// bytes [1 + 8] = (byte)(ipMac [1].ToCharArray () [0]);
|
// bytes [2 + 8] = (byte)(ipMac [2].ToCharArray () [0]);
|
// bytes [3 + 8] = byte.Parse (ipMac [3]);
|
// bytes [4 + 8] = byte.Parse (ipMac [4]);
|
// bytes [5 + 8] = byte.Parse (ipMac [5]);
|
// string [] subnetMask = gatewayDevice.SubnetMask.Split ('.');
|
// bytes [14] = 0x17;
|
// bytes [15] = 0x70;
|
// for (int i = 0; i < subnetMask.Length; i++) {
|
// bytes [i + 16] = byte.Parse (subnetMask [i]);
|
// }
|
// if (Control.ControlBytesSendHasReturn (Command.UpdateGatewayIp,
|
// gatewayDevice.SubnetID, gatewayDevice.DeviceID, bytes) != null) {
|
// IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
// }
|
// //UpdateBaseInfo (gatewayDevice);
|
// } catch {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipPleaseEnterTheCorrectData), Language.StringByID (R.MyInternationalizationString.Confrim)).Show ();
|
// }
|
// };
|
// btnDHCPSave.MouseUpEventHandler += (sender, e) => {
|
// gatewayDevice.IPAddress = etIPAddresses.Text.Trim ();
|
// gatewayDevice.SubnetMask = etSubnetMask.Text.Trim ();
|
// gatewayDevice.RouteIPAddress = etRoutingIP.Text.Trim ();
|
// gatewayDevice.DHCP = btnDHCPCheck.IsSelected;
|
// try {
|
// byte [] bytes = new byte [21];
|
// bytes [20] = gatewayDevice.DHCP == true ? (byte)1 : (byte)0;
|
// System.Net.IPAddress address;
|
// if (System.Net.IPAddress.TryParse (gatewayDevice.IPAddress, out address)) {
|
// string [] ipAddress = gatewayDevice.IPAddress.Split ('.');
|
// for (int i = 0; i < ipAddress.Length; i++) {
|
// bytes [i] = byte.Parse (ipAddress [i]);
|
// }
|
// } else {
|
// throw new Exception ();
|
// }
|
// if (System.Net.IPAddress.TryParse (gatewayDevice.RouteIPAddress, out address)) {
|
// string [] r = gatewayDevice.RouteIPAddress.Split ('.');
|
// for (int i = 0; i < r.Length; i++) {
|
// bytes [i + 4] = byte.Parse (r [i]);
|
// }
|
// } else {
|
// throw new Exception ();
|
// }
|
// string [] ipMac = gatewayDevice.IPMAC.Split ('.');
|
// //ipMAC前三位HDL 需要特殊处理
|
// bytes [0 + 8] = (byte)(ipMac [0].ToCharArray () [0]);
|
// bytes [1 + 8] = (byte)(ipMac [1].ToCharArray () [0]);
|
// bytes [2 + 8] = (byte)(ipMac [2].ToCharArray () [0]);
|
// bytes [3 + 8] = byte.Parse (ipMac [3]);
|
// bytes [4 + 8] = byte.Parse (ipMac [4]);
|
// bytes [5 + 8] = byte.Parse (ipMac [5]);
|
// string [] subnetMask = gatewayDevice.SubnetMask.Split ('.');
|
// bytes [14] = 0x17;
|
// bytes [15] = 0x70;
|
// for (int i = 0; i < subnetMask.Length; i++) {
|
// bytes [i + 16] = byte.Parse (subnetMask [i]);
|
// }
|
// if (Control.ControlBytesSendHasReturn (Command.UpdateGatewayIp,
|
// gatewayDevice.SubnetID, gatewayDevice.DeviceID, bytes) != null) {
|
// IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
// }
|
// //UpdateBaseInfo (gatewayDevice);
|
// } catch {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipPleaseEnterTheCorrectData), Language.StringByID (R.MyInternationalizationString.Confrim)).Show ();
|
// }
|
// };
|
// if (gatewayDevice.DHCP) {
|
// btnDHCPCheck.IsSelected = true;
|
// etIPAddresses.Enable = etSubnetMask.Enable = etRoutingIP.Enable = false;
|
// btnDHCPSave.Visible = false;
|
// } else {
|
// btnDHCPCheck.IsSelected = false;
|
// etIPAddresses.Enable = etSubnetMask.Enable = etRoutingIP.Enable = true;
|
// btnDHCPSave.Visible = true;
|
// }
|
// };
|
// #endregion
|
|
// #region--------------RemoteAccess---------------------
|
// RowLayout remoteAccessRow = new RowLayout () {
|
// Y = networkRow.Bottom,
|
// Height = Application.GetRealHeight (110),
|
// Width = LayoutParams.MatchParent,
|
// BackgroundColor = SkinStyle.Current.MainColor
|
// };
|
// AddChidren (remoteAccessRow);
|
|
|
// Button btnRemoteAccesss = new Button () {
|
// X = Application.GetRealWidth (60),
|
// Width = Application.GetRealWidth (300),
|
// TextID = R.MyInternationalizationString.RemoteAccess,
|
// Gravity = Gravity.CenterVertical,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessRow.AddChidren (btnRemoteAccesss);
|
// Button btnRemoteAccessHelp = new Button () {
|
// X = Application.GetRealWidth (540),
|
// Height = Application.GetMinRealAverage (98),
|
// Width = Application.GetMinRealAverage (76),
|
// UnSelectedImagePath = "Item/Help.png",
|
// SelectedImagePath = "Item/HelpSelected.png",
|
// Gravity = Gravity.CenterVertical,
|
// };
|
// remoteAccessRow.AddChidren (btnRemoteAccessHelp);
|
// Button btnRemoteAccessCheck = new Button () {
|
// Height = Application.GetMinRealAverage (98),
|
// Width = Application.GetMinRealAverage (76),
|
// UnSelectedImagePath = "Item/Check.png",
|
// SelectedImagePath = "Item/CheckSelected.png",
|
// Y = btnRemoteAccessHelp.Y,
|
// };
|
// btnRemoteAccessCheck.X = remoteAccessRow.Width - btnRemoteAccessCheck.Width - Application.GetRealWidth (100);
|
// btnRemoteAccessHelp.MouseUpEventHandler += (sender, e) => {
|
// new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.HelpRemoteAccess), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
|
// };
|
// remoteAccessRow.AddChidren (btnRemoteAccessCheck);
|
|
// btnRemoteAccesss.MouseUpEventHandler += (senderRomote, eRomote) => {
|
// var dgRemote = new Dialog ();
|
// FrameLayout remoteAccessBodyView = new FrameLayout () {
|
// Height = Application.GetRealHeight (900),
|
// Width = Application.GetRealWidth(600),
|
// Gravity = Gravity.Center,
|
// Radius = 5,
|
// BorderColor = SkinStyle.Current.Transparent,
|
// BorderWidth = 0,
|
// BackgroundColor = SkinStyle.Current.DialogColor,
|
// };
|
// dgRemote.AddChidren (remoteAccessBodyView);
|
|
// FrameLayout flRemoteAutoSetting = new FrameLayout () {
|
// Height = Application.GetRealHeight (90),
|
// };
|
// remoteAccessBodyView.AddChidren (flRemoteAutoSetting);
|
|
// Button btnRemoteAutoCheck = new Button () {
|
// Gravity = Gravity.Center,
|
// Width = Application.GetRealWidth (300),
|
// Height = Application.GetRealHeight (60),
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// SelectedTextColor = SkinStyle.Current.TextColor1,
|
// TextID = R.MyInternationalizationString.AutomaticSetting,
|
// TextAlignment = TextAlignment.Center,
|
// };
|
// flRemoteAutoSetting.AddChidren (btnRemoteAutoCheck);
|
|
|
// Button btnGroupName = new Button () {
|
// X = gatewayIDName.X,
|
// Y = flRemoteAutoSetting.Bottom + Application.GetRealHeight (20),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (49),
|
// Width = Application.GetRealWidth (360),
|
// TextID = R.MyInternationalizationString.GroupName,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (btnGroupName);
|
|
// EditText etGroupName = new EditText () {
|
// X = gatewayIDName.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// Y = btnGroupName.Bottom + Application.GetRealHeight (2),
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etGroupName);
|
|
// Button lblProjectName = new Button () {
|
// X = gatewayIDName.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (40),
|
// Width = Application.GetRealWidth (360),
|
// TextID = R.MyInternationalizationString.ProjectName,
|
// Y = etGroupName.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (lblProjectName);
|
|
// EditText etProjectName = new EditText () {
|
// X = gatewayIDName.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// Y = lblProjectName.Bottom + Application.GetRealHeight (2),
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etProjectName);
|
|
// Button lblUsername = new Button () {
|
// X = lblProjectName.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// TextID = R.MyInternationalizationString.UserName,
|
// Y = etProjectName.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (lblUsername);
|
|
// EditText etUserName = new EditText () {
|
// X = lblProjectName.X,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// Y = lblUsername.Bottom + Application.GetRealHeight (2),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etUserName);
|
|
// Button btnGatewayPassword = new Button () {
|
// X = lblProjectName.X,
|
// Y = etUserName.Bottom + Application.GetRealHeight (2),
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// TextID = R.MyInternationalizationString.PassWrod,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (btnGatewayPassword);
|
|
// EditText etGatewayPassWrod = new EditText () {
|
// X = lblProjectName.X,
|
// Y = btnGatewayPassword.Bottom + Application.GetRealHeight (2),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// Text = gatewayDevice.Password,
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etGatewayPassWrod);
|
|
// Button btnServerIP = new Button () {
|
// X = lblProjectName.X,
|
// Y = etGatewayPassWrod.Bottom + Application.GetRealHeight (2),
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// TextID = R.MyInternationalizationString.ServerIP,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (btnServerIP);
|
|
// EditText etServerIP = new EditText () {
|
// X = lblProjectName.X,
|
// Y = btnServerIP.Bottom + Application.GetRealHeight (2),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (300),
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etServerIP);
|
|
// EditText etServerIPPoint = new EditText () {
|
// X = etServerIP.Right + 2,
|
// Y = etServerIP.Y,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (140) - 2,
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etServerIPPoint);
|
|
// Button btnAlternativeServerIP = new Button () {
|
// X = lblProjectName.X,
|
// Y = etServerIP.Bottom + Application.GetRealHeight (2),
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (440),
|
// TextID = R.MyInternationalizationString.AlternativeServerIP,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (btnAlternativeServerIP);
|
|
// EditText etAlternativeServerIP = new EditText () {
|
// X = lblProjectName.X,
|
// Y = btnAlternativeServerIP.Bottom + Application.GetRealHeight (2),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (300),
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etAlternativeServerIP);
|
// EditText etAlternativeServerIPPoint = new EditText () {
|
// X = etAlternativeServerIP.Right + 2,
|
// Y = etAlternativeServerIP.Y,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (140) - 2,
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (etAlternativeServerIPPoint);
|
|
// Button btnGatewaySave = new Button () {
|
// X = (Application.CurrentWidth / 2 - 30),
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (100),
|
// BackgroundColor = SkinStyle.Current.ButtonColor,
|
// SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// BorderColor = SkinStyle.Current.Transparent,
|
// TextID = R.MyInternationalizationString.SAVE,
|
// Y = etAlternativeServerIP.Bottom + Application.GetRealHeight (20),
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// remoteAccessBodyView.AddChidren (btnGatewaySave);
|
// remoteAccessBodyView.Height = btnGatewaySave.Bottom + Application.GetRealHeight (20);
|
// byte [] gatewayBytes = null;
|
// byte [] serverIPBytes = null;
|
// System.Threading.Tasks.Task.Run (() => {
|
// gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, new byte [] { });
|
// serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, gatewayDevice.SubnetID, gatewayDevice.DeviceID, new byte [] { });
|
// IO.FileUtils.WriteFileByBytes ("Remote_GatewayBytes_" + gatewayDevice.Name + "_" + gatewayDevice.SubnetID, gatewayBytes);
|
// if (gatewayBytes != null && serverIPBytes != null) {
|
// Application.RunOnMainThread (() => {
|
// #region ---读取、设置组名工程名---
|
// int model = gatewayBytes [0];
|
// gatewayDevice.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 1, 20).Trim ('\0');
|
// gatewayDevice.Remote_ProjectName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 21, 20).Trim ('\0');
|
// gatewayDevice.Remote_UserName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 41, 8).Trim ('\0');
|
// gatewayDevice.Remote_Password = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 49, 8).Trim ('\0');
|
// IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
|
// etGroupName.Text = gatewayDevice.Remote_GroupName;
|
// etProjectName.Text = gatewayDevice.Remote_ProjectName;
|
// etUserName.Text = gatewayDevice.Remote_UserName;
|
// etGatewayPassWrod.Text = gatewayDevice.Remote_Password;
|
|
// btnRemoteAccessCheck.MouseUpEventHandler += (sender, e) => {
|
// if (!btnRemoteAccessCheck.IsSelected) {
|
// remoteAccessBodyView.Height = btnGatewaySave.Bottom + Application.GetRealHeight (20);
|
// btnRemoteAccessCheck.IsSelected = true;
|
// gatewayDevice.RometoMode = gatewayBytes [0] = 2;
|
// Control.ControlBytesSend (Command.SetGateWayModelInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, gatewayBytes);
|
// UserConfig.Instance.RemoteModeFile = "Equipment_" + gatewayDevice.Type.ToString () + "_" + gatewayDevice.SubnetID.ToString () + "_" + gatewayDevice.DeviceID.ToString ();
|
// UserConfig.Instance.SaveUserConfig ();
|
// } else {
|
// remoteAccessBodyView.Height = Application.GetRealHeight (0);
|
// btnRemoteAccessCheck.IsSelected = false;
|
// gatewayDevice.RometoMode = gatewayBytes [0] = 0;
|
// Control.ControlBytesSend (Command.SetGateWayModelInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, gatewayBytes);
|
// UserConfig.Instance.RemoteModeFile = "";
|
// UserConfig.Instance.SaveUserConfig ();
|
// }
|
// IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
// };
|
// #endregion
|
// #region ---读取、设置 网关IP地址参数---
|
// string serverIP1 = serverIPBytes [0].ToString () + "." + serverIPBytes [1].ToString () + "." +
|
// serverIPBytes [2].ToString () + "." + serverIPBytes [3].ToString ();
|
// string serverIP1Point = ((serverIPBytes [4] * 256) + serverIPBytes [5]).ToString ();
|
// string serverIP2 = serverIPBytes [6].ToString () + "." + serverIPBytes [7].ToString () + "." +
|
// serverIPBytes [8].ToString () + "." + serverIPBytes [9].ToString ();
|
// string serverIP2Point = ((serverIPBytes [10] * 256) + serverIPBytes [11]).ToString ();
|
// etServerIP.Text = serverIP1;
|
// etServerIPPoint.Text = serverIP1Point == "0" ? "9999" : serverIP1Point;
|
// serverIP1Point = etServerIPPoint.Text;
|
// etAlternativeServerIP.Text = serverIP2;
|
// etAlternativeServerIPPoint.Text = serverIP2Point == "0" ? "9999" : serverIP2Point;
|
// serverIP2Point = etAlternativeServerIPPoint.Text;
|
// btnGatewaySave.MouseUpEventHandler += (sender, e) => {
|
// gatewayDevice.Remote_GroupName = etGroupName.Text.Trim ();// "james";//gatewayGroupName;
|
// gatewayDevice.Remote_ProjectName = etProjectName.Text.Trim ();//"myhome";//gatewayProjectName;
|
// gatewayDevice.Remote_UserName = etUserName.Text.Trim ();//"james";//gatewayUserName;
|
// gatewayDevice.Remote_Password = etGatewayPassWrod.Text.Trim ();//"chy1125";//gatewayPassWord;
|
|
// string [] strServerIP = etServerIP.Text.Split ('.');
|
// string [] strServerIP1 = etAlternativeServerIP.Text.Split ('.');
|
// IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
// System.Threading.Tasks.Task.Run (() => {
|
// try {
|
// Application.RunOnMainThread (() => {
|
// MainPage.Loading.Start ("Sending...");
|
// });
|
// byte [] ggn = new byte [20];
|
// byte [] b1 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_GroupName);
|
// Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length);
|
|
// byte [] gpn = new byte [20];
|
// byte [] b2 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_ProjectName);
|
// Array.Copy (b2, 0, gpn, 0, 20 < b2.Length ? 20 : b2.Length);
|
|
// byte [] gun = new byte [8];
|
// byte [] b3 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_UserName);
|
// Array.Copy (b3, 0, gun, 0, 8 < b3.Length ? 8 : b3.Length);
|
|
// byte [] gpw = new byte [8];
|
// byte [] b4 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_Password);
|
// Array.Copy (b4, 0, gpw, 0, 8 < b4.Length ? 8 : b4.Length);
|
|
|
// byte [] macAddress = Control.ControlBytesSendHasReturn (Command.ReadDeviceMac, gatewayDevice.SubnetID, gatewayDevice.DeviceID, new byte [] { });
|
// byte [] sendServerBytes = new byte [56];
|
// Array.Copy (gpn, 0, sendServerBytes, 0, 20 < gpn.Length ? 20 : gpn.Length);
|
// Array.Copy (ggn, 0, sendServerBytes, 20, 20 < ggn.Length ? 20 : ggn.Length);
|
// Array.Copy (gun, 0, sendServerBytes, 40, 8 < gun.Length ? 8 : gun.Length);
|
// Array.Copy (macAddress, 0, sendServerBytes, 48, 8 < macAddress.Length ? 8 : macAddress.Length);
|
// Control control = new Control ();
|
// control.Send (new Target () {
|
// IPEndPoint = new System.Net.IPEndPoint (System.Net.IPAddress.Parse ("115.29.251.24"), 9999),
|
// Command = Command.SendRemoteInfoToServer,
|
// SubnetID = 251,
|
// DeviceID = 251,
|
// AddData = sendServerBytes,
|
// }, SendCount.Three, true);
|
// var serverResult = control.UsefulBytes;
|
// if (serverResult == null || serverResult [0] == 0) {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.OperationFailed),
|
// Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// });
|
// //} else if (serverResult [0] == 2) {
|
// //Application.RunOnMainThread (() => {
|
// // new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.HaveTheSame),
|
// // Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// //});
|
// } else {
|
// Array.Copy (ggn, 0, gatewayBytes, 1, 20 < ggn.Length ? 20 : ggn.Length);
|
// Array.Copy (gpn, 0, gatewayBytes, 21, 20 < gpn.Length ? 20 : gpn.Length);
|
// Array.Copy (gun, 0, gatewayBytes, 41, 8 < gun.Length ? 8 : gun.Length);
|
// Array.Copy (gpw, 0, gatewayBytes, 49, 8 < gpw.Length ? 8 : gpw.Length);
|
|
// Control.ControlBytesSend (Command.SetGateWayModelInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, gatewayBytes);
|
|
// if (strServerIP.Length != 4 || strServerIP1.Length != 4) {
|
// throw new Exception ();
|
// } else {
|
// serverIPBytes [0] = Convert.ToByte (strServerIP [0]);
|
// serverIPBytes [1] = Convert.ToByte (strServerIP [1]);
|
// serverIPBytes [2] = Convert.ToByte (strServerIP [2]);
|
// serverIPBytes [3] = Convert.ToByte (strServerIP [3]);
|
// int point1 = 9999;
|
// if (!int.TryParse (serverIP1Point, out point1)) {
|
// point1 = 9999;
|
// }
|
// serverIPBytes [4] = Convert.ToByte (point1 / 256);
|
// serverIPBytes [5] = Convert.ToByte (point1 % 256);
|
|
// serverIPBytes [6] = Convert.ToByte (strServerIP1 [0]);
|
// serverIPBytes [7] = Convert.ToByte (strServerIP1 [1]);
|
// serverIPBytes [8] = Convert.ToByte (strServerIP1 [2]);
|
// serverIPBytes [9] = Convert.ToByte (strServerIP1 [3]); int point2 = 9999;
|
// if (!int.TryParse (serverIP2Point, out point2)) {
|
// point2 = 9999;
|
// }
|
// serverIPBytes [10] = Convert.ToByte (point2 / 256);
|
// serverIPBytes [11] = Convert.ToByte (point2 % 256);
|
// }
|
// //远程ip地址的设置
|
// var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, serverIPBytes);
|
// if (mobytes == null || mobytes [0] == 0xF5) {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.OperationFailed),
|
// Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// });
|
// } else {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.ThePerationWasSuccessful), Language.StringByID (R.MyInternationalizationString.Confrim)).Show ();
|
// });
|
// }
|
// }
|
// } catch {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipPleaseEnterTheCorrectData), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// });
|
// } finally {
|
// Application.RunOnMainThread (() => {
|
// MainPage.Loading.Hide ();
|
// });
|
// }
|
// });
|
// };
|
// #endregion
|
|
// if (model == 0) {
|
// remoteAccessBodyView.Height = Application.GetRealHeight (0);
|
// btnRemoteAccessCheck.IsSelected = false;
|
// } else {
|
// remoteAccessBodyView.Height = btnGatewaySave.Bottom + Application.GetRealHeight (20);
|
// btnRemoteAccessCheck.IsSelected = true;
|
// UserConfig.Instance.RemoteModeFile = "Equipment_" + gatewayDevice.Type.ToString () + "_" + gatewayDevice.SubnetID.ToString () + "_" + gatewayDevice.DeviceID.ToString ();
|
// UserConfig.Instance.SaveUserConfig ();
|
// gatewayBytes [0] = 2;
|
// }
|
// });
|
// }
|
// });
|
|
// btnRemoteAutoCheck.MouseUpEventHandler += (sender, e) => {
|
// var dialogRemoteAuto = new Dialog ();
|
|
// FrameLayout remoteAutoView = new FrameLayout () {
|
// Width = Application.GetRealWidth (400),
|
// Height = Application.GetRealHeight (270 + 100),
|
// Gravity = Gravity.Center,
|
// Radius = 5,
|
// BorderColor = SkinStyle.Current.Transparent,
|
// BorderWidth = 0,
|
// BackgroundColor = SkinStyle.Current.DialogColor,
|
// };
|
// dialogRemoteAuto.AddChidren (remoteAutoView);
|
|
|
// Button remoteAutoTitle = new Button () {
|
// Height = Application.GetRealHeight (80),
|
// BackgroundColor = SkinStyle.Current.DialogTitle,
|
// TextID = R.MyInternationalizationString.RemotePassword,
|
// TextColor = SkinStyle.Current.DialogTextColor,
|
// TextAlignment = TextAlignment.Center,
|
// };
|
// remoteAutoView.AddChidren (remoteAutoTitle);
|
|
|
// EditText etRemoteAutoPW = new EditText () {
|
// Gravity = Gravity.Center,
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (300),
|
// //BackgroundColor = SkinStyle.Current.SysEditBox,
|
// BorderColor = SkinStyle.Current.BorderColor,
|
// TextAlignment = TextAlignment.Center,
|
// BorderWidth = 1,
|
// Radius = 5,
|
// TextColor = SkinStyle.Current.TextColor
|
// };
|
// remoteAutoView.AddChidren (etRemoteAutoPW);
|
|
// FrameLayout remoteAutoBottom = new FrameLayout () {
|
// Y = Application.GetRealHeight (270 + 20),
|
// Height = Application.GetRealHeight (83),
|
// BackgroundColor = SkinStyle.Current.LineColor,
|
// };
|
// remoteAutoView.AddChidren (remoteAutoBottom);
|
|
// Button btnCancel = new Button () {
|
// Width = Application.GetRealWidth (200),
|
// BackgroundColor = SkinStyle.Current.DialogTitle,
|
// TextID = R.MyInternationalizationString.cancel,
|
// TextAlignment = TextAlignment.Center,
|
// };
|
// remoteAutoBottom.AddChidren (btnCancel);
|
// btnCancel.MouseUpEventHandler += (ssd, de) => {
|
// dialogRemoteAuto.Close ();
|
// };
|
|
// Button btnConfrim = new Button () {
|
// X = btnCancel.Right + 1,
|
// Width = Application.GetRealWidth (200),
|
// BackgroundColor = SkinStyle.Current.DialogTitle,
|
// TextID = R.MyInternationalizationString.Confrim,
|
// TextAlignment = TextAlignment.Center,
|
// };
|
// remoteAutoBottom.AddChidren (btnConfrim);
|
|
// btnConfrim.MouseUpEventHandler += (ssd, de) => {
|
// if (etRemoteAutoPW.Text.Trim ().Length < 6) {
|
// new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PasswordLenghtTip), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show (etRemoteAutoPW);
|
// return;
|
// }
|
|
// gatewayDevice.Remote_GroupName = etGroupName.Text = UserConfig.Instance.CurrentRegion.RegionName;
|
// gatewayDevice.Remote_ProjectName = etProjectName.Text = UserConfig.Instance.CurrentRegion.RegionName;
|
// gatewayDevice.Remote_UserName = etUserName.Text = "Admin";
|
// gatewayDevice.Remote_Password = etGatewayPassWrod.Text = etRemoteAutoPW.Text.Trim ();
|
|
// string [] strServerIP = ("115.29.251.24").Split ('.');
|
// string [] strServerIP1 = ("115.29.251.24").Split ('.');
|
// System.Threading.Tasks.Task.Run (() => {
|
// try {
|
// Application.RunOnMainThread (() => {
|
// MainPage.Loading.Start ("Sending...");
|
// });
|
// byte [] ggn = new byte [20];
|
// byte [] b1 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_GroupName);
|
// Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length);
|
|
// byte [] gpn = new byte [20];
|
// byte [] b2 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_ProjectName);
|
// Array.Copy (b2, 0, gpn, 0, 20 < b2.Length ? 20 : b2.Length);
|
|
// byte [] gun = new byte [8];
|
// byte [] b3 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_UserName);
|
// Array.Copy (b3, 0, gun, 0, 8 < b3.Length ? 8 : b3.Length);
|
|
// byte [] gpw = new byte [8];
|
// byte [] b4 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDevice.Remote_Password);
|
// Array.Copy (b4, 0, gpw, 0, 8 < b4.Length ? 8 : b4.Length);
|
|
|
// byte [] macAddress = Control.ControlBytesSendHasReturn (Command.ReadDeviceMac, gatewayDevice.SubnetID, gatewayDevice.DeviceID, new byte [] { });
|
// byte [] sendServerBytes = new byte [56];
|
// Array.Copy (gpn, 0, sendServerBytes, 0, 20 < gpn.Length ? 20 : gpn.Length);
|
// Array.Copy (ggn, 0, sendServerBytes, 20, 20 < ggn.Length ? 20 : ggn.Length);
|
// Array.Copy (gun, 0, sendServerBytes, 40, 8 < gun.Length ? 8 : gun.Length);
|
// Array.Copy (macAddress, 0, sendServerBytes, 48, 8 < macAddress.Length ? 8 : macAddress.Length);
|
// Control control = new Control ();
|
// control.Send (new Target () {
|
// IPEndPoint = new System.Net.IPEndPoint (System.Net.IPAddress.Parse ("115.29.251.24"), 9999),
|
// Command = Command.SendRemoteInfoToServer,
|
// SubnetID = 251,
|
// DeviceID = 251,
|
// AddData = sendServerBytes,
|
// }, SendCount.Three, true);
|
// var serverResult = control.UsefulBytes;
|
// if (serverResult == null || serverResult [0] == 0) {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.OperationFailed),
|
// Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// });
|
// } else {
|
// Array.Copy (ggn, 0, gatewayBytes, 1, 20 < ggn.Length ? 20 : ggn.Length);
|
// Array.Copy (gpn, 0, gatewayBytes, 21, 20 < gpn.Length ? 20 : gpn.Length);
|
// Array.Copy (gun, 0, gatewayBytes, 41, 8 < gun.Length ? 8 : gun.Length);
|
// Array.Copy (gpw, 0, gatewayBytes, 49, 8 < gpw.Length ? 8 : gpw.Length);
|
|
// Control.ControlBytesSend (Command.SetGateWayModelInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, gatewayBytes);
|
|
// if (strServerIP.Length != 4 || strServerIP1.Length != 4) {
|
// throw new Exception ();
|
// } else {
|
// serverIPBytes [0] = Convert.ToByte (strServerIP [0]);
|
// serverIPBytes [1] = Convert.ToByte (strServerIP [1]);
|
// serverIPBytes [2] = Convert.ToByte (strServerIP [2]);
|
// serverIPBytes [3] = Convert.ToByte (strServerIP [3]);
|
// int point1 = 9999;
|
|
// serverIPBytes [4] = Convert.ToByte (point1 / 256);
|
// serverIPBytes [5] = Convert.ToByte (point1 % 256);
|
|
// serverIPBytes [6] = Convert.ToByte (strServerIP1 [0]);
|
// serverIPBytes [7] = Convert.ToByte (strServerIP1 [1]);
|
// serverIPBytes [8] = Convert.ToByte (strServerIP1 [2]);
|
// serverIPBytes [9] = Convert.ToByte (strServerIP1 [3]);
|
// int point2 = 9999;
|
|
// serverIPBytes [10] = Convert.ToByte (point2 / 256);
|
// serverIPBytes [11] = Convert.ToByte (point2 % 256);
|
// }
|
// //远程ip地址的设置
|
// var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, serverIPBytes);
|
// if (mobytes == null || mobytes [0] == 0xF5) {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.OperationFailed),
|
// Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// });
|
// } else {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.ThePerationWasSuccessful), Language.StringByID (R.MyInternationalizationString.Confrim)).Show ();
|
// IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
// dialogRemoteAuto.Close ();
|
// });
|
// }
|
// }
|
// } catch {
|
// Application.RunOnMainThread (() => {
|
// new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipPleaseEnterTheCorrectData), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
// });
|
// } finally {
|
// Application.RunOnMainThread (() => {
|
// MainPage.Loading.Hide ();
|
// });
|
// }
|
// });
|
// };
|
|
// dialogRemoteAuto.Show ();
|
// };
|
|
// #endregion
|
|
// #region 分配地址
|
// RowLayout flDistributionMACTop = new RowLayout () {
|
// Height = Application.GetRealHeight (100),
|
// Width = LayoutParams.MatchParent,
|
// BackgroundColor = SkinStyle.Current.MainColor
|
// };
|
// sView.AddChidren (flDistributionMACTop);
|
// Button btnMACIcon = new Button () {
|
// X = Application.GetRealWidth (15),
|
// Height = Application.GetMinRealAverage (66),
|
// Width = Application.GetMinRealAverage (66),
|
// UnSelectedImagePath = "Item/RedistributionAddress.png",
|
// SelectedImagePath = "Item/RedistributionAddressSelected.png",
|
// Gravity = Gravity.CenterVertical,
|
// };
|
// flDistributionMACTop.AddChidren (btnMACIcon);
|
// Button btnMACText = new Button () {
|
// X = backButton.Right,
|
// Height = Application.GetRealHeight (41),
|
// Width = Application.GetRealWidth (400),
|
// TextID = R.MyInternationalizationString.DistributionOfDeviceAddress,
|
// Gravity = Gravity.CenterVertical,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// flDistributionMACTop.AddChidren (btnMACText);
|
// btnMACText.MouseUpEventHandler += (sender, e) => {
|
// ShowAssignedAddressDialog (gatewayDevice.SubnetID, gatewayDevice.DeviceID);
|
// };
|
// btnMACIcon.MouseUpEventHandler += (sender, e) => {
|
// ShowAssignedAddressDialog (gatewayDevice.SubnetID, gatewayDevice.DeviceID);
|
// };
|
// Button btnDistributionMACHelp = new Button () {
|
// Height = Application.GetMinRealAverage (98),
|
// Width = Application.GetMinRealAverage (76),
|
// UnSelectedImagePath = "Item/Help.png",
|
// SelectedImagePath = "Item/HelpSelected.png",
|
// Gravity = Gravity.CenterVertical,
|
// X = btnNetWorkHelp.X,
|
// };
|
// flDistributionMACTop.AddChidren (btnDistributionMACHelp);
|
// btnDistributionMACHelp.MouseUpEventHandler += (sender, e) => {
|
// new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.SearchEquipmentHelp), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
|
// };
|
// #endregion
|
|
// #region ----Add a connection to the Gateway List-----
|
// RowLayout flGatewayMapping = new RowLayout () {
|
// Height = Application.GetRealHeight (100),
|
// Width = LayoutParams.MatchParent,
|
// BackgroundColor = SkinStyle.Current.MainColor
|
// };
|
// sView.AddChidren (flGatewayMapping);
|
// Button btnGatewayMappingAdd = new Button () {
|
// X = Application.GetRealWidth (17),
|
// Height = Application.GetRealHeight (55),
|
// Width = Application.GetRealWidth (55),
|
// UnSelectedImagePath = "Item/+.png",
|
// SelectedImagePath = "Item/+Selected.png",
|
// Gravity = Gravity.CenterVertical,
|
// };
|
// flGatewayMapping.AddChidren (btnGatewayMappingAdd);
|
|
// Button rpMappingAdd = new Button () {
|
// X = backButton.Right,
|
// Height = Application.GetRealHeight (41),
|
// Width = Application.GetRealWidth (400),
|
// TextID = R.MyInternationalizationString.GatewayList,
|
// Gravity = Gravity.CenterVertical,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1
|
// };
|
// flGatewayMapping.AddChidren (rpMappingAdd);
|
// Button btnGatewayMappingHelp = new Button () {
|
// Height = Application.GetMinRealAverage (100),
|
// Width = Application.GetMinRealAverage (76),
|
// UnSelectedImagePath = "Item/Help.png",
|
// SelectedImagePath = "Item/HelpSelected.png",
|
// Gravity = Gravity.CenterVertical,
|
// X = btnNetWorkHelp.X,
|
// };
|
// btnGatewayMappingHelp.MouseUpEventHandler += (sender, e) => {
|
// new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.DistributionMACHelp), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
|
// };
|
// flGatewayMapping.AddChidren (btnGatewayMappingHelp);
|
|
// FrameLayout flGatewayMapping4 = new FrameLayout () {
|
// Height = Application.GetRealHeight (60),
|
// Width = LayoutParams.MatchParent,
|
// };
|
|
// EventHandler<MouseEventArgs> handler = (sender, e) => {
|
// SystemWirelessGateway.UpdataGatewayList (btnGatewayMappingHelp.X, flGatewayMapping4, gatewayDevice.MAC);
|
// };
|
// btnGatewayMappingAdd.MouseUpEventHandler += handler;
|
// rpMappingAdd.MouseUpEventHandler += handler;
|
|
// sView.AddChidren (flGatewayMapping4);
|
// #endregion
|
|
// // 刷新当前一端口交换机
|
// var sysBottomView = new FrameLayout () {
|
// Height = Application.GetRealHeight (90),
|
// Y = Application.GetRealHeight (844)
|
// };
|
// AddChidren (sysBottomView);
|
|
// Button AddSystemEquipmentButton = new Button () {
|
// Width = LayoutParams.MatchParent,
|
// Height = LayoutParams.MatchParent,
|
// TextID = R.MyInternationalizationString.ReFresh,
|
// TextAlignment = TextAlignment.Center,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// BackgroundColor = SkinStyle.Current.MainColor
|
// };
|
// sysBottomView.AddChidren (AddSystemEquipmentButton);
|
// sysBottomView.AddChidren (new Button () { Height = 1, BackgroundColor = SkinStyle.Current.White20Transparent });
|
// AddSystemEquipmentButton.MouseUpEventHandler += (sender, e) => {
|
// MainPage.Loading.Start ();
|
// System.Threading.Tasks.Task.Run (() => {
|
// CommonPage.GateWayList.Clear ();
|
// CommonPage.RandomHigh = (byte)new Random ().Next (255);
|
// CommonPage.RandomLow = (byte)new Random ().Next (255);
|
// gatewayInfo = Control.ControlBytesSendHasReturn (Command.ReadGateway, gatewayDevice.SubnetID, gatewayDevice.DeviceID, new byte [] { CommonPage.RandomHigh, CommonPage.RandomLow });
|
// var deviceBytes = IO.FileUtils.ReadEquipmentMessage (gatewayDevice);
|
// var gatewayDevice1 = Newtonsoft.Json.JsonConvert.DeserializeObject<GatewayBase> (deviceBytes);
|
// if (gatewayDevice1 != null) {
|
// Application.RunOnMainThread (() => {
|
// this.ShowOnePortBus (gatewayDevice1);
|
// });
|
// } else {
|
// Application.RunOnMainThread (() => {
|
// MainPage.Loading.Hide ();
|
// });
|
// }
|
// });
|
// };
|
// }
|
// });
|
// });
|
// }
|
// /// <summary>
|
// /// 弹出确认分配设备地址的窗口
|
// /// </summary>
|
// /// <param name="subnetID">Subnet I.</param>
|
// /// <param name="deviceID">Device I.</param>
|
// static void ShowAssignedAddressDialog (byte subnetID, byte deviceID)
|
// {
|
// SystemWirelessGateway.ShowAssignedAddressDialog (subnetID, deviceID);
|
// }
|
// }
|
//}
|