| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter.Safety |
| | | { |
| | | /// <summary> |
| | | /// 添加报警目标菜单列表的画面 |
| | | /// </summary> |
| | | public class AddAlarmTargetTypeListForm : UserCenterCommonForm |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Safety
|
| | | {
|
| | | /// <summary>
|
| | | /// 添加报警目标菜单列表的画面
|
| | | /// </summary>
|
| | | public class AddAlarmTargetTypeListForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary> |
| | | /// 防区ID(这个东西似乎是唯一的) |
| | | /// </summary> |
| | | private int zoonID = 0; |
| | | /// <summary> |
| | | /// 列表控件 |
| | | /// </summary> |
| | | private VerticalScrolViewLayout listView = null; |
| | | /// <summary> |
| | | /// 全部设备信息 |
| | | /// </summary> |
| | | /// <summary>
|
| | | /// 防区ID(这个东西似乎是唯一的)
|
| | | /// </summary>
|
| | | private int zoonID = 0;
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listView = null;
|
| | | /// <summary>
|
| | | /// 全部设备信息
|
| | | /// </summary>
|
| | | private List<uRowInformation> listAllDeviceInfo = new List<uRowInformation>();
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary> |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建) |
| | | /// </summary> |
| | | /// <param name="i_zoonID">防区ID</param> |
| | | public void ShowForm(int i_zoonID) |
| | | { |
| | | this.zoonID = i_zoonID; |
| | | |
| | | //设置头部信息 |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddAlarmTarget)); |
| | | |
| | | //初始化中部信息 |
| | | this.InitMiddleFrame(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部信息 |
| | | /// </summary> |
| | | private void InitMiddleFrame() |
| | | { |
| | | bodyFrameLayout.RemoveAll(); |
| | | |
| | | this.listView = new VerticalScrolViewLayout();
|
| | | this.listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(this.listView); |
| | | |
| | | //设置中间部分信息 |
| | | this.SetMiddleInfo(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置中间部分信息 |
| | | /// </summary> |
| | | private void SetMiddleInfo() |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_zoonID">防区ID</param>
|
| | | public void ShowForm(int i_zoonID)
|
| | | {
|
| | | this.zoonID = i_zoonID;
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddAlarmTarget));
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | //设置中间部分信息
|
| | | this.SetMiddleInfo();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置中间部分信息
|
| | | /// </summary>
|
| | | private void SetMiddleInfo()
|
| | | {
|
| | | new System.Threading.Thread(() =>
|
| | | {
|
| | | System.Threading.Thread.Sleep(100);
|
| | |
|
| | | //获取设备的所有类型,并整理成每一行的数据
|
| | | this.GetAllListData();
|
| | |
|
| | | //添加设备的行
|
| | | foreach (uRowInformation info in listAllDeviceInfo)
|
| | | if (listAllDeviceInfo.Count == 0)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | this.AddRowLaout(info);
|
| | | });
|
| | | return;
|
| | | }
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | int realHeight = (ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(29)) * listAllDeviceInfo.Count + Application.GetRealHeight(23);
|
| | | if (realHeight > bodyFrameLayout.Height + Application.GetRealHeight(6))
|
| | | {
|
| | | //计算真实高度
|
| | | realHeight = bodyFrameLayout.Height + Application.GetRealHeight(6);
|
| | | }
|
| | | this.listView = new VerticalListControl(29);
|
| | | listView.Y = Application.GetRealHeight(-6);
|
| | | listView.Height = realHeight;
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(this.listView);
|
| | |
|
| | | //添加设备的行
|
| | | int count = listAllDeviceInfo.Count - 1;
|
| | | for (int i = 0; i < listAllDeviceInfo.Count; i++)
|
| | | {
|
| | | this.AddRowLaout(listAllDeviceInfo[i], i != count);
|
| | | }
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | |
| | |
|
| | | #region ■ 添加行_____________________________
|
| | |
|
| | | /// <summary> |
| | | /// 添加行 |
| | | /// </summary> |
| | | /// <param name="uRow"></param> |
| | | private void AddRowLaout(uRowInformation uRow) |
| | | { |
| | | var rowlayout = new StatuRowLayout(this.listView); |
| | | //图标 |
| | | var btnIcon = new RowLeftIconView(); |
| | | btnIcon.UnSelectedImagePath = uRow.IconUnSelectPath; |
| | | btnIcon.SelectedImagePath = uRow.IconSelectPath; |
| | | rowlayout.AddChidren(btnIcon); |
| | | |
| | | //设备名 |
| | | var txtDevice = new RowCenterView(); |
| | | txtDevice.Text = uRow.TextName; |
| | | rowlayout.AddChidren(txtDevice); |
| | | |
| | | //向右图标 |
| | | rowlayout.AddRightIconControl(); |
| | | |
| | | //单击事件 |
| | | rowlayout.MouseUpEvent += (sender, e) => |
| | | { |
| | | /// <summary>
|
| | | /// 添加行
|
| | | /// </summary>
|
| | | /// <param name="uRow"></param>
|
| | | /// <param name="addLine"></param>
|
| | | private void AddRowLaout(uRowInformation uRow, bool addLine)
|
| | | {
|
| | | var rowlayout = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(rowlayout);
|
| | | //图标
|
| | | var btnIcon = rowlayout.AddLeftIcon(81);
|
| | | btnIcon.UnSelectedImagePath = uRow.IconUnSelectPath;
|
| | |
|
| | | //设备名
|
| | | var txtDevice = rowlayout.AddLeftCaption(uRow.TextName, 750);
|
| | | txtDevice.Text = uRow.TextName;
|
| | | txtDevice.TextSize = 15;
|
| | | //向右图标
|
| | | rowlayout.AddRightArrow();
|
| | | if (addLine == true)
|
| | | {
|
| | | //底线
|
| | | rowlayout.AddBottomLine();
|
| | | }
|
| | |
|
| | | //单击事件
|
| | | rowlayout.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (uRow.listScene == null)
|
| | | {
|
| | | //设备的一览
|
| | | var form = new AddDeviceAlarmTargetListForm();
|
| | | this.AddForm(form, this.zoonID, uRow.TextName, uRow.listDevice);
|
| | | } |
| | | form.AddForm(this.zoonID, uRow.TextName, uRow.listDevice);
|
| | | }
|
| | | else
|
| | | {
|
| | | //场景的一览
|
| | | var form = new AddSceneAlarmTargetListForm();
|
| | | this.AddForm(form, this.zoonID, uRow.listScene);
|
| | | } |
| | | }; |
| | | form.AddForm(this.zoonID, uRow.listScene);
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary> |
| | | /// 获取设备的所有类型,并整理成每一行的数据 |
| | | /// </summary> |
| | | private void GetAllListData() |
| | | { |
| | | Dictionary<string, uRowInformation> dic = new Dictionary<string, uRowInformation>(); |
| | | this.listAllDeviceInfo.Clear(); |
| | | |
| | | var listDevice = Common.LocalDevice.Current.listAllDevice; |
| | | foreach (CommonDevice device in listDevice) |
| | | /// <summary>
|
| | | /// 获取设备的所有类型,并整理成每一行的数据
|
| | | /// </summary>
|
| | | private void GetAllListData()
|
| | | {
|
| | | Dictionary<string, uRowInformation> dic = new Dictionary<string, uRowInformation>();
|
| | | this.listAllDeviceInfo.Clear();
|
| | |
|
| | | var listDevice = Common.LocalDevice.Current.listAllDevice;
|
| | | foreach (CommonDevice device in listDevice)
|
| | | {
|
| | | //如果那个设备已经添加了,则不再显示
|
| | | if (Common.LocalSafeguard.Current.IsAlarmDeviceExist(this.zoonID, device) == true)
|
| | | {
|
| | | continue;
|
| | | } |
| | | if (device.Type == DeviceType.IASZone//传感器 |
| | | || device.Type == DeviceType.OnOffSwitch//面板
|
| | | )
|
| | | if (HdlSafeguardLogic.Current.IsAlarmDeviceExist(this.zoonID, device) == true)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (device.Type == DeviceType.AirSwitch//空气开关
|
| | | || device.Type == DeviceType.DimmableLight//调光器
|
| | | || device.Type == DeviceType.ColorDimmableLight//彩灯
|
| | | || device.Type == DeviceType.OnOffOutput//继电器
|
| | | || device.Type == DeviceType.WindowCoveringDevice)//窗帘
|
| | | {
|
| | | //显示文本
|
| | | string KeysName = Common.LocalDevice.Current.GetDeviceObjectText(new List<CommonDevice>() { device });
|
| | |
|
| | | //显示文本
|
| | | string KeysName = Common.LocalDevice.Current.GetDeviceObjectText(new List<CommonDevice>() { device }); |
| | | //图标地址:点亮 |
| | | string IconSelect = string.Empty; |
| | | //图标地址:未点亮 |
| | | string IconUnSelect = string.Empty;
|
| | | uRowInformation infoRow = null;
|
| | | if (dic.ContainsKey(KeysName) == false)
|
| | | {
|
| | | //图标地址:点亮
|
| | | string IconSelect = string.Empty;
|
| | | //图标地址:未点亮
|
| | | string IconUnSelect = string.Empty;
|
| | | Common.LocalDevice.Current.GetDeviceBeloneIcon(new List<CommonDevice>() { device }, ref IconUnSelect, ref IconSelect);
|
| | |
|
| | | Common.LocalDevice.Current.GetDeviceBeloneIcon(new List<CommonDevice>() { device }, ref IconUnSelect, ref IconSelect); |
| | | |
| | | uRowInformation infoRow = null; |
| | | if (dic.ContainsKey(KeysName) == false) |
| | | { |
| | | //第一次时,设置它的显示文本及设置它的图标 |
| | | infoRow = new uRowInformation(); |
| | | dic[KeysName] = infoRow; |
| | | infoRow.TextName = KeysName; |
| | | infoRow.IconSelectPath = IconSelect; |
| | | infoRow.IconUnSelectPath = IconUnSelect; |
| | | |
| | | this.listAllDeviceInfo.Add(infoRow); |
| | | } |
| | | infoRow = dic[KeysName]; |
| | | |
| | | //设备收集 |
| | | var info = new uDeviceInfo |
| | | { |
| | | listRoomName = Shared.Common.Room.CurrentRoom.GetRoomListNameByDevice(device), |
| | | Device = device, |
| | | MainKeys = device.DeviceAddr + device.DeviceEpoint.ToString() |
| | | }; |
| | | infoRow.listDevice.Add(info); |
| | | //第一次时,设置它的显示文本及设置它的图标
|
| | | infoRow = new uRowInformation();
|
| | | dic[KeysName] = infoRow;
|
| | | infoRow.TextName = KeysName;
|
| | | infoRow.IconSelectPath = IconSelect;
|
| | | infoRow.IconUnSelectPath = IconUnSelect;
|
| | |
|
| | | this.listAllDeviceInfo.Add(infoRow);
|
| | | }
|
| | | infoRow = dic[KeysName];
|
| | |
|
| | | //设备收集
|
| | | var info = new uDeviceInfo
|
| | | {
|
| | | listRoomName = Shared.Common.Room.CurrentRoom.GetRoomListNameByDevice(device),
|
| | | Device = device,
|
| | | MainKeys = device.DeviceAddr + device.DeviceEpoint.ToString()
|
| | | };
|
| | | infoRow.listDevice.Add(info);
|
| | | }
|
| | | }
|
| | |
|
| | | //获取场景
|
| | |
| | | return;
|
| | | }
|
| | | //获取本地安防的场景
|
| | | Dictionary<int, string> dicScene = Common.LocalSafeguard.Current.GetLocalSceneByZoneID(this.zoonID);
|
| | | Dictionary<int, string> dicScene = HdlSafeguardLogic.Current.GetLocalSceneByZoneID(this.zoonID);
|
| | |
|
| | | var SceneInfo = new uRowInformation();
|
| | | SceneInfo.listScene = new List<Common.SceneRoomUI>();
|
| | |
| | | if (SceneInfo.listScene.Count > 0)
|
| | | {
|
| | | SceneInfo.TextName = Language.StringByID(R.MyInternationalizationString.uScence);
|
| | | SceneInfo.IconSelectPath = "Item/SceneSelected.png";
|
| | | SceneInfo.IconUnSelectPath = "Item/Scene.png";
|
| | | this.listAllDeviceInfo.Add(SceneInfo);
|
| | | } |
| | | }
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 界面重新激活事件___________________ |
| | | #region ■ 界面重新激活事件___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
|
| | | /// </summary> |
| | | /// </summary>
|
| | | public override void FormActionAgainEvent()
|
| | | {
|
| | | //重新刷新界面
|
| | | this.ShowForm(zoonID);
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | #endregion |
| | | |
| | | #region ■ 自定义结构体_______________________ |
| | | |
| | | /// <summary> |
| | | /// 每一行的行数据 |
| | | /// </summary> |
| | | private class uRowInformation |
| | | { |
| | | /// <summary> |
| | | /// 图标地址:未点亮 |
| | | /// </summary> |
| | | public string IconUnSelectPath = string.Empty; |
| | | /// <summary> |
| | | /// 图标地址:点亮 |
| | | /// </summary> |
| | | public string IconSelectPath = string.Empty; |
| | | /// <summary> |
| | | /// 显示的内容 |
| | | /// </summary> |
| | | public string TextName = string.Empty; |
| | | /// <summary> |
| | | /// 设备列表信息 |
| | | /// </summary> |
| | | public List<uDeviceInfo> listDevice = new List<uDeviceInfo>(); |
| | | #endregion
|
| | |
|
| | | #region ■ 自定义结构体_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 每一行的行数据
|
| | | /// </summary>
|
| | | private class uRowInformation
|
| | | {
|
| | | /// <summary>
|
| | | /// 图标地址:未点亮
|
| | | /// </summary>
|
| | | public string IconUnSelectPath = string.Empty;
|
| | | /// <summary>
|
| | | /// 图标地址:点亮
|
| | | /// </summary>
|
| | | public string IconSelectPath = string.Empty;
|
| | | /// <summary>
|
| | | /// 显示的内容
|
| | | /// </summary>
|
| | | public string TextName = string.Empty;
|
| | | /// <summary>
|
| | | /// 设备列表信息
|
| | | /// </summary>
|
| | | public List<uDeviceInfo> listDevice = new List<uDeviceInfo>();
|
| | | /// <summary>
|
| | | /// 场景
|
| | | /// </summary> |
| | | public List<Common.SceneRoomUI> listScene = null; |
| | | /// </summary>
|
| | | public List<Common.SceneRoomUI> listScene = null;
|
| | | }
|
| | | #endregion |
| | | } |
| | | } |
| | | #endregion
|
| | | }
|
| | | }
|