New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Safety
|
| | | {
|
| | | /// <summary>
|
| | | /// 既存报警目标设置画面
|
| | | /// </summary>
|
| | | public class AlarmTargetExistSettionForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 防区ID(这个东西似乎是唯一的)
|
| | | /// </summary>
|
| | | private int zoonID = 0;
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listView = null;
|
| | |
|
| | | #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.uAlarmTargetSettion)); |
| | | |
| | | //添加图标
|
| | | var btnAdd = new MostRightIconControl(69, 69);
|
| | | btnAdd.UnSelectedImagePath = "Item/Add.png";
|
| | | topFrameLayout.AddChidren(btnAdd);
|
| | | btnAdd.InitControl();
|
| | | btnAdd.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new AlarmTargetAddMenuForm();
|
| | | form.AddForm(this.zoonID);
|
| | | }; |
| | | |
| | | //初始化中部信息 |
| | | this.InitMiddleFrame(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部信息 |
| | | /// </summary> |
| | | private void InitMiddleFrame() |
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | //根据防区ID获取本地的报警目标列表
|
| | | var listData = HdlSafeguardLogic.Current.GetLocalAlarmTargetInfoByZoneId(this.zoonID);
|
| | | if (listData.Count == 0)
|
| | | {
|
| | | //还没有设置报警目标
|
| | | this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDoNotHadSettionTargetMsg));
|
| | | return;
|
| | | }
|
| | |
|
| | | this.listView = new VerticalListControl(23);
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | for (int i = 0; i < listData.Count; i++)
|
| | | {
|
| | | var data = listData[i];
|
| | | //场景
|
| | | if (data.Type == 1)
|
| | | {
|
| | | this.AddSceneRow(data, i != listData.Count - 1);
|
| | | }
|
| | | //设备
|
| | | if (data.Type == 0)
|
| | | {
|
| | | this.AddDeviceRow(data, i != listData.Count - 1);
|
| | | }
|
| | | }
|
| | | //调整真实高度
|
| | | this.listView.AdjustRealHeight(Application.GetRealHeight(23));
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 报警目标明细行_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加设备行
|
| | | /// </summary>
|
| | | /// <param name="data"></param>
|
| | | /// <param name="addLine"></param>
|
| | | private void AddDeviceRow(Safeguard.CatActionResponseObj data, bool addLine)
|
| | | {
|
| | | //行控件
|
| | | var row = new DeviceRoomControl(data.DeviceAddr, data.Epoint, listView.rowSpace / 2);
|
| | | listView.AddChidren(row);
|
| | | row.InitControl();
|
| | | row.frameTable.UseClickStatu = false;
|
| | | if (addLine == true)
|
| | | {
|
| | | //底线
|
| | | row.frameTable.AddBottomLine();
|
| | | }
|
| | | //状态显示
|
| | | var btnStatu = row.frameTable.AddMostRightView("", 400);
|
| | | if (data.TaskList.Count > 0)
|
| | | {
|
| | | btnStatu.Text = HdlSafeguardLogic.Current.GetAdjustTargetStatuText(data.TaskList);
|
| | | }
|
| | | else
|
| | | {
|
| | | //无动作
|
| | | btnStatu.TextID = R.MyInternationalizationString.uNotAction;
|
| | | }
|
| | |
|
| | | if (row.device != null)
|
| | | {
|
| | | //编辑
|
| | | var btnEditor = row.AddEditorControl();
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //编辑报警目标
|
| | | this.EditorAlarmTarget(row, btnStatu, data);
|
| | | };
|
| | | }
|
| | |
|
| | | //删除
|
| | | var btnDelete = row.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //删除
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //删除报警目标
|
| | | this.DeleteAlarmTarget(row, data);
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加场景行
|
| | | /// </summary>
|
| | | /// <param name="data"></param>
|
| | | /// <param name="addLine"></param>
|
| | | private void AddSceneRow(Safeguard.CatActionResponseObj data, bool addLine)
|
| | | {
|
| | | //行控件
|
| | | var row = new SceneRoomControl(data.ScenesId, data.ESName, listView.rowSpace / 2);
|
| | | listView.AddChidren(row);
|
| | | row.InitControl();
|
| | | row.frameTable.UseClickStatu = false;
|
| | |
|
| | | if (addLine == true)
|
| | | {
|
| | | //底线
|
| | | row.frameTable.AddBottomLine();
|
| | | }
|
| | |
|
| | | //删除
|
| | | var btnDelete = row.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //删除报警目标
|
| | | this.DeleteAlarmTarget(row, data);
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 删除指定报警目标___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 删除指定报警目标
|
| | | /// </summary>
|
| | | /// <param name="row"></param>
|
| | | /// <param name="delObj"></param>
|
| | | private async void DeleteAlarmTarget(RowLayoutControl row, Safeguard.CatActionResponseObj delObj)
|
| | | {
|
| | | //参数
|
| | | var Pra = new List<Safeguard.DelAlarmActionObj>();
|
| | | var actionObj = new Safeguard.DelAlarmActionObj();
|
| | | actionObj.DeviceAddr = delObj.DeviceAddr;
|
| | | actionObj.Epoint = delObj.Epoint;
|
| | | actionObj.ScenesId = delObj.ScenesId;
|
| | | actionObj.Type = delObj.Type;
|
| | | Pra.Add(actionObj);
|
| | |
|
| | | //执行删除
|
| | | bool result = await HdlSafeguardLogic.Current.DeleteAlarmTaget(this.zoonID, Pra);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //行移除
|
| | | row?.RemoveFromParent();
|
| | | //调整真实高度
|
| | | listView.AdjustRealHeight(Application.GetRealHeight(23));
|
| | | if (listView.ChildrenCount == 0)
|
| | | {
|
| | | //重新初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | return;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 编辑指定报警目标___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 编辑指定报警目标
|
| | | /// </summary>
|
| | | /// <param name="btnStatu"></param>
|
| | | /// <param name="resObj"></param>
|
| | | private void EditorAlarmTarget(DeviceRoomControl deviceRow, NormalViewControl btnStatu, Safeguard.CatActionResponseObj resObj)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(resObj.DeviceAddr, resObj.Epoint);
|
| | | if (device.Type == DeviceType.DimmableLight//调光器
|
| | | || device.Type == DeviceType.ColorDimmableLight)//彩灯
|
| | | {
|
| | | var form = new AlarmTargetStatuSelectLightForm();
|
| | | form.AddForm(device, resObj.TaskList);
|
| | | form.FinishSelectEvent += (statuText, listInfo) =>
|
| | | {
|
| | | //还原左右菜单
|
| | | deviceRow?.HideMenu();
|
| | | btnStatu.Text = statuText;
|
| | | //保存编辑的报警目标
|
| | | this.SaveEditorAlarmTarget(resObj, listInfo);
|
| | | };
|
| | | }
|
| | | else if (device.Type == DeviceType.WindowCoveringDevice)//窗帘
|
| | | {
|
| | | var form = new AlarmTargetStatuSelectCurtainForm();
|
| | | form.AddForm(device, resObj.TaskList);
|
| | | form.FinishSelectEvent += (statuText, listInfo) =>
|
| | | {
|
| | | //还原左右菜单
|
| | | deviceRow?.HideMenu();
|
| | | btnStatu.Text = statuText;
|
| | | //保存编辑的报警目标
|
| | | this.SaveEditorAlarmTarget(resObj, listInfo);
|
| | | };
|
| | | }
|
| | | else
|
| | | {
|
| | | //其他直接归为开关类
|
| | | var form = new AlarmTargetStatuSelectSwitchForm();
|
| | | form.AddForm(device, resObj.TaskList);
|
| | | form.FinishSelectEvent += (statuText, listInfo) =>
|
| | | {
|
| | | //还原左右菜单
|
| | | deviceRow?.HideMenu();
|
| | | btnStatu.Text = statuText;
|
| | | //保存编辑的报警目标
|
| | | this.SaveEditorAlarmTarget(resObj, listInfo);
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 保存编辑的报警目标
|
| | | /// </summary>
|
| | | /// <param name="resObj"></param>
|
| | | /// <param name="listTask"></param>
|
| | | private async void SaveEditorAlarmTarget(Safeguard.CatActionResponseObj resObj, List<Safeguard.TaskListInfo> listTask)
|
| | | {
|
| | | //先删除 参数
|
| | | var PraDel = new List<Safeguard.DelAlarmActionObj>();
|
| | | var actionObjDel = new Safeguard.DelAlarmActionObj();
|
| | | actionObjDel.DeviceAddr = resObj.DeviceAddr;
|
| | | actionObjDel.Epoint = resObj.Epoint;
|
| | | actionObjDel.ScenesId = resObj.ScenesId;
|
| | | actionObjDel.Type = resObj.Type;
|
| | | PraDel.Add(actionObjDel);
|
| | |
|
| | | //执行删除
|
| | | bool result = await HdlSafeguardLogic.Current.DeleteAlarmTaget(this.zoonID, PraDel);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //然后再添加
|
| | | var listAction = new List<Safeguard.AlarmActionObj>();
|
| | | var actionObjAdd = new Safeguard.AlarmActionObj();
|
| | | actionObjAdd.DeviceAddr = resObj.DeviceAddr;
|
| | | actionObjAdd.Epoint = resObj.Epoint;
|
| | | actionObjAdd.Type = 0;
|
| | | actionObjAdd.TaskList = listTask;
|
| | | listAction.Add(actionObjAdd);
|
| | |
|
| | | //添加报警目标到安防
|
| | | bool success = await HdlSafeguardLogic.Current.AddAlarmTagetToSafety(this.zoonID, listAction);
|
| | | if (success == true)
|
| | | {
|
| | | resObj.TaskList.Clear();
|
| | | resObj.TaskList.AddRange(listTask);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 界面重新激活事件___________________ |
| | |
|
| | | /// <summary>
|
| | | /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
|
| | | /// </summary> |
| | | public override int FormActionAgainEvent()
|
| | | {
|
| | | //重新刷新界面
|
| | | this.InitMiddleFrame();
|
| | |
|
| | | return 1;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|