using System;
|
namespace Shared.SimpleControl.Phone
|
{
|
public class SystemMusicModel : FrameLayout
|
{
|
void UpdateOnePorWirelessFR (MusicModel musciModel)
|
{
|
byte [] bytes = new byte [51];
|
bytes [0] = musciModel.BigClass;
|
bytes [1] = musciModel.MinClass;
|
bytes [2] = musciModel.ChNumberCount;
|
string [] mac = musciModel.MAC.Split ('.');
|
for (int i = 0; i < mac.Length; i++)
|
bytes [i + 3] = Convert.ToByte (mac [i], 16);
|
//Remark需要解码
|
byte [] ddd = CommonPage.MyEncodingGB2312.GetBytes (musciModel.Name);
|
Array.Copy (ddd, 0, bytes, 11, 20 < ddd.Length ? 20 : ddd.Length);
|
string [] ipAddress = musciModel.IPAddress.Split ('.');
|
for (int i = 0; i < ipAddress.Length; i++)
|
bytes [i + 31] = byte.Parse (ipAddress [i]);
|
string [] r = musciModel.RouteIPAddress.Split ('.');
|
for (int i = 0; i < r.Length; i++)
|
bytes [i + 35] = byte.Parse (r [i]);
|
string [] ipMac = musciModel.IPMAC.Split ('.');
|
//ipMAC前三位HDL 需要特殊处理
|
bytes [0 + 39] = (byte)(ipMac [0].ToCharArray () [0]);
|
bytes [1 + 39] = (byte)(ipMac [1].ToCharArray () [0]);
|
bytes [2 + 39] = (byte)(ipMac [2].ToCharArray () [0]);
|
bytes [3 + 39] = byte.Parse (ipMac [3]);
|
bytes [4 + 39] = byte.Parse (ipMac [4]);
|
bytes [5 + 39] = byte.Parse (ipMac [5]);
|
string [] subnetMask = musciModel.SubnetMask.Split ('.');
|
for (int i = 0; i < subnetMask.Length; i++)
|
bytes [i + 45] = byte.Parse (subnetMask [i]);
|
//Control.ControlBytesSend (Command.SetBaseInfo,
|
// musciModel.SubnetID,
|
// musciModel.DeviceID,
|
// bytes);
|
|
//IO.FileUtils.SaveEquipmentMessage (musciModel);
|
}
|
|
public void ShowMusicModel (MusicModel musicModel)
|
{
|
VerticalScrolViewLayout sView = new VerticalScrolViewLayout (){
|
Height = Application.GetRealHeight (844),
|
};
|
AddChidren (sView);
|
#region ---------------title---------------
|
RowLayout frameLayout = new RowLayout () {
|
Height = Application.GetRealHeight (100),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
sView.AddChidren (frameLayout);
|
|
Button backButton = new Button () {
|
X = Application.GetRealWidth (0),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
backButton.MouseUpEventHandler += (sender, e) => {
|
(Parent as PageLayout).PageIndex -= 1;
|
//SystemMiddle.ShowGateWayView ();
|
};
|
frameLayout.AddChidren (backButton);
|
string strOnePortWirelessFRRemark = musicModel.Name.ToString ();
|
EditText textButton = new EditText () {
|
X = Application.GetRealWidth (11) + backButton.Right,
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (400),
|
Text = strOnePortWirelessFRRemark,
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = SkinStyle.Current.Transparent,
|
SelectedBackgroundColor = SkinStyle.Current.SysEditBox,
|
Enable = false,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
frameLayout.AddChidren (textButton);
|
|
Button editor = new Button () {
|
X = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (70),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
//editor.X = frameLayout.Width - editor.Width - Application.GetRealWidth (30);
|
frameLayout.AddChidren (editor);
|
editor.MouseUpEventHandler += (sender, e) => {//---------------修改Remark----------------
|
if (editor.IsSelected == true) {
|
MainPage.Loading.Start ();
|
musicModel.Name = textButton.Text.Trim ();
|
|
CommonPage.UpdateRemark (musicModel.SubnetID, musicModel.DeviceID, musicModel.Name);
|
IO.FileUtils.SaveEquipmentMessage (musicModel);
|
editor.IsSelected = false;
|
textButton.Enable = false;
|
textButton.IsSelected = false;
|
MainPage.Loading.Hide ();
|
System.Console.WriteLine ("OnePortWirelessFR Remark Update");
|
} else {
|
textButton.Enable = true;
|
textButton.IsSelected = true;
|
editor.IsSelected = true;
|
}
|
};
|
textButton.IsSelected = false;
|
textButton.Enable = false;
|
#endregion
|
|
#region GatewayID
|
RowLayout frameLayoutGatewayID = new RowLayout () {
|
Height = Application.GetRealHeight (98),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
sView.AddChidren (frameLayoutGatewayID);
|
|
Button gatewayIDText = new Button () {
|
X = Application.GetRealWidth (30),
|
Height = Application.GetRealHeight (49),
|
Width = Application.GetRealWidth (49),
|
UnSelectedImagePath = "Item/Wireless.png",
|
SelectedImagePath = "Item/WirelessSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
frameLayoutGatewayID.AddChidren (gatewayIDText);
|
Button gatewayIDName = new Button () {
|
X = Application.GetRealWidth (11) + gatewayIDText.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (150),
|
TextID = R.MyInternationalizationString.GatewayID,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
frameLayoutGatewayID.AddChidren (gatewayIDName);
|
EditText etGatewayID = new EditText () {
|
Height = Application.GetRealHeight (42),
|
Width = Application.GetRealWidth (62),
|
X = gatewayIDName.X + gatewayIDName.Width,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.Center,
|
Text = musicModel.SubnetID.ToString (),
|
SelectedBackgroundColor = SkinStyle.Current.SysEditBox,
|
BackgroundColor = SkinStyle.Current.Transparent,
|
Enable = false,
|
};
|
frameLayoutGatewayID.AddChidren (etGatewayID);
|
|
Button gatewayIDEdit = new Button () {
|
X = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (70),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
//gatewayIDEdit.X = frameLayout.Width - gatewayIDEdit.Width - Application.GetRealWidth (30);
|
#region 更改网关设备号
|
byte [] macAddress = Control.ControlBytesSendHasReturn (Command.ReadDeviceMac, musicModel.SubnetID, musicModel.DeviceID, new byte [] { });
|
gatewayIDEdit.MouseUpEventHandler += (sender, e) => {
|
if (macAddress == null) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
return;
|
}
|
if (etGatewayID.Enable) {
|
etGatewayID.Enable = etGatewayID.IsSelected = false;
|
byte [] Musics = new byte [10];
|
Array.Copy (macAddress, 0, Musics, 0, 8);
|
try {
|
Musics [8] = Convert.ToByte (Convert.ToInt32 (etGatewayID.Text.Trim ()));
|
if (Musics [8] < 0 || Musics [8] > 255) {
|
return;
|
}
|
} catch {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipPleaseEnterTheCorrectData), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
Control.ControlBytesSendHasReturn (Command.SetDeviceSubnetID, musicModel.SubnetID, musicModel.DeviceID, Musics);
|
|
musicModel.SubnetID = Musics [8];
|
UpdateOnePorWirelessFR (musicModel);
|
} else {
|
etGatewayID.IsSelected = etGatewayID.Enable = true;
|
}
|
};
|
#endregion
|
frameLayoutGatewayID.AddChidren (gatewayIDEdit);
|
#endregion
|
|
#region--------------NetWork----------------------
|
bool isMusicModu = musicModel.Type == DeviceType.MusicModel ? true : false;
|
RowLayout flNetWorkTop = new RowLayout () {
|
Height = Application.GetRealHeight (98),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
sView.AddChidren (flNetWorkTop);
|
|
Button netParameterSeleted = new Button () {
|
X = Application.GetRealWidth (30),
|
Height = Application.GetRealHeight (49),
|
Width = Application.GetRealWidth (49),
|
UnSelectedImagePath = "Item/NetParameter.png",
|
SelectedImagePath = "Item/NetParameterSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
flNetWorkTop.AddChidren (netParameterSeleted);
|
Button textButton1 = new Button () {
|
X = Application.GetRealWidth (11) + netParameterSeleted.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (300),
|
TextID = R.MyInternationalizationString.NetwordParameters,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
flNetWorkTop.AddChidren (textButton1);
|
Button btnNetWorkHelp = 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,
|
};
|
//btnNetWorkHelp.X = frameLayout.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);
|
//---------------------------------------------------------------------------------------------------------------------------------
|
FrameLayout frameLayout2 = new FrameLayout () {
|
Height = Application.GetRealHeight (798),
|
Width = LayoutParams.MatchParent,
|
};
|
sView.AddChidren (frameLayout2);
|
|
|
Button lblIPAddresses = new Button () {
|
X = gatewayIDName.X,
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (239),
|
TextID = R.MyInternationalizationString.IPAddresses,
|
Y = Application.GetRealHeight (10),
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
frameLayout2.AddChidren (lblIPAddresses);
|
|
EditText etIPAddresses = new EditText () {
|
X = gatewayIDName.X,
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (440),
|
Text = " " + musicModel.IPAddress,
|
BackgroundColor = SkinStyle.Current.SysEditBox,
|
SelectedImagePath = "Item/TextBoxSelected.png",
|
Y = lblIPAddresses.Bottom + Application.GetRealHeight (2),
|
Enable = isMusicModu,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
frameLayout2.AddChidren (etIPAddresses);
|
CommonPage.FindGatewayChilrenIPAddress = musicModel.IPAddress;
|
|
Button lblSubnetMask = new Button () {
|
X = gatewayIDName.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 = gatewayIDName.X,
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (440),
|
Text = " " + musicModel.SubnetMask,
|
BackgroundColor = SkinStyle.Current.SysEditBox,
|
SelectedImagePath = "Item/TextBoxSelected.png",
|
Y = lblSubnetMask.Bottom + Application.GetRealHeight (2),
|
Enable = isMusicModu,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
frameLayout2.AddChidren (etSubnetMask);
|
|
Button lblRoutingIP = new Button () {
|
X = gatewayIDName.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 = gatewayIDName.X,
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight (55),
|
Width = Application.GetRealWidth (440),
|
Text = " " + musicModel.RouteIPAddress,
|
BackgroundColor = SkinStyle.Current.SysEditBox,
|
SelectedImagePath = "Item/TextBoxSelectedd.png",
|
Y = lblRoutingIP.Bottom + Application.GetRealHeight (2),
|
Enable = isMusicModu,
|
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 (12),
|
Visible = isMusicModu
|
};
|
frameLayout2.AddChidren (btnDHCPSave);
|
frameLayout2.Height = btnDHCPSave.Bottom + Application.GetRealHeight (20);
|
|
|
btnDHCPSave.MouseUpEventHandler += (sender, e) => {
|
musicModel.IPAddress = etIPAddresses.Text.Trim ();
|
musicModel.SubnetMask = etSubnetMask.Text.Trim ();
|
musicModel.RouteIPAddress = etRoutingIP.Text.Trim ();
|
UpdateOnePorWirelessFR (musicModel);
|
};
|
|
#endregion
|
|
|
|
#region --------------bottom--------------
|
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);
|
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);
|
var gatewayInfo = Control.ControlBytesSendHasReturn (Command.ReadGateway, musicModel.SubnetID, musicModel.DeviceID, new byte [] { CommonPage.RandomHigh, CommonPage.RandomLow });
|
var deviceBytes = IO.FileUtils.ReadEquipmentMessage (musicModel);
|
var gatewayDevice1 = Newtonsoft.Json.JsonConvert.DeserializeObject<MusicModel> (deviceBytes);
|
if (gatewayDevice1 != null) {
|
Application.RunOnMainThread (() => {
|
this.ShowMusicModel (musicModel);
|
MainPage.Loading.Hide ();
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
sysBottomView.AddChidren (new Button () { Height = 1, BackgroundColor = SkinStyle.Current.White20Transparent });
|
#endregion
|
}
|
|
|
public void ControlMusicModel ()
|
{
|
//指定播放格式: *ZzzsLISTxxxyyya
|
byte [] musicDataBytes_read = System.Text.Encoding.ASCII.GetBytes ("S1PLAY");
|
}
|
}
|
}
|