using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter.DevicePirSensor
|
{
|
/// <summary>
|
/// PIR传感器绑定界面★
|
/// </summary>
|
public class PirSensorBindTargetForm : EditorCommonForm
|
{
|
/// <summary>
|
/// 列表控件
|
/// </summary>
|
private VerticalScrolViewLayout listView = null;
|
/// <summary>
|
/// 编辑按钮
|
/// </summary>
|
private BottomClickButton btnEditor = null;
|
/// <summary>
|
/// 传感器设备
|
/// </summary>
|
private IASZone deviceIASZone = null;
|
/// <summary>
|
/// 已经存在的绑定设备
|
/// </summary>
|
private Dictionary<string, CommonDevice> dicEsixtDevice = new Dictionary<string, CommonDevice>();
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
/// <param name="i_iasZone">传感器设备</param>
|
public void ShowForm(IASZone i_iasZone)
|
{
|
deviceIASZone = i_iasZone;
|
|
//设置头部信息
|
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBindTargetsSettion));
|
|
////右上添加按钮
|
//var btnAddDeviceIcon = new MostRightIconControl(69, 69);
|
//btnAddDeviceIcon.UnSelectedImagePath = "Item/Add.png";
|
//btnAddDeviceIcon.SelectedImagePath = "Item/AddSelected.png";
|
//topFrameLayout.AddChidren(btnAddDeviceIcon);
|
//btnAddDeviceIcon.MouseUpEventHandler += (sender, e) =>
|
//{
|
// //显示设备选择的界面
|
// this.ShowDeviceSelectForm();
|
//};
|
|
//初始化中部信息
|
//this.InitMiddleFrame();
|
}
|
|
///// <summary>
|
///// 初始化中部信息
|
///// </summary>
|
//private void InitMiddleFrame()
|
//{
|
// //清空bodyFrame
|
// this.ClearBodyFrame();
|
|
// this.listView = new VerticalScrolViewLayout();
|
// this.listView.Height = bodyFrameLayout.Height;
|
// bodyFrameLayout.AddChidren(this.listView);
|
|
// this.dicEsixtDevice.Clear();
|
|
// //开启进度条
|
// this.ShowProgressBar();
|
|
// HdlThreadLogic.Current.Run(async () =>
|
// {
|
// List<CommonDevice> listDevice = await HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
|
// if (listDevice == null)
|
// {
|
// //关闭进度条
|
// this.CloseProgressBar(ShowReLoadMode.YES);
|
// return;
|
// }
|
// foreach(CommonDevice device in listDevice)
|
// {
|
// Application.RunOnMainThread(() =>
|
// {
|
// if (this.Parent != null)
|
// {
|
// this.AddRowlayout(device);
|
// }
|
// });
|
// }
|
// //关闭进度条
|
// this.CloseProgressBar();
|
// });
|
//}
|
|
///// <summary>
|
///// 添加行
|
///// </summary>
|
///// <param name="device"></param>
|
//private void AddRowlayout(CommonDevice device)
|
//{
|
// //初始化编辑按钮
|
// this.InitEditorButton();
|
|
// string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
// this.dicEsixtDevice[mainKeys] = device;
|
|
// var row = new DeviceRoomViewRow(this.listView, device);
|
// row.ChangedChidrenBindMode(row.btnIcon, ChidrenBindMode.BindEventOnly);
|
// row.ChangedChidrenBindMode(row.btnRoom, ChidrenBindMode.BindEventOnly);
|
// row.ChangedChidrenBindMode(row.btnDevie, ChidrenBindMode.BindEventOnly);
|
|
// //删除
|
// var btnDelete = new RowDeleteButton();
|
// row.AddRightView(btnDelete);
|
// btnDelete.MouseUpEventHandler += (sender, e) =>
|
// {
|
// //确认要删除吗?
|
// string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
|
// this.ShowConfirmMsg(msg, "DeleteTargetDevice", device, row);
|
// };
|
//}
|
|
///// <summary>
|
///// 删除绑定目标
|
///// </summary>
|
///// <param name="device"></param>
|
///// <param name="row"></param>
|
//public async void DeleteTargetDevice(CommonDevice device, DeviceRoomViewRow row)
|
//{
|
// //开启进度条
|
// this.ShowProgressBar();
|
// bool result = await HdlDeviceBindLogic.Current.DeleteDeviceTarget(this.deviceIASZone, device);
|
// //关闭进度条
|
// this.CloseProgressBar();
|
|
// if (result == false)
|
// {
|
// return;
|
// }
|
// Application.RunOnMainThread(() =>
|
// {
|
// string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
// this.dicEsixtDevice.Remove(mainKeys);
|
|
// row?.RemoveFromParent();
|
// if (listView != null && listView.ChildrenCount == 0)
|
// {
|
// this.btnEditor?.RemoveFromParent();
|
// this.btnEditor = null;
|
// }
|
// });
|
//}
|
|
///// <summary>
|
///// 显示设备选择的界面
|
///// </summary>
|
//private void ShowDeviceSelectForm()
|
//{
|
// var listShowDevice = new List<CommonDevice>();
|
// var listTempDevice = Common.LocalDevice.Current.listAllDevice;
|
// foreach (var device in listTempDevice)
|
// {
|
// //如果是传感器,或者是没有开关簇的话(这里判断的是输入簇)
|
// if ((device is IASZone) || Common.LocalDevice.Current.InDeviceIsCanOnOff(device) == false)
|
// {
|
// continue;
|
// }
|
// string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
// if (this.dicEsixtDevice.ContainsKey(mainKeys) == true)
|
// {
|
// //如果已经添加了,则不再显示
|
// continue;
|
// }
|
|
// listShowDevice.Add(device);
|
// }
|
// var listSelect = new List<string>();
|
// foreach (string mainkeys in this.dicEsixtDevice.Keys)
|
// {
|
// listSelect.Add(mainkeys);
|
// }
|
|
// var form = new SelectDeviceForm();
|
// form.AddForm(listShowDevice, listSelect, false);
|
// //添加绑定目标
|
// form.SetTitleText(Language.StringByID(R.MyInternationalizationString.AddBindTargets));
|
|
// //设备选择确定
|
// form.ActionSelectDevice += (async (listDevice) =>
|
// {
|
// if (listDevice.Count == 0)
|
// {
|
// return;
|
// }
|
// //开启进度条
|
// this.ShowProgressBar();
|
// var listNewDevice = await HdlDeviceBindLogic.Current.BindDeviceTarget(this.deviceIASZone, listDevice);
|
// //关闭进度条
|
// this.CloseProgressBar();
|
|
// if (listNewDevice == null || listNewDevice.Count == 0)
|
// {
|
// return;
|
// }
|
|
// foreach (CommonDevice device in listNewDevice)
|
// {
|
// string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
// this.dicEsixtDevice[mainKeys] = device;
|
|
// Application.RunOnMainThread(() =>
|
// {
|
// if (this.listView != null)
|
// {
|
// this.AddRowlayout(device);
|
// }
|
// });
|
// }
|
// Application.RunOnMainThread(() =>
|
// {
|
// //打开PIR传感器的灯光特效配置界面
|
// var newform = new PirSensorLightSettionForm();
|
// newform.AddForm(this.deviceIASZone);
|
// });
|
// });
|
//}
|
|
///// <summary>
|
///// 初始化编辑按钮
|
///// </summary>
|
//private void InitEditorButton()
|
//{
|
// if (this.btnEditor != null)
|
// {
|
// return;
|
// }
|
|
// Application.RunOnMainThread(() =>
|
// {
|
// if (this.listView == null)
|
// {
|
// return;
|
// }
|
// //编辑
|
// this.btnEditor = new BottomClickButton();
|
// this.btnEditor.MouseUpTime = 0;
|
// this.btnEditor.TextID = R.MyInternationalizationString.uEditor;
|
// bodyFrameLayout.AddChidren(this.btnEditor);
|
// this.btnEditor.MouseUpEvent += (sender, e) =>
|
// {
|
// var form = new PirSensorLightSettionForm();
|
// form.AddForm(deviceIASZone);
|
// };
|
|
// this.listView.Height = this.btnEditor.Y - ControlCommonResourse.BottomButtonAndListViewSpace;
|
// });
|
//}
|
}
|
}
|