using Shared.SimpleControl.Phone;
|
using System;
|
|
namespace Shared.SimpleControl.Pad
|
{
|
public class SystemOnePortBus
|
{
|
byte[] gatewayInfo;
|
void UpdateBaseInfo (OnePortBus gateway)
|
{
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ("Sending...");
|
});
|
if (gatewayInfo == null) {
|
CommonPage.RandomHigh = (byte)new Random ().Next (255);
|
CommonPage.RandomLow = (byte)new Random ().Next (255);
|
gatewayInfo = Control.ControlBytesSendHasReturn (Command.ReadGateway, gateway.SubnetID, gateway.DeviceID, new byte [] { CommonPage.RandomHigh, CommonPage.RandomLow });
|
}
|
if (gatewayInfo == null) {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip),
|
Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
return;
|
}
|
byte [] bytes = new byte [gatewayInfo.Length - 2];
|
Array.Copy (gatewayInfo, 2, bytes, 0, gatewayInfo.Length-2 );
|
//Remark需要解码
|
byte [] ddd = new byte [20];
|
byte [] ddd2 = CommonPage.MyEncodingGB2312.GetBytes (gateway.Name);
|
Array.Copy (ddd2, 0, ddd, 0, 20 < ddd2.Length ? 20 : ddd2.Length);
|
Array.Copy (ddd, 0, bytes, 11, 20 < ddd.Length ? 20 : ddd.Length);
|
string [] ipAddress = gateway.IPAddress.Split ('.');
|
for (int i = 0; i < ipAddress.Length; i++)
|
bytes [i + 31] = byte.Parse (ipAddress [i]);
|
string [] r = gateway.RouteIPAddress.Split ('.');
|
for (int i = 0; i < r.Length; i++)
|
bytes [i + 35] = byte.Parse (r [i]);
|
string [] subnetMask = gateway.SubnetMask.Split ('.');
|
for (int i = 0; i < subnetMask.Length; i++)
|
bytes [i + 45] = byte.Parse (subnetMask [i]);
|
bytes [49] = gateway.DHCP == true ? (byte)1 : (byte)0;
|
var reBytes = Control.ControlBytesSendHasReturn (Command.SetGateway, gateway.SubnetID, gateway.DeviceID, bytes);
|
if (reBytes == null) {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip),
|
Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
IO.FileUtils.SaveEquipmentMessage (gateway);
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip),
|
Language.StringByID (R.MyInternationalizationString.ThePerationWasSuccessful),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
}
|
|
public void ShowOnePortBus (OnePortBus gatewayDevice)
|
{
|
MainPage.Loading.Hide ();
|
|
if (!CommonPage.IsRemote) {
|
CommonPage.FindGatewayChilrenIPAddress = gatewayDevice.IPAddress;
|
}
|
#region title
|
SystemMiddle.SecondScrolView.RemoveAll ();
|
SystemMiddle.ThirdScrolView.RemoveAll ();
|
|
Button backButton = new Button () {
|
Height = Application.GetRealHeight (98),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Wireless.png",
|
SelectedImagePath = "Item/WirelessSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
SystemMiddle.SecondScrolView.TitleView.AddChidren (backButton);
|
string deviceRemark = gatewayDevice.Name.ToString ();
|
EditText textButton = new EditText () {
|
X = Application.GetRealWidth (95),
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (380),
|
Gravity = Gravity.CenterVertical,
|
Text = deviceRemark,
|
SelectedBackgroundColor = 0xFF000000,
|
UnSelectedImagePath = "Item/Transparent.png",
|
Enable = false,
|
};
|
SystemMiddle.SecondScrolView.TitleView.AddChidren (textButton);
|
|
Button editor = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (70),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
Gravity = Gravity.CenterVertical,
|
X = textButton.Right + Application.GetRealWidth (10),
|
};
|
SystemMiddle.SecondScrolView.TitleView.AddChidren (editor);
|
editor.MouseUpEventHandler += (sender, e) => {//---------------修改Remark----------------
|
if (editor.IsSelected == true) {
|
MainPage.Loading.Start ();
|
gatewayDevice.Name = textButton.Text.Trim ();
|
UpdateBaseInfo (gatewayDevice);
|
//CommonPage.UpdateRemark (gatewayDevice.SubnetID, gatewayDevice.DeviceID, gatewayDevice.Name);
|
//IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
editor.IsSelected = false;
|
textButton.Enable = false;
|
textButton.IsSelected = false;
|
MainPage.Loading.Hide ();
|
System.Console.WriteLine ("SystemOnePortBus Reamek Update");
|
} else {
|
textButton.Enable = true;
|
textButton.IsSelected = true;
|
editor.IsSelected = true;
|
}
|
};
|
|
|
|
Button btnRefresh = new Button () {
|
X = editor.Right + Application.GetRealWidth (10),
|
Height = Application.GetMinRealAverage (66),
|
Width = Application.GetMinRealAverage (66),
|
UnSelectedImagePath = "Item/Refresh.png",
|
SelectedImagePath = "Item/RefreshOn.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
SystemMiddle.SecondScrolView.TitleView.AddChidren (btnRefresh);
|
#endregion
|
|
#region GatewayID
|
FrameLayout frameLayoutGatewayID = new FrameLayout () {
|
Height = Application.GetRealHeight (131),
|
Width = LayoutParams.MatchParent,
|
};
|
SystemMiddle.SecondScrolView.AddChidren (frameLayoutGatewayID);
|
|
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,
|
};
|
frameLayoutGatewayID.AddChidren (gatewayIDText);
|
Button gatewayIDName = new Button () {
|
X = backButton.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (150),
|
TextID = R.MyInternationalizationString.GatewayID,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
frameLayoutGatewayID.AddChidren (gatewayIDName);
|
EditText etGatewayID = new EditText () {
|
Height = Application.GetRealHeight (52),
|
Width = Application.GetRealWidth (62),
|
X = gatewayIDName.Right,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.Center,
|
Text = gatewayDevice.SubnetID.ToString (),
|
SelectedBackgroundColor = 0xFF000000,
|
UnSelectedImagePath = "Item/Transparent.png",
|
Enable = false,
|
};
|
frameLayoutGatewayID.AddChidren (etGatewayID);
|
|
Button gatewayIDEdit = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (70),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
gatewayIDEdit.X = SystemMiddle.SecondScrolView.TitleView.Width - gatewayIDEdit.Width - Application.GetRealWidth (30);
|
#region 更改网关设备号
|
|
gatewayIDEdit.MouseUpEventHandler += (sender, e) => {
|
string [] macAddress = gatewayDevice.MAC.Split ('.');
|
if (etGatewayID.Enable) {
|
etGatewayID.Enable = etGatewayID.IsSelected = false;
|
byte [] Musics = new byte [10];
|
for (int i = 0; i < macAddress.Length; i++) {
|
Musics [i] = Convert.ToByte (macAddress [i], 16);
|
}
|
try {
|
Musics [8] = Convert.ToByte (Convert.ToInt32 (etGatewayID.Text.Trim ()));
|
if (Musics [8] < 0 || Musics [8] > 255) {
|
throw new Exception ();
|
}
|
} catch {
|
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, Musics);
|
foreach (string ss in IO.FileUtils.ReadFiles ()) {
|
if (ss.Contains ("Equipment_")) {
|
if (ss.Contains ("_" + Musics [8].ToString () + "_") || ss.Contains ("_" + gatewayDevice.SubnetID.ToString () + "_")) {
|
IO.FileUtils.DeleteFile (ss);
|
}
|
}
|
}
|
gatewayDevice.SubnetID = Musics [8];
|
UpdateBaseInfo (gatewayDevice);
|
} else {
|
etGatewayID.IsSelected = etGatewayID.Enable = true;
|
}
|
};
|
#endregion
|
frameLayoutGatewayID.AddChidren (gatewayIDEdit);
|
Button btnNul = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
frameLayoutGatewayID.AddChidren (btnNul);
|
Button btnNull = new Button () {
|
Y = Application.GetRealHeight (131) - 1,
|
Height = 1,
|
BackgroundColor = 0xFF2f2f2f,
|
};
|
frameLayoutGatewayID.AddChidren (btnNull);
|
#endregion
|
|
#region--------------NetWork--------------------------
|
FrameLayout flNetWorkTop = new FrameLayout () {
|
Height = Application.GetRealHeight (131),
|
Width = LayoutParams.MatchParent,
|
};
|
SystemMiddle.SecondScrolView.AddChidren (flNetWorkTop);
|
|
Button netParameterSeleted = new Button () {
|
X = Application.GetRealWidth (15),
|
Height = Application.GetRealHeight (66),
|
Width = Application.GetRealWidth (66),
|
UnSelectedImagePath = "Item/NetParameter.png",
|
SelectedImagePath = "Item/NetParameterSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
flNetWorkTop.AddChidren (netParameterSeleted);
|
Button textButton1 = new Button () {
|
X = backButton.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (300),
|
TextID = R.MyInternationalizationString.NetwordParameters,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
flNetWorkTop.AddChidren (textButton1);
|
Button btnNetWorkHelp = new Button () {
|
Height = Application.GetMinRealAverage (100),
|
Width = Application.GetMinRealAverage (76),
|
UnSelectedImagePath = "Item/Help.png",
|
SelectedImagePath = "Item/HelpSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
btnNetWorkHelp.X = SystemMiddle.SecondScrolView.TitleView.Width - btnNetWorkHelp.Width - Application.GetRealWidth (30);
|
btnNetWorkHelp.MouseUpEventHandler += (sender, e) => {
|
new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.HelpNetWork), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
|
};
|
flNetWorkTop.AddChidren (btnNetWorkHelp);
|
Button btnNul2 = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
flNetWorkTop.AddChidren (btnNul2);
|
Button btnNull2 = new Button () {
|
Y = Application.GetRealHeight (131) - 1,
|
Height = 1,
|
BackgroundColor = 0xFF2f2f2f,
|
};
|
flNetWorkTop.AddChidren (btnNull2);
|
|
//---------------------------------------------------------------------------------------------------------------------------------
|
EventHandler<MouseEventArgs> networkEHandler = new EventHandler<MouseEventArgs> (delegate (object senderea, MouseEventArgs eae) {
|
SystemMiddle.ThirdScrolView.RemoveAll ();
|
Button textButton12 = new Button () {
|
TextID = R.MyInternationalizationString.NetwordParameters,
|
TextAlignment = TextAlignment.Center
|
};
|
SystemMiddle.ThirdScrolView.TitleView.AddChidren (textButton12);
|
|
FrameLayout frameLayout2 = new FrameLayout ();
|
SystemMiddle.ThirdScrolView.AddChidren (frameLayout2);
|
|
Button btnDHCP = new Button () {
|
X = Application.GetRealWidth (100),
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (40),
|
Width = Application.GetRealWidth (360),
|
Text = "DHCP:",
|
Y = Application.GetRealHeight (20),
|
};
|
frameLayout2.AddChidren (btnDHCP);
|
Button btnDHCPCheck = new Button () {
|
Height = Application.GetMinRealAverage (98),
|
Width = Application.GetMinRealAverage (76),
|
UnSelectedImagePath = "Item/Check.png",
|
SelectedImagePath = "Item/CheckSelected.png",
|
Y = Application.GetRealHeight (20),
|
IsSelected = gatewayDevice.DHCP,
|
};
|
btnDHCPCheck.X = SystemMiddle.SecondScrolView.TitleView.Width - btnDHCPCheck.Width - Application.GetRealWidth (98);
|
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),
|
};
|
frameLayout2.AddChidren (lblIPAddresses);
|
|
EditText etIPAddresses = new EditText () {
|
X = btnDHCP.X,
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (440),
|
Text = " " + gatewayDevice.IPAddress,
|
BackgroundColor = 0xFF000000,
|
Y = lblIPAddresses.Bottom + Application.GetRealHeight (2),
|
};
|
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),
|
};
|
frameLayout2.AddChidren (lblSubnetMask);
|
|
EditText etSubnetMask = new EditText () {
|
X = btnDHCP.X,
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (440),
|
Text = " " + gatewayDevice.SubnetMask,
|
BackgroundColor = 0xFF000000,
|
Y = lblSubnetMask.Bottom + Application.GetRealHeight (2),
|
};
|
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),
|
};
|
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 = 0xFF000000,
|
Y = lblRoutingIP.Bottom + Application.GetRealHeight (2),
|
};
|
frameLayout2.AddChidren (etRoutingIP);
|
|
|
Button btnDHCPSave = new Button () {
|
X = (Application.CurrentWidth / 2 - 30),
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (100),
|
BackgroundColor = 0xFF333333,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
TextID = R.MyInternationalizationString.SAVE,
|
Y = etRoutingIP.Bottom + Application.GetRealHeight (10),
|
};
|
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 ();
|
}
|
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;
|
}
|
});
|
textButton1.MouseUpEventHandler += networkEHandler;
|
flNetWorkTop.MouseUpEventHandler += networkEHandler;
|
#endregion
|
|
#region--------------RemoteAccess---------------------
|
FrameLayout flRemoteAccessTop = new FrameLayout () {
|
Height = Application.GetRealHeight (131),
|
Width = LayoutParams.MatchParent,
|
};
|
SystemMiddle.SecondScrolView.AddChidren (flRemoteAccessTop);
|
|
Button RemoteAccessSeleted = new Button () {
|
X = Application.GetRealWidth (15),
|
Height = Application.GetRealHeight (66),
|
Width = Application.GetRealWidth (66),
|
UnSelectedImagePath = "Item/RemoteAccess.png",
|
SelectedImagePath = "Item/RemoteAccessSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
flRemoteAccessTop.AddChidren (RemoteAccessSeleted);
|
Button lblRemoteAccesss = new Button () {
|
X = Application.GetRealWidth (11) + RemoteAccessSeleted.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (200),
|
TextID = R.MyInternationalizationString.RemoteAccess,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
flRemoteAccessTop.AddChidren (lblRemoteAccesss);
|
Button btnRemoteAccessHelp = new Button () {
|
Height = Application.GetMinRealAverage (98),
|
Width = Application.GetMinRealAverage (76),
|
UnSelectedImagePath = "Item/Help.png",
|
SelectedImagePath = "Item/HelpSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
btnRemoteAccessHelp.X = flRemoteAccessTop.Width - btnRemoteAccessHelp.Width - Application.GetRealWidth (30);
|
flRemoteAccessTop.AddChidren (btnRemoteAccessHelp);
|
btnRemoteAccessHelp.MouseUpEventHandler += (sender, e) => {
|
new Tip () { MaxWidth = 150, Text = Language.StringByID (R.MyInternationalizationString.HelpRemoteAccess), Direction = AMPopTipDirection.Down, CloseTime = 4 }.Show ((View)sender);
|
};
|
|
Button btnNul3 = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
flRemoteAccessTop.AddChidren (btnNul3);
|
Button btnNull3 = new Button () {
|
Y = Application.GetRealHeight (131) - 1,
|
Height = 1,
|
BackgroundColor = 0xFF2f2f2f,
|
};
|
flRemoteAccessTop.AddChidren (btnNull3);
|
|
//---------------------------------------------------------------------------------------------------------------------------------
|
|
EventHandler<MouseEventArgs> RemoteAccessBodyEHandler = new EventHandler<MouseEventArgs> (delegate (object senderea, MouseEventArgs eae) {
|
SystemMiddle.ThirdScrolView.RemoveAll ();
|
|
Button lblRemoteAccesss2 = new Button () {
|
TextID = R.MyInternationalizationString.RemoteAccess,
|
TextAlignment = TextAlignment.Center,
|
};
|
SystemMiddle.ThirdScrolView.TitleView.AddChidren (lblRemoteAccesss2);
|
Button btnRemoteAccessCheck = new Button () {
|
Height = Application.GetMinRealAverage (98),
|
Width = Application.GetMinRealAverage (76),
|
UnSelectedImagePath = "Item/Check.png",
|
SelectedImagePath = "Item/CheckSelected.png",
|
Y = btnRemoteAccessHelp.Y,
|
X = Application.GetRealWidth (500),
|
};
|
SystemMiddle.ThirdScrolView.TitleView.AddChidren (btnRemoteAccessCheck);
|
|
|
FrameLayout flRemoteAccessBody = new FrameLayout () {
|
Height = Application.GetRealHeight (0),
|
Width = LayoutParams.MatchParent,
|
};
|
SystemMiddle.ThirdScrolView.AddChidren (flRemoteAccessBody);
|
Button btnGroupName = new Button () {
|
X = gatewayIDName.X,
|
Y = Application.GetRealHeight (20),
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (49),
|
Width = Application.GetRealWidth (360),
|
TextID = R.MyInternationalizationString.GroupName,
|
};
|
flRemoteAccessBody.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 = 0xFF000000,
|
};
|
flRemoteAccessBody.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),
|
};
|
flRemoteAccessBody.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 = 0xFF000000,
|
};
|
flRemoteAccessBody.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),
|
};
|
flRemoteAccessBody.AddChidren (lblUsername);
|
//---------------------------------------------------------------------------------------------------------------------------------
|
|
EditText etUserName = new EditText () {
|
X = lblProjectName.X,
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (440),
|
BackgroundColor = 0xFF000000,
|
Y = lblUsername.Bottom + Application.GetRealHeight (2),
|
};
|
flRemoteAccessBody.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,
|
};
|
flRemoteAccessBody.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 = 0xFF000000,
|
};
|
flRemoteAccessBody.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,
|
};
|
flRemoteAccessBody.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 = 0xFF000000,
|
};
|
flRemoteAccessBody.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 = 0xFF000000,
|
};
|
flRemoteAccessBody.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,
|
};
|
flRemoteAccessBody.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),
|
SelectedBackgroundColor = 0xFF000000,
|
BackgroundColor = 0xFF000000,
|
};
|
flRemoteAccessBody.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 = 0xFF000000,
|
};
|
flRemoteAccessBody.AddChidren (etAlternativeServerIPPoint);
|
|
//-------------------------------------------------------------------------------------------
|
Button btnGatewaySave = new Button () {
|
X = (Application.CurrentWidth / 2 - 30),
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (100),
|
BackgroundColor = 0xFF333333,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
TextID = R.MyInternationalizationString.SAVE,
|
Y = etAlternativeServerIP.Bottom + Application.GetRealHeight (20),
|
};
|
flRemoteAccessBody.AddChidren (btnGatewaySave);
|
flRemoteAccessBody.Height = btnGatewaySave.Bottom + Application.GetRealHeight (20);
|
|
System.Threading.Tasks.Task.Run (() => {
|
var gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDevice.SubnetID, gatewayDevice.DeviceID, new byte [] { });
|
var 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];
|
//string gatewayGroupName = CommonPage.MyEncodingGB2312.GetString(gatewayBytes,1,20).Trim('\0');
|
//string gatewayProjectName = CommonPage.MyEncodingGB2312.GetString(gatewayBytes,21,20).Trim('\0');
|
//string gatewayUserName = CommonPage.MyEncodingGB2312.GetString(gatewayBytes,41,8).Trim('\0');
|
//string gatewayPassWord = CommonPage.MyEncodingGB2312.GetString(gatewayBytes,49,8).Trim('\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) {
|
flRemoteAccessBody.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 {
|
flRemoteAccessBody.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;
|
etAlternativeServerIP.Text = serverIP2;
|
etAlternativeServerIPPoint.Text = serverIP2Point == "0" ? "9999" : serverIP2Point;
|
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;
|
|
IO.FileUtils.SaveEquipmentMessage (gatewayDevice);
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.ThePerationWasSuccessful), Language.StringByID (R.MyInternationalizationString.Confrim)).Show ();
|
try {
|
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);
|
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ("Sending...");
|
});
|
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 (MainPage.SeviceIP), 9999),
|
Command = Command.SendRemoteInfoToServer,
|
SubnetID = 255,
|
DeviceID = 255,
|
AddData = gatewayBytes,
|
}, 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 ();
|
return;
|
});
|
} 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 ();
|
return;
|
});
|
}
|
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);
|
|
string [] strServerIP = etServerIP.Text.Split ('.');
|
string [] strServerIP1 = etAlternativeServerIP.Text.Split ('.');
|
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 (etServerIPPoint.Text, 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 (etAlternativeServerIPPoint.Text, 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 ();
|
return;
|
});
|
}
|
} catch {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipPleaseEnterTheCorrectData), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
};
|
#endregion
|
|
if (model == 0) {
|
flRemoteAccessBody.Height = Application.GetRealHeight (0);
|
btnRemoteAccessCheck.IsSelected = false;
|
} else {
|
flRemoteAccessBody.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;
|
}
|
});
|
}
|
});
|
});
|
lblRemoteAccesss.MouseUpEventHandler += RemoteAccessBodyEHandler;
|
flRemoteAccessTop.MouseUpEventHandler += RemoteAccessBodyEHandler;
|
#endregion
|
|
#region 分配地址
|
FrameLayout flDistributionMACTop = new FrameLayout () {
|
Height = Application.GetRealHeight (131),
|
Width = LayoutParams.MatchParent,
|
};
|
SystemMiddle.SecondScrolView.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,
|
};
|
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);
|
};
|
|
Button btnNul41 = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
flDistributionMACTop.AddChidren (btnNul41);
|
Button btnNull41 = new Button () {
|
Y = Application.GetRealHeight (131) - 1,
|
Height = 1,
|
BackgroundColor = 0xFF2f2f2f,
|
};
|
flDistributionMACTop.AddChidren (btnNull41);
|
#endregion
|
|
#region ----Add a connection to the Gateway List-----
|
FrameLayout flSearchEquipmentTop = new FrameLayout () {
|
Height = Application.GetRealHeight (131),
|
Width = LayoutParams.MatchParent,
|
};
|
SystemMiddle.SecondScrolView.AddChidren (flSearchEquipmentTop);
|
Button btnGatewayMappingIcon = new Button () {
|
X = Application.GetRealWidth (17),
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (55),
|
UnSelectedImagePath = "Item/+.png",
|
SelectedImagePath = "Item/+Selected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
flSearchEquipmentTop.AddChidren (btnGatewayMappingIcon);
|
|
Button btnGatewayMappingText = new Button () {
|
X = backButton.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (400),
|
TextID = R.MyInternationalizationString.GatewayList,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
flSearchEquipmentTop.AddChidren (btnGatewayMappingText);
|
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);
|
};
|
flSearchEquipmentTop.AddChidren (btnGatewayMappingHelp);
|
|
|
|
Button btnNul42 = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
flSearchEquipmentTop.AddChidren (btnNul42);
|
Button btnNull42 = new Button () {
|
Y = Application.GetRealHeight (131) - 1,
|
Height = 1,
|
BackgroundColor = 0xFF2f2f2f,
|
};
|
flSearchEquipmentTop.AddChidren (btnNull42);
|
|
btnGatewayMappingText.MouseUpEventHandler += (sender, e) => {
|
|
SystemWirelessGateway.UpdataGatewayList (gatewayDevice.SubnetID);
|
};
|
btnGatewayMappingIcon.MouseUpEventHandler += (sender, e) => {
|
|
SystemWirelessGateway.UpdataGatewayList (gatewayDevice.SubnetID);
|
};
|
|
#endregion
|
//},true);
|
|
// 刷新当前一端口交换机
|
btnRefresh.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 one = IO.FileUtils.ReadEquipmentMessage (gatewayDevice);
|
gatewayDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortBus> (one);
|
Application.RunOnMainThread (() => {
|
this.ShowOnePortBus (gatewayDevice);
|
});
|
});
|
};
|
}
|
/// <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);
|
}
|
}
|
}
|