using Shared.SimpleControl.Phone;
|
using System;
|
using System.Collections.Generic;
|
|
namespace Shared.SimpleControl.Pad
|
{
|
/// <summary>
|
/// 自定义控件,为了不修改已经做好的节目,优化体验
|
/// 固定titleview
|
/// 内容view 可以滑动
|
/// </summary>
|
public class NK_FrameLayout : FrameLayout {
|
public FrameLayout TitleView;
|
public VerticalScrolViewLayout VerticalScrolView;
|
int nk_height;
|
public NK_FrameLayout (int NK_Height)
|
{
|
Width = Application.GetRealWidth (646);
|
Height = Application.GetRealHeight (NK_Height);
|
BackgroundColor = 0xFF2f2f2f;
|
nk_height = NK_Height;
|
|
TitleView = new FrameLayout () {
|
Height = Application.GetRealHeight (140),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = 0xFF333333,
|
};
|
base.AddChidren (TitleView);
|
|
VerticalScrolView = new VerticalScrolViewLayout () {
|
Y = Application.GetRealHeight(140),
|
Height = Application.GetRealHeight(NK_Height) - Application.GetRealHeight (140),
|
};
|
base.AddChidren (VerticalScrolView);
|
}
|
|
public void HideTopView () {
|
TitleView.Height = 0;
|
VerticalScrolView.Y = 0;
|
VerticalScrolView.Height = Application.GetRealHeight (nk_height);
|
}
|
|
public override void AddChidren (View view)
|
{
|
VerticalScrolView.AddChidren (view);
|
}
|
|
public void VerticalScrolViewScrolUnEnable () {
|
VerticalScrolView.ScrollEnabled = false;
|
}
|
|
public override void RemoveAll ()
|
{
|
base.RemoveAll ();
|
VerticalScrolView.ScrollEnabled = true;
|
Width = Application.GetRealWidth (646);
|
BackgroundColor = 0xFF2f2f2f;
|
|
TitleView = new FrameLayout () {
|
Height = Application.GetRealHeight (140),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = 0xFF333333,
|
};
|
base.AddChidren (TitleView);
|
|
VerticalScrolView = new VerticalScrolViewLayout () {
|
Y = Application.GetRealHeight (140),
|
Height = Application.GetRealHeight (nk_height - 140),
|
};
|
base.AddChidren (VerticalScrolView);
|
}
|
|
public void SelectedInVerticalScrolViewFrameLayoutButton (object tag)
|
{
|
MainPage.Loading.Start ("Loading...");
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
for (int i = 0; i < VerticalScrolView.ChildrenCount; i++) {
|
if (VerticalScrolView.GetChildren (i).GetType () == typeof (RowLayout)) {
|
RowLayout inFView = (RowLayout)VerticalScrolView.GetChildren (i);
|
for (int kkk = 0; kkk < inFView.ChildrenCount; kkk++) {
|
selectedView (inFView, kkk, tag);
|
}
|
}
|
}
|
MainPage.Loading.Hide ();
|
});
|
});
|
}
|
|
void selectedView (RowLayout inFView, int kkk, object tag)
|
{
|
if (inFView.GetChildren (kkk).GetType () == typeof (Button)) {
|
Button btnS = (Button)inFView.GetChildren (kkk);
|
if (btnS.Tag != null) {
|
Console.WriteLine (btnS.Tag.ToString ());
|
if (btnS.Tag.ToString() == tag.ToString())
|
btnS.IsSelected = true;
|
else
|
btnS.IsSelected = false;
|
}
|
} else if (inFView.GetChildren (kkk).GetType () == typeof (RowLayout) ) {
|
RowLayout view = (RowLayout)inFView.GetChildren (kkk);
|
for (int iii = 0; iii < view.ChildrenCount; iii++) {
|
selectedView (view, iii, tag);
|
}
|
}
|
}
|
}
|
|
/// <summary>
|
/// 后台中间界面
|
/// </summary>
|
public static class SystemMiddle
|
{
|
/// <summary>
|
/// 当前主界面
|
/// </summary>
|
static readonly FrameLayout FrameLayoutMain = new FrameLayout () {
|
Height = Application.GetRealHeight (1236),
|
BackgroundColor = 0xFF000000
|
};
|
|
public static NK_FrameLayout FristScrolView = new NK_FrameLayout (1216) {
|
X = Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetRealWidth(656),
|
BackgroundColor = 0xFF2f2f2f
|
};
|
|
public static NK_FrameLayout SecondScrolView = new NK_FrameLayout (1216) {
|
X = Application.GetRealWidth (696),
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetRealWidth (656),
|
BackgroundColor = 0xFF2f2f2f
|
};
|
|
public static NK_FrameLayout ThirdScrolView = new NK_FrameLayout (1216) {
|
X = Application.GetRealWidth (1382),
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetRealWidth (656),
|
BackgroundColor = 0xFF2f2f2f
|
};
|
/// <summary>
|
/// 初始化当前视图
|
/// </summary>
|
public static void Init ()
|
{
|
if (null != FrameLayoutMain.Parent) {
|
return;
|
}
|
FrameLayoutMain.Y = SystemMiddleTop.SystemTopMeunView.Bottom;
|
SystemHomePage.FrameLayoutMain.AddChidren (FrameLayoutMain);
|
FrameLayoutMain.AddChidren (FristScrolView);
|
FrameLayoutMain.AddChidren (SecondScrolView);
|
FrameLayoutMain.AddChidren (ThirdScrolView);
|
InitBottomButtonForReadGateWay ();
|
|
//默认显示网关
|
ShowGateWayFrameLayout ();
|
}
|
|
/// <summary>
|
/// 初始化底部的按键,默认是搜索网关
|
/// </summary>
|
public static void InitBottomButtonForReadGateWay ()
|
{
|
Button AddSystemEquipmentButton = new Button () {
|
TextID = R.MyInternationalizationString.AddSystemEquipment,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 16,
|
};
|
|
AddSystemEquipmentButton.MouseUpEventHandler += (sender, e) => {
|
CommonPage.FindGateway = true;
|
MainPage.Loading.Start ();
|
readOnePort (() => {
|
CommonPage.FindGateway = false;
|
ShowGateWayFrameLayout ();
|
MainPage.Loading.Hide ();
|
});
|
};
|
FristScrolView.TitleView.AddChidren (AddSystemEquipmentButton);
|
}
|
|
/// <summary>
|
/// 读取一端口信息
|
/// </summary>
|
public static void readOnePort (Action action, byte subnetID = 0)
|
{
|
System.Threading.Tasks.Task.Run (() => {
|
//这里搜索设备,直到完成就退出
|
readDevice (subnetID);
|
CommonPage.LocalPhoneFindDevice = false;
|
if (action != null) {
|
Application.RunOnMainThread (
|
action
|
);
|
}
|
});
|
}
|
|
/// <summary>
|
/// 发送控制命令,不需要等等回复
|
/// </summary>
|
/// <param name="isRadio">If set to <c>true</c> is radio.</param>
|
/// <param name="addBytes">Add bytes.</param>
|
/// <param name="command">Command.</param>
|
public static void ControlSend (bool isRadio, byte [] addBytes, Command command)
|
{
|
System.Net.IPAddress ipAddress = new Net.NetWiFi ().BroadcastIpAddress;
|
if (isRadio) {
|
ipAddress = System.Net.IPAddress.Parse ("224.0.168.188");
|
}
|
|
Control control = new Control ();
|
control.Send (new Target () {
|
IPEndPoint = new System.Net.IPEndPoint (ipAddress, 6000),
|
Command = command,
|
SubnetID = 0xFF,
|
DeviceID = 0xFF,
|
AddData = addBytes
|
}, SendCount.Three, true);
|
if (control.UsefulBytes == null) {
|
}
|
}
|
|
/// <summary>
|
/// 读取设备
|
/// </summary>
|
/// <param name="findGateWay">If set to <c>true</c> find gate way.</param>
|
static void readDevice (byte subnetID)
|
{
|
CommonPage.LocalPhoneFindDevice = true;
|
if (subnetID == 0) {
|
readGateWay ();
|
} else {
|
//Newtonsoft.Json.js IO.FileUtils.ReadFile (gatwayFile);
|
CommonPage.RandomHigh = (byte)new Random ().Next (255);
|
CommonPage.RandomLow = (byte)new Random ().Next (255);
|
CommonPage.DeviceList.Clear ();
|
|
//如果两次都没有数据反馈,就不读取
|
int readCount = 4;
|
while (0 < readCount) {
|
readCount--;
|
System.IO.MemoryStream ms = new System.IO.MemoryStream ();
|
ms.WriteByte (CommonPage.RandomHigh);
|
ms.WriteByte (CommonPage.RandomLow);
|
|
List<Common> list = CommonPage.DeviceList;
|
int tempCount = list.Count;
|
string s = ";";
|
for (int i = 0; i < list.Count; i++) {
|
Common common = list [i];
|
if (common.SubnetID != subnetID)
|
continue;
|
if (s.Contains (";" + common.SubnetID.ToString () + ":" + common.DeviceID.ToString ()))
|
continue;
|
s += common.SubnetID.ToString () + ":" + common.DeviceID.ToString () + ";";
|
ms.WriteByte (common.SubnetID);
|
ms.WriteByte (common.DeviceID);
|
}
|
Console.WriteLine ("搜索非网关设备,网络地址是:" + CommonPage.EndPoint.ToString ());
|
Control control = new Control ();
|
control.Send (new Target () {
|
IPEndPoint = CommonPage.EndPoint,
|
Command = Command.ReadDeviceModul,
|
SubnetID = 0xFF,
|
DeviceID = 0xFF,
|
AddData = ms.ToArray ()
|
}, SendCount.Zero, false);
|
|
ms.Close ();
|
|
System.Threading.Thread.Sleep (1000);
|
//如果数量不相等,就重置次数
|
if (tempCount != CommonPage.DeviceList.Count) {
|
readCount = 4;
|
}
|
}
|
CommonPage.DeviceList = CommonPage.DeviceList.FindAll ((obj) => { return obj != null && obj.SubnetID == subnetID; });
|
|
}
|
}
|
|
/// <summary>
|
/// 读取网关设备
|
/// </summary>
|
static void readGateWay ()
|
{
|
CommonPage.RandomHigh = (byte)new Random ().Next (255);
|
CommonPage.RandomLow = (byte)new Random ().Next (255);
|
CommonPage.GateWayList.Clear ();
|
CommonPage.FindGateway = true;
|
//如果两次都没有数据反馈,就不读取
|
int readCount = 2;
|
while (0 < readCount) {
|
readCount--;
|
System.IO.MemoryStream ms = new System.IO.MemoryStream ();
|
ms.WriteByte (CommonPage.RandomHigh);
|
ms.WriteByte (CommonPage.RandomLow);
|
|
List<Common> list = CommonPage.GateWayList;
|
|
int tempCount = list.Count;
|
string s = ";";
|
for (int i = 0; i < list.Count; i++) {
|
Common common = list [i];
|
if (s.Contains (";" + common.SubnetID.ToString () + ":" + common.DeviceID.ToString ()))
|
continue;
|
s += common.SubnetID.ToString () + ":" + common.DeviceID.ToString () + ";";
|
ms.WriteByte (common.SubnetID);
|
ms.WriteByte (common.DeviceID);
|
}
|
Console.WriteLine ("搜索网关,搜索地址是:" + CommonPage.EndPoint.ToString () + " " + CommonPage.GateWayList.Count);
|
Control control = new Control ();
|
control.Send (new Target () {
|
IPEndPoint = CommonPage.EndPoint,
|
Command = Command.ReadGateway,
|
SubnetID = 0xFF,
|
DeviceID = 0xFF,
|
AddData = ms.ToArray ()
|
}, SendCount.Zero, false);
|
|
ms.Close ();
|
|
System.Threading.Thread.Sleep (800);
|
//如果数量不相等,就重置次数
|
if (tempCount != CommonPage.GateWayList.Count) {
|
readCount = 2;
|
}
|
}
|
CommonPage.FindGateway = false;
|
|
}
|
|
/// <summary>
|
/// 显示出已经查找到的网关设备
|
/// </summary>
|
public static void ShowGateWayFrameLayout ()
|
{
|
FristScrolView.RemoveAll ();
|
SecondScrolView.RemoveAll ();
|
ThirdScrolView.RemoveAll ();
|
InitBottomButtonForReadGateWay ();
|
try {
|
List<string> filesList = IO.FileUtils.ReadFiles ().FindAll ((obj) => obj.Split ('_').Length == 4 &&
|
obj.Split ('_') [0] == "Equipment");
|
foreach (var f in filesList) {
|
string [] str = f.Split ('_');
|
if (str.Length == 4 && str [0] == "Equipment") {
|
var one = System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (f));
|
var commGateway = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (one);
|
if (commGateway.obj1 == 1) {
|
RowLayout WirelessView = new RowLayout () {
|
Height = Application.GetRealHeight (131),
|
Tag = commGateway.CommonLoopID
|
};
|
FristScrolView.AddChidren (WirelessView);
|
AddWirelessGateway (commGateway, null, WirelessView);
|
} else if (str [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) {
|
var onePortWirelessFR = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortWirelessFR> (one);
|
|
RowLayout WirelessView = new RowLayout () {
|
Height = Application.GetRealHeight (131),
|
};
|
FristScrolView.AddChidren (WirelessView);
|
AddWirelessGateway (onePortWirelessFR, (sender, e) => {
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
FristScrolView.SelectedInVerticalScrolViewFrameLayoutButton (onePortWirelessFR.CommonLoopID);
|
new SystemWirelessGateway ().ShowWirelessGateway (onePortWirelessFR);
|
|
});
|
});
|
}, WirelessView);
|
} else if (str [1].ToString () == DeviceType.OnePortBus.ToString ()) {
|
var onePortBus = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortBus> (one);
|
RowLayout WirelessView = new RowLayout () {
|
Height = Application.GetRealHeight (131),
|
Tag = commGateway.CommonLoopID
|
};
|
FristScrolView.AddChidren (WirelessView);
|
|
AddWirelessGateway (onePortBus, (sender, e) => {
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
FristScrolView.SelectedInVerticalScrolViewFrameLayoutButton (onePortBus.CommonLoopID);
|
new SystemOnePortBus ().ShowOnePortBus (onePortBus);
|
|
});
|
});
|
}, WirelessView);
|
}
|
else if (str [1].ToString () == DeviceType.MusicModel.ToString ()) {
|
var musicModel = Newtonsoft.Json.JsonConvert.DeserializeObject<MusicModel> (one);
|
RowLayout rlMusicModel = new RowLayout () {
|
Height = Application.GetRealHeight (131),
|
};
|
FristScrolView.AddChidren (rlMusicModel);
|
Button btnDelFile = new Button () {
|
TextID = R.MyInternationalizationString.Del,
|
BackgroundColor = SkinStyle.Current.DelColor,
|
};
|
rlMusicModel.AddRightView (btnDelFile);
|
btnDelFile.MouseUpEventHandler += (sender, e) => {
|
IO.FileUtils.DeleteFile (f);
|
IO.FileUtils.DeleteFile (f + "_01");
|
SystemMiddle.ShowGateWayFrameLayout ();
|
};
|
|
Button button1 = new Button () {
|
X = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (66),
|
Width = Application.GetRealWidth (66),
|
UnSelectedImagePath = "Item/Music.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
rlMusicModel.AddChidren (button1);
|
|
Button textButton1 = new Button () {
|
X = Application.GetRealWidth (76),// + btnIcon.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (400),
|
Text = musicModel.Name,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
rlMusicModel.AddChidren (textButton1);
|
Button rightButton = new Button () {
|
X = Application.GetRealWidth (580),
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
rlMusicModel.AddChidren (rightButton);
|
rightButton.MouseUpEventHandler += (sender, e) => {
|
new SystemMusicModel ().ShowMusicModel (musicModel);
|
};
|
}
|
}
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
} catch { } finally {
|
}
|
}
|
|
/// <summary>
|
/// 显示网关
|
/// </summary>
|
static void AddWirelessGateway (Common common, EventHandler<MouseEventArgs> eHandler, RowLayout wirelessView)
|
{
|
int subnetID = common.SubnetID;
|
string remark = common.Name;
|
|
Button btnDelFile = new Button () {
|
TextID = R.MyInternationalizationString.Del,
|
BackgroundColor = SkinStyle.Current.DelColor,
|
};
|
btnDelFile.MouseUpEventHandler += (sender, e) => {
|
Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipDeleteEquipmentMessage)
|
, Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
|
alert.Show ();
|
alert.ResultEventHandler += (object sender1, bool e1) => {
|
if (e1) {
|
var delFile = IO.FileUtils.ReadFiles ().FindAll ((w) => {
|
return (w.Split ('_') [0] == "Equipment") && (w.Split ('_') [2] == subnetID.ToString ());
|
});
|
for (int k = 0; k < delFile.Count; k++) {
|
IO.FileUtils.DeleteFile (delFile [k]);
|
}
|
ShowGateWayFrameLayout ();
|
}
|
};
|
};
|
wirelessView.AddRightView (btnDelFile);
|
|
Button pointButton1 = new Button () {
|
Width = Application.GetRealHeight (13),
|
Height = Application.GetRealHeight (13),
|
X = Application.GetRealWidth (40),
|
UnSelectedImagePath = "Item/Point.png",
|
SelectedImagePath = "Item/PointSelected.png",
|
Gravity = Gravity.CenterVertical,
|
Tag = common.CommonLoopID
|
};
|
wirelessView.AddChidren (pointButton1);
|
|
Button nameButton1 = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = remark,
|
TextAlignment = TextAlignment.CenterLeft,
|
SelectedTextColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
X = pointButton1.Right + Application.GetRealWidth (20),
|
Tag = common.CommonLoopID
|
};
|
wirelessView.AddChidren (nameButton1);
|
|
wirelessView.MouseUpEventHandler += eHandler;
|
nameButton1.MouseUpEventHandler += eHandler;
|
|
Button btnNul = new Button () {
|
Y = Application.GetRealHeight(131)-2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
wirelessView.AddChidren (btnNul);
|
Button btnNull = new Button () {
|
Y = Application.GetRealHeight(131)-1,
|
Height = 1 ,
|
BackgroundColor = 0xFF2f2f2f,
|
};
|
wirelessView.AddChidren (btnNull);
|
}
|
|
public static List<Common> hideListCommon = new List<Common> ();
|
|
/// <summary>
|
/// 显示设备列表信息.
|
/// </summary>
|
public static void ShowEquipmentBase ()
|
{
|
hideListCommon = new List<Common> ();
|
FristScrolView.RemoveAll ();
|
SecondScrolView.RemoveAll ();
|
ThirdScrolView.RemoveAll ();
|
FristScrolView.TitleView.AddChidren (new Button () {
|
TextID = R.MyInternationalizationString.AllDeviceList,
|
TextSize = 16,
|
TextAlignment = TextAlignment.Center
|
});
|
List<string> localFileList = IO.FileUtils.ReadFiles ();
|
List<string> offlineDeviceList = new List<string> ();
|
var gateWayList = localFileList.FindAll ((obj) => {
|
return obj.Split ('_').Length == 4 && obj.StartsWith ("Equipment_") && obj.EndsWith ("_0");
|
});
|
|
foreach (var offline in localFileList) {
|
if (offline.Split ('_').Length == 5 && offline.Split ('_') [0] == "Equipment") {
|
var ss = IO.FileUtils.ReadFile (offline);
|
Common commonOffline = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (offline)));
|
if (commonOffline == null)
|
continue;
|
if (commonOffline.obj1 == 1) {
|
offlineDeviceList.Add (offline);
|
}
|
}
|
}
|
|
foreach (var gatewayFileName in gateWayList) {
|
if (offlineDeviceList.Contains (gatewayFileName))
|
continue;
|
var tempStrings = gatewayFileName.Split ('_');
|
if (tempStrings [1].ToString () == DeviceType.OnePortBus.ToString () ||
|
tempStrings [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) {
|
var one = System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (gatewayFileName));
|
#region titel
|
RowLayout OnePortBusFrameLayout = new RowLayout () {
|
Height = Application.GetRealHeight (131),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
FristScrolView.AddChidren (OnePortBusFrameLayout);
|
|
RowLayout busEquipmentBody = new RowLayout () {
|
Height = 0,
|
Tag = 0,
|
};
|
FristScrolView.AddChidren (busEquipmentBody);
|
Button button1 = new Button () {
|
X = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (66),
|
Width = Application.GetRealWidth (66),
|
UnSelectedImagePath = "Item/OnePort.png",
|
SelectedImagePath = "Item/OnePortSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
OnePortBusFrameLayout.AddChidren (button1);
|
|
Button textButton1 = new Button () {
|
X = Application.GetRealWidth (20) + button1.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (400),
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
OnePortBusFrameLayout.AddChidren (textButton1);
|
|
Button downSelectedButton1 = new Button () {
|
Height = Application.GetRealHeight (46),
|
Width = Application.GetRealWidth (47),
|
UnSelectedImagePath = "Item/Down.png",
|
SelectedImagePath = "Item/DownSelected.png",
|
Gravity = Gravity.CenterVertical,
|
IsSelected = true,
|
};
|
downSelectedButton1.X = OnePortBusFrameLayout.Width - downSelectedButton1.Width - Application.GetRealWidth (20);
|
OnePortBusFrameLayout.AddChidren (downSelectedButton1);
|
EventHandler<MouseEventArgs> eHandler = (sender, e) => {
|
downSelectedButton1.IsSelected = !downSelectedButton1.IsSelected;
|
if (downSelectedButton1.IsSelected) {
|
busEquipmentBody.Height = Convert.ToInt32 (busEquipmentBody.Tag);
|
} else {
|
busEquipmentBody.Height = 0;
|
}
|
};
|
downSelectedButton1.MouseUpEventHandler += eHandler;
|
button1.MouseUpEventHandler += eHandler;
|
textButton1.MouseUpEventHandler += eHandler;
|
Button btnTopLine = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 2,
|
BackgroundColor = 0xFF2f2f2f,
|
};
|
OnePortBusFrameLayout.AddChidren (btnTopLine);
|
#endregion
|
bool gatewayEntryProgramming = true;
|
if (tempStrings [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) {
|
var onePortWirelessFR = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortWirelessFR> (one);
|
textButton1.Text = onePortWirelessFR.Name;
|
button1.SelectedImagePath = "Item/WirelessSelected.png";
|
button1.UnSelectedImagePath = "Item/Wireless.png";
|
|
}
|
if (tempStrings [1].ToString () == DeviceType.OnePortBus.ToString ()) {
|
var onePortBus = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortBus> (one);
|
textButton1.Text = onePortBus.Name;
|
button1.SelectedImagePath = "Item/OnePortSelected.png";
|
button1.UnSelectedImagePath = "Item/OnePort.png";
|
|
}
|
button1.IsSelected = false;
|
int equipmentHeight = 0;
|
int count = 0;
|
//gatewayEntryProgramming = true;//qqqqqqq
|
foreach (var deviceFile in localFileList) {
|
if (deviceFile == gatewayFileName
|
|| deviceFile.Split ('_') [0] != "Equipment"
|
|| deviceFile.Split ('_').Length != 4) {
|
continue;
|
}
|
if (offlineDeviceList.Contains (deviceFile))
|
continue;
|
//子网号相等
|
if (deviceFile.Split ('_') [2] != tempStrings [2]) {
|
continue;
|
}
|
string localFileType = deviceFile.Split ('_') [1];
|
byte [] equipmentUsefullBytes = IO.FileUtils.ReadFile (deviceFile);
|
|
string equipmentString;
|
Common common = null;
|
equipmentString = CommonPage.MyEncodingUTF8.GetString (equipmentUsefullBytes);
|
common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (equipmentString);
|
if (common == null) {
|
continue;
|
}
|
|
if (common.isMixBox) {
|
hideListCommon.Add (common);
|
} else {
|
RowLayout frameLayout = new RowLayout () {
|
Height = Application.GetRealHeight (131),
|
};
|
frameLayout.Y = count++ * frameLayout.Height;
|
|
busEquipmentBody.AddChidren (frameLayout);
|
|
Button btnDelFile = new Button () {
|
TextID = R.MyInternationalizationString.Del,
|
BackgroundColor = SkinStyle.Current.DelColor
|
};
|
btnDelFile.MouseUpEventHandler += (sender, e) => {
|
Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipDeleteEquipmentMessage)
|
, Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
|
alert.Show ();
|
alert.ResultEventHandler += (object sender1, bool e1) => {
|
if (e1) {
|
//"_" + deviceFile.Split ('_') [1] +
|
string delFlag = "_" + deviceFile.Split ('_') [2] + "_" + deviceFile.Split ('_') [3];
|
var delFile = IO.FileUtils.ReadFiles ().FindAll ((w) => {
|
return w.Contains (delFlag);
|
});
|
|
for (int i = 0; i < delFile.Count; i++) {
|
IO.FileUtils.DeleteFile (delFile [i]);
|
}
|
ShowEquipmentBase ();
|
}
|
};
|
};
|
frameLayout.AddRightView (btnDelFile);
|
|
busEquipmentBody.Height += Application.GetRealHeight (131);
|
equipmentHeight += Application.GetRealHeight (131);
|
busEquipmentBody.Tag = equipmentHeight;
|
Button pointButton = new Button () {
|
Width = Application.GetRealHeight (13),
|
Height = Application.GetRealHeight (13),
|
X = Application.GetRealWidth (40),
|
UnSelectedImagePath = "Item/Point.png",
|
SelectedImagePath = "Item/PointSelected.png",
|
Gravity = Gravity.CenterVertical,
|
Tag = common.CommonLoopID,
|
};
|
frameLayout.AddChidren (pointButton);
|
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (642),
|
Height = LayoutParams.MatchParent,
|
Text = common.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = pointButton.Right + Application.GetRealWidth (20),
|
Tag = common.CommonLoopID,
|
SelectedTextColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
frameLayout.AddChidren (btnName);
|
|
EventHandler<MouseEventArgs> mouseEvent = (sender, e) => {
|
FristScrolView.SelectedInVerticalScrolViewFrameLayoutButton (common.CommonLoopID);
|
new SystemEquipmentBase ().EquipmentBaseViewShow (common);
|
};
|
if (gatewayEntryProgramming) {
|
btnName.MouseUpEventHandler += mouseEvent;
|
frameLayout.MouseUpEventHandler += mouseEvent;
|
}
|
|
Button btnNul = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
frameLayout.AddChidren (btnNul);
|
Button btnNull = new Button () {
|
Y = Application.GetRealHeight (131) - 1,
|
Height = 1,
|
BackgroundColor = 0xFF2f2f2f
|
};
|
frameLayout.AddChidren (btnNull);
|
}
|
}
|
}
|
}
|
|
if (offlineDeviceList.Count != 0) {
|
#region titel
|
FrameLayout OnePortBusFrameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (131),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
FristScrolView.AddChidren (OnePortBusFrameLayout);
|
|
FrameLayout busEquipmentBody = new FrameLayout () {
|
Height = 0,
|
Tag = 0,
|
};
|
FristScrolView.AddChidren (busEquipmentBody);
|
Button button1 = new Button () {
|
X = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (66),
|
Width = Application.GetRealWidth (66),
|
UnSelectedImagePath = "Item/OnePort.png",
|
SelectedImagePath = "Item/OnePortSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
OnePortBusFrameLayout.AddChidren (button1);
|
|
Button textButton1 = new Button () {
|
X = Application.GetRealWidth (20) + button1.Right,
|
Height = Application.GetRealHeight (41),
|
Width = Application.GetRealWidth (400),
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.OfflineDevice
|
};
|
OnePortBusFrameLayout.AddChidren (textButton1);
|
|
Button downSelectedButton1 = new Button () {
|
Height = Application.GetRealHeight (46),
|
Width = Application.GetRealWidth (47),
|
UnSelectedImagePath = "Item/Down.png",
|
SelectedImagePath = "Item/DownSelected.png",
|
Gravity = Gravity.CenterVertical,
|
IsSelected = true,
|
};
|
downSelectedButton1.X = OnePortBusFrameLayout.Width - downSelectedButton1.Width - Application.GetRealWidth (20);
|
OnePortBusFrameLayout.AddChidren (downSelectedButton1);
|
EventHandler<MouseEventArgs> eHandler = (sender, e) => {
|
downSelectedButton1.IsSelected = !downSelectedButton1.IsSelected;
|
if (downSelectedButton1.IsSelected) {
|
busEquipmentBody.Height = Convert.ToInt32 (busEquipmentBody.Tag);
|
} else {
|
busEquipmentBody.Height = 0;
|
}
|
};
|
downSelectedButton1.MouseUpEventHandler += eHandler;
|
button1.MouseUpEventHandler += eHandler;
|
textButton1.MouseUpEventHandler += eHandler;
|
#endregion
|
|
int count = 0;
|
int equipmentHeight = 0;
|
foreach (var offlineDevice in offlineDeviceList) {
|
string localFileType = offlineDevice.Split ('_') [1];
|
byte [] equipmentUsefullBytes = IO.FileUtils.ReadFile (offlineDevice);
|
string equipmentString;
|
Common common = null;
|
//设备界面要显示的设备,必须在这里添加显示
|
equipmentString = CommonPage.MyEncodingUTF8.GetString (equipmentUsefullBytes);
|
common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (equipmentString);
|
if (common == null) {
|
continue;
|
}
|
|
if (common.isMixBox) {
|
hideListCommon.Add (common);
|
} else {
|
RowLayout frameLayout = new RowLayout () {
|
Height = Application.GetRealHeight (131),
|
};
|
frameLayout.Y = count++ * frameLayout.Height;
|
|
busEquipmentBody.AddChidren (frameLayout);
|
|
Button btnDelFile = new Button () {
|
TextID = R.MyInternationalizationString.Del,
|
BackgroundColor = SkinStyle.Current.DelColor
|
};
|
btnDelFile.MouseUpEventHandler += (sender, e) => {
|
Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipDeleteEquipmentMessage)
|
, Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
|
alert.Show ();
|
alert.ResultEventHandler += (object sender1, bool e1) => {
|
if (e1) {
|
IO.FileUtils.DeleteFile (offlineDevice);
|
ShowEquipmentBase ();
|
}
|
};
|
};
|
frameLayout.AddRightView (btnDelFile);
|
|
busEquipmentBody.Height += Application.GetRealHeight (131);
|
equipmentHeight += Application.GetRealHeight (131);
|
busEquipmentBody.Tag = equipmentHeight;
|
Button pointButton = new Button () {
|
Width = Application.GetRealHeight (13),
|
Height = Application.GetRealHeight (13),
|
X = Application.GetRealWidth (40),
|
UnSelectedImagePath = "Item/Point.png",
|
SelectedImagePath = "Item/PointSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
frameLayout.AddChidren (pointButton);
|
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (642),
|
Height = LayoutParams.MatchParent,
|
Text = common.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = pointButton.Right + Application.GetRealWidth (20),
|
};
|
frameLayout.AddChidren (btnName);
|
Button btnNul = new Button () {
|
Y = Application.GetRealHeight (131) - 2,
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
frameLayout.AddChidren (btnNul);
|
Button btnNull = new Button () {
|
Y = Application.GetRealHeight (131) - 1,
|
Height = 1,
|
BackgroundColor = 0xFF2f2f2f
|
};
|
frameLayout.AddChidren (btnNull);
|
|
}
|
}
|
}
|
}
|
}
|
}
|