using System;
|
using Shared;
|
using HDL_ON.UI.CSS;
|
using Newtonsoft.Json;
|
using HDL_ON.Entity;
|
using System.Collections.Generic;
|
using HDL_ON.DriverLayer;
|
|
namespace HDL_ON.UI
|
{
|
public partial class SearchDevicePage : FrameLayout
|
{
|
FrameLayout bodyView;
|
VerticalRefreshLayout contentView;
|
List<string> deviceIpList = new List<string>();
|
public SearchDevicePage()
|
{
|
bodyView = this;
|
}
|
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
new TopViewDiv(bodyView, Language.StringByID(StringId.Panel)).LoadTopView();
|
|
contentView = new VerticalRefreshLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(603),
|
};
|
bodyView.AddChidren(contentView);
|
|
contentView.BeginHeaderRefreshingAction += () =>
|
{
|
deviceIpList.Clear();
|
contentView.RemoveAll();
|
//DriverLayer.Control.ins.ChangeCommunicationMode(DriverLayer.CommunicationMode.local_BusUdp);
|
// UdpSocket._BusSocket.SearchNetDeviceAction = (jto) =>
|
// {
|
// var device = JsonConvert.DeserializeObject<DeviceModule>(jto.ToString());
|
// if (device != null)
|
// {
|
// lock (deviceIpList)
|
// {
|
// if (!deviceIpList.Contains(device.ip_address))
|
// {
|
// deviceIpList.Add(device.ip_address);
|
// MainPage.Log($"搜索到网络设备:{device.ip_address}");
|
// Application.RunOnMainThread(() =>
|
// {
|
//#if DEBUG
|
//#else
|
// if(device.gateway_type== 4)
|
//#endif
|
// {
|
// LoadRow(device);
|
// }
|
// });
|
// }
|
// else
|
// {
|
// MainPage.Log($"已加载该IP设备:{device.ip_address}");
|
// }
|
// }
|
// }
|
// };
|
new Control_Udp().SearchLocalGateway();
|
contentView.EndHeaderRefreshing();
|
};
|
|
contentView.BeginHeaderRefreshing();
|
|
}
|
/// <summary>
|
///
|
/// </summary>
|
void LoadRow(DeviceModule device)
|
{
|
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
|
var bodyDiv = new FrameLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(80),
|
Radius = (uint)Application.GetMinRealAverage(12),
|
BorderColor = 0x00FFFFFF,
|
BorderWidth = 1,
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(bodyDiv);
|
|
Button btnIcon = new Button()
|
{
|
X = Application.GetRealWidth(10),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
};
|
bodyDiv.AddChidren(btnIcon);
|
|
switch (device.gateway_type)
|
{
|
case 4:
|
btnIcon.UnSelectedImagePath = "FunctionIcon/DeviceIcon/VoicePanelIcon.png";
|
break;
|
default:
|
break;
|
}
|
|
Button btnName = new Button()
|
{
|
X = Application.GetRealWidth(54),
|
Width = Application.GetRealWidth(200),
|
Text = device.device_name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
};
|
bodyDiv.AddChidren(btnName);
|
|
SkipVoicePanelScenePage(device, bodyDiv, btnIcon, btnName);
|
}
|
}
|
|
|
public partial class SearchDevicePage
|
{
|
void SkipVoicePanelScenePage(DeviceModule device,FrameLayout div,Button btn1,Button btn2)
|
{
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
var page = new VoicePanelSceneListPage(device);
|
MainPage.BasePageView.AddChidren(page);
|
page.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
div.MouseUpEventHandler = eventHandler;
|
btn1.MouseUpEventHandler = eventHandler;
|
btn2.MouseUpEventHandler = eventHandler;
|
}
|
|
}
|
|
}
|