using System;
using System.Collections.Generic;
namespace Shared.SimpleControl.Phone
{
///
/// 用户干接点状态界面,干接点不能控制,先显示状态
///
public class UserDryContact
{
public static UserDryContact curDC;
VerticalScrolViewLayout scenesBodyView;
public UserDryContact ()
{
curDC = this;
}
///
/// 更新界面
///
/// The view.
/// Subnet identifier.
/// Device identifier.
/// Loop identifier.
/// Status.
public static void UpdataView (byte subnetID,byte deviceID,byte loopID,byte status)
{
if (curDC == null) {
return;
}
for (int i = 0; i < curDC.scenesBodyView.ChildrenCount; i++) {
if (curDC.scenesBodyView.GetChildren (i).GetType () == typeof (FrameLayout)) {
FrameLayout frameLayout = (FrameLayout)curDC.scenesBodyView.GetChildren (i);
for (int j = 0; j < frameLayout.ChildrenCount; j++) {
if (frameLayout.GetChildren (j).GetType () == typeof (FrameLayout)) {
FrameLayout frameLayout2 = (FrameLayout)frameLayout.GetChildren (j);
for (int k = 0; k < frameLayout2.ChildrenCount; k++) {
if (frameLayout2.GetChildren (k).GetType () == typeof (Button)) {
Button btn = (Button)frameLayout2.GetChildren (k);
var o = btn.GetTagByKey ("UpdataKey");
if (o != null && o.ToString () == subnetID.ToString () + deviceID.ToString () + loopID.ToString ()) {
Application.RunOnMainThread (() => {
if (status ==0) {
btn.IsSelected = true;
} else {
btn.IsSelected = false;
}
});
}
}
}
}
}
}
}
}
public void ShowUserDryContact (Room roomUI = null)
{
//UserMiddle.VerticalScrolView_InUserMiddleView.RemoveAll ();
//UserHomePage.FrameLayoutMain.Remove (UserTop.UserTopFrameLayout);
//FrameLayout bodyView = new FrameLayout () {
// Width = LayoutParams.MatchParent,
// Height = LayoutParams.MatchParent,
//};
//UserMiddle.VerticalScrolView_InUserMiddleView.AddChidren (bodyView);
//// topView
//new EquipmentPublicClass ().InitUserTopView (Language.StringByID (R.MyInternationalizationString.DryContactPanel));
//var listdcpUI = FindAllScenesRoom (roomUI);
//#region bodyView
//FrameLayout scenesRowView = new FrameLayout () {
// Width = LayoutParams.MatchParent,
// Height = Application.GetRealHeight (220),
//};
//VerticalScrolViewLayout scrolView = new VerticalScrolViewLayout () {
// Width = LayoutParams.MatchParent,
// Height = Application.GetRealHeight (776 + 88),
//};
//bodyView.AddChidren (scrolView);
// scenesBodyView = new VerticalScrolViewLayout () {
// Width = LayoutParams.MatchParent,
// Height = LayoutParams.MatchParent,
//};
//scrolView.AddChidren (scenesBodyView);
//int number = -1;
//for (int i = listdcpUI.Count; i < 8; i = listdcpUI.Count) {
// listdcpUI.Add (new DryContact ());
//}
//foreach (var dcUI in listdcpUI) {
// number++;
// if (number % 2 == 0) {
// scenesRowView = new FrameLayout () {
// Width = LayoutParams.MatchParent,
// Height = Application.GetRealHeight (220),
// };
// scenesBodyView.AddChidren (scenesRowView);
// }
// FrameLayout sceneView = new FrameLayout () {
// Width = Application.GetRealWidth (322),
// Height = Application.GetRealHeight (220),
// BackgroundImagePath = "Item/ArticulatingFrameLeft1.png",
// };
// scenesRowView.AddChidren (sceneView);
// if (number % 2 == 1) {
// sceneView.Width = Application.GetRealWidth (318);
// sceneView.Height = Application.GetRealHeight (220);
// sceneView.X = Application.GetRealWidth (322);
// sceneView.BackgroundImagePath = "Item/ArticulatingFrameRight1.png";
// }
// if (null != dcUI.Name) {
// Button btnSceneIcon = new Button () {
// Width = Application.GetRealWidth (85),
// Height = Application.GetRealHeight (75),
// Gravity = Gravity.CenterHorizontal,
// Y = Application.GetRealHeight (70),
// UnSelectedImagePath = "Item/DryContact.png",
// SelectedImagePath = "Item/DryContactSelected.png",
// };
// sceneView.AddChidren (btnSceneIcon);
// btnSceneIcon.AddTag("UpdataKey", dcUI.SubnetID.ToString () + dcUI.DeviceID.ToString () + dcUI.LoopID.ToString ());
// Button btnSceneName = new Button () {
// Width = Application.GetRealWidth (300),
// Height = Application.GetRealHeight (45),
// Gravity = Gravity.CenterHorizontal,
// Y = Application.GetRealHeight (90) + btnSceneIcon.Height,
// Text = dcUI.Name,
// };
// sceneView.AddChidren (btnSceneName);
// System.Threading.Tasks.Task.Run (() => {
// byte [] bbb = Control.ControlBytesSendHasReturn (Command.ReadDryContactStatus, dcUI.SubnetID,
// dcUI.DeviceID, new byte [] { 1, dcUI.LoopID });
// if (bbb != null) {
// Application.RunOnMainThread (() => {
// if (bbb [2] == 0) {
// btnSceneIcon.IsSelected = true;
// //dcp.Status = ONorOFF.ON;
// } else {
// btnSceneIcon.IsSelected = false;
// //dcp.Status = ONorOFF.OFF;
// }
// });
// }
// });
// }
//}
//#endregion
}
List FindAllScenesRoom (Room roomUI)
{
List list = new List ();
if (roomUI == null) {
foreach (var tempRoomUI in Room.Lists) {
for (int i = 0; i < tempRoomUI.DeviceList.Count; i++) {
var common = tempRoomUI.DeviceList [i];
if (common.Type != DeviceType.DryContact) {
continue;
}
list.Add (common as DryContact);
}
}
} else {
for (int i = 0; i < roomUI.DeviceList.Count; i++) {
var common = roomUI.DeviceList [i];
if (common.Type != DeviceType.DryContact) {
continue;
}
list.Add (common as DryContact);
}
}
return list;
}
}
}