| | |
| | | /// <summary>
|
| | | /// 添加报警目标指定设备类型的设备列表
|
| | | /// </summary>
|
| | | public class AddDeviceAlarmTargetListForm : UserCenterCommonForm
|
| | | public class AddDeviceAlarmTargetListForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalScrolViewLayout listView = null;
|
| | | private VerticalListControl listView = null;
|
| | | /// <summary>
|
| | | /// 防区ID(这个东西似乎是唯一的)
|
| | | /// </summary>
|
| | |
| | | /// </summary>
|
| | | private List<uDeviceInfo> listAllDevice = null;
|
| | | /// <summary>
|
| | | /// 现存的报警目标
|
| | | /// </summary>
|
| | | private Dictionary<string, Safeguard.CatActionResponseObj> dicAlarmDevice = null;
|
| | | /// <summary>
|
| | | /// 需要添加的报警设备
|
| | | /// </summary>
|
| | | private Dictionary<string, TaskInfoData> dicSaveDevice = new Dictionary<string, TaskInfoData>();
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | |
| | | //设置头部信息
|
| | | base.SetTitleText(i_deviceText);
|
| | |
|
| | | //完成
|
| | | var btnfinish = new TopLayoutFinshView();
|
| | | topFrameLayout.AddChidren(btnfinish); |
| | | btnfinish.MouseUpEventHandler += (sender, e) => |
| | | {
|
| | | //保存选择的设备
|
| | | this.DoSaveSelectDeviceAsync();
|
| | | };
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame(i_deviceText);
|
| | | }
|
| | |
| | | /// <param name="titleText">列表头部名称</param>
|
| | | private void InitMiddleFrame(string titleText)
|
| | | {
|
| | | //XXX列表
|
| | | var btnTitle = new TitleViewControl();
|
| | | btnTitle.TextColor = UserCenterColor.Current.TextGrayColor;
|
| | | btnTitle.Y = Application.GetRealHeight(60);
|
| | | btnTitle.Text = titleText + Language.StringByID(R.MyInternationalizationString.uList);
|
| | | bodyFrameLayout.AddChidren(btnTitle);
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | this.listView = new VerticalScrolViewLayout();
|
| | | this.listView.Y = btnTitle.Bottom;
|
| | | this.listView.Height = bodyFrameLayout.Height - btnTitle.Bottom;
|
| | | //完成
|
| | | var btnfinish = new BottomClickButton();
|
| | | btnfinish.TextID = R.MyInternationalizationString.uFinish;
|
| | | bodyFrameLayout.AddChidren(btnfinish);
|
| | | btnfinish.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //保存选择的设备
|
| | | this.DoSaveSelectDeviceAsync();
|
| | | };
|
| | |
|
| | | //XXX列表
|
| | | var frameTemp = new FrameLayout();
|
| | | frameTemp.Height = Application.GetRealHeight(60 + 52);
|
| | | frameTemp.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(frameTemp);
|
| | |
|
| | | var btnTitle = new NormalViewControl(850, 60, true);
|
| | | btnTitle.X = ControlCommonResourse.XXLeft;
|
| | | btnTitle.Y = Application.GetRealHeight(52);
|
| | | btnTitle.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnTitle.Text = titleText + Language.StringByID(R.MyInternationalizationString.uList);
|
| | | btnTitle.TextSize = 15;
|
| | | frameTemp.AddChidren(btnTitle);
|
| | |
|
| | | this.listView = new VerticalListControl(29);
|
| | | listView.Y = frameTemp.Bottom;
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | listView.Height = btnfinish.Y - ControlCommonResourse.BottomButtonAndListViewSpace - frameTemp.Bottom;
|
| | | bodyFrameLayout.AddChidren(this.listView);
|
| | |
|
| | | //设置中部信息
|
| | |
| | | {
|
| | | new System.Threading.Thread(() =>
|
| | | {
|
| | | //获取现存的报警设备
|
| | | var listData = Common.LocalSafeguard.Current.GetLocalAlarmTargetInfoByZoneId(this.zoonID);
|
| | | dicAlarmDevice = new Dictionary<string, Safeguard.CatActionResponseObj>();
|
| | | foreach (var data in listData)
|
| | | if (this.Parent == null)
|
| | | {
|
| | | if (data.Type == 1)
|
| | | {
|
| | | //不需要场景
|
| | | continue;
|
| | | }
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
|
| | | dicAlarmDevice[mainkeys] = data;
|
| | | return;
|
| | | }
|
| | |
|
| | | foreach (var deviceInfo in listAllDevice)
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //如果那个设备已经添加了,则不再显示
|
| | | if (Common.LocalSafeguard.Current.IsAlarmDeviceExist(this.zoonID, deviceInfo.Device) == true)
|
| | | int count = listAllDevice.Count - 1;
|
| | | for (int i = 0; i < listAllDevice.Count; i++)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //如果那个设备已经添加了,则不再显示
|
| | | if (HdlSafeguardLogic.Current.IsAlarmDeviceExist(this.zoonID, listAllDevice[i].Device) == true)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | //添加行目标
|
| | | this.AddRowLayout(deviceInfo);
|
| | | });
|
| | | }
|
| | | this.AddRowLayout(listAllDevice[i], i != count);
|
| | | }
|
| | | if (listView.ChildrenCount > 0)
|
| | | {
|
| | | int realHeight = (listView.GetChildren(listView.ChildrenCount - 1).Height) * listView.ChildrenCount + Application.GetRealHeight(23);
|
| | | if (realHeight < listView.Height)
|
| | | {
|
| | | //调整真实高度
|
| | | listView.Height = realHeight;
|
| | | }
|
| | | }
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 添加行目标_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加行目标
|
| | | /// </summary>
|
| | | /// <param name="deviceInfo"></param>
|
| | | private void AddRowLayout(uDeviceInfo deviceInfo)
|
| | | /// <param name="addLine"></param>
|
| | | private void AddRowLayout(uDeviceInfo deviceInfo, bool addLine)
|
| | | {
|
| | | var row = new DeviceRoomViewRow(this.listView, deviceInfo.Device, deviceInfo.listRoomName);
|
| | | var row = new DeviceRoomControl(deviceInfo.Device, listView.rowSpace / 2);
|
| | | listView.AddChidren(row);
|
| | | row.InitControl();
|
| | | //添加向右的图标
|
| | | row.AddRightIconControl();
|
| | | row.frameTable.AddRightArrow();
|
| | | //底线
|
| | | if (addLine == true)
|
| | | {
|
| | | row.frameTable.AddBottomLine();
|
| | | }
|
| | |
|
| | | //状态显示
|
| | | var btnStatu = new RowSecondRightTextView();
|
| | | row.AddChidren(btnStatu);
|
| | |
|
| | | var btnStatu = row.frameTable.AddMostRightView("", 400);
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(deviceInfo.Device);
|
| | | List<Safeguard.TaskListInfo> listTaskinfo = null;
|
| | | if (this.dicAlarmDevice.ContainsKey(mainKeys) == true)
|
| | |
|
| | | row.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //显示现存的状态文本
|
| | | listTaskinfo = this.dicAlarmDevice[mainKeys].TaskList;
|
| | | btnStatu.Text = SafeguardLogic.GetLightAlarmStatuText(listTaskinfo);
|
| | | btnStatu.TextColor = UserCenterColor.Current.Green;
|
| | | List<Safeguard.TaskListInfo> listTaskinfo = null;
|
| | | if (dicSaveDevice.ContainsKey(mainKeys) == true)
|
| | | {
|
| | | //取缓存中还未保存的数据
|
| | | listTaskinfo = dicSaveDevice[mainKeys].listInfos;
|
| | | }
|
| | |
|
| | | if (deviceInfo.Device.Type == DeviceType.DimmableLight//调光器
|
| | | || deviceInfo.Device.Type == DeviceType.ColorDimmableLight)//彩灯
|
| | | {
|
| | | var form = new LightAlarmSettionForm();
|
| | | form.AddForm(deviceInfo.Device, listTaskinfo);
|
| | | form.ActionFormClose += (statuText, listInfo) =>
|
| | | {
|
| | | btnStatu.Text = statuText;
|
| | | //将新的报警目标添加入缓存
|
| | | this.AddAlarmSettionDataToMemory(deviceInfo, listInfo);
|
| | | };
|
| | | }
|
| | | else if (deviceInfo.Device.Type == DeviceType.WindowCoveringDevice)//窗帘
|
| | | {
|
| | | var form = new CurtainAlarmSettionForm();
|
| | | form.AddForm(deviceInfo.Device, listTaskinfo);
|
| | | form.ActionFormClose += (statuText, listInfo) =>
|
| | | {
|
| | | btnStatu.Text = statuText;
|
| | | //将新的报警目标添加入缓存
|
| | | this.AddAlarmSettionDataToMemory(deviceInfo, listInfo);
|
| | | };
|
| | | }
|
| | | else
|
| | | {
|
| | | //其他直接归为开关类
|
| | | var form = new SwitchAlarmSettionForm();
|
| | | form.AddForm(deviceInfo.Device, listTaskinfo);
|
| | | form.ActionFormClose += (statuText, listInfo) =>
|
| | | {
|
| | | btnStatu.Text = statuText;
|
| | | //将新的报警目标添加入缓存
|
| | | this.AddAlarmSettionDataToMemory(deviceInfo, listInfo);
|
| | | };
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 将新的报警目标添加入缓存
|
| | | /// </summary>
|
| | | /// <param name="deviceInfo"></param>
|
| | | /// <param name="listInfo"></param>
|
| | | private void AddAlarmSettionDataToMemory(uDeviceInfo deviceInfo, List<Safeguard.TaskListInfo> listInfo)
|
| | | {
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(deviceInfo.Device);
|
| | | if (listInfo == null || listInfo.Count == 0)
|
| | | {
|
| | | //指定为无动作模式
|
| | | if (this.dicSaveDevice.ContainsKey(mainKeys) == true)
|
| | | {
|
| | | this.dicSaveDevice.Remove(mainKeys);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | //无动作
|
| | | btnStatu.TextID = R.MyInternationalizationString.uNotAction;
|
| | | }
|
| | | row.MouseUpEvent += (sender, e) =>
|
| | | {
|
| | | var form = new LightAlarmSettionForm();
|
| | | this.AddForm(form, deviceInfo.Device, listTaskinfo);
|
| | | form.formCloseEvent += (statuText, listInfo) =>
|
| | | {
|
| | | btnStatu.Text = statuText;
|
| | | if (listInfo == null)
|
| | | {
|
| | | //指定为无动作模式
|
| | | if (this.dicSaveDevice.ContainsKey(mainKeys) == true)
|
| | | {
|
| | | this.dicSaveDevice.Remove(mainKeys);
|
| | | }
|
| | | btnStatu.TextColor = UserCenterColor.Current.TextColor;
|
| | | }
|
| | | else
|
| | | {
|
| | | //确认添加动作
|
| | | var data = new TaskInfoData();
|
| | | this.dicSaveDevice[mainKeys] = data;
|
| | | data.MacAddress = deviceInfo.Device.DeviceAddr;
|
| | | data.Epoint = deviceInfo.Device.DeviceEpoint;
|
| | | data.listInfos = listInfo;
|
| | | //确认添加动作
|
| | | var data = new TaskInfoData();
|
| | | this.dicSaveDevice[mainKeys] = data;
|
| | | data.MacAddress = deviceInfo.Device.DeviceAddr;
|
| | | data.Epoint = deviceInfo.Device.DeviceEpoint;
|
| | | data.listInfos.AddRange(listInfo);
|
| | |
|
| | | btnStatu.TextColor = UserCenterColor.Current.Green;
|
| | | }
|
| | | };
|
| | | };
|
| | | listInfo = null;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 保存选择的设备_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 保存选择的设备
|
| | |
| | | this.ShowProgressBar();
|
| | |
|
| | | //添加报警目标到安防
|
| | | bool success = await Common.LocalSafeguard.Current.AddAlarmTagetToSafety(this.zoonID, listAction);
|
| | | bool success = await HdlSafeguardLogic.Current.AddAlarmTagetToSafety(this.zoonID, listAction);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | |
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //刷新一览画面
|
| | | this.LoadFormMethodByName("AlarmTargetSettionForm", "SetMiddleInfo");
|
| | | //关闭自身
|
| | | this.CloseForm();
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 结构体_______________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 报警目标数据
|
| | |
| | | /// </summary>
|
| | | public List<Safeguard.TaskListInfo> listInfos = new List<Safeguard.TaskListInfo>();
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|