| | |
| | | /// <summary>
|
| | | /// 已经设置了的传感器的一览画面
|
| | | /// </summary>
|
| | | public class SensorDeviceSettionListForm : UserCenterCommonForm
|
| | | public class SensorDeviceSettionListForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalScrolViewLayout listView = null;
|
| | | private VerticalListControl listView = null;
|
| | | /// <summary>
|
| | | /// 防区ID
|
| | | /// </summary>
|
| | |
| | | base.SetTitleText(SectorsName + Language.StringByID(R.MyInternationalizationString.uSettion));
|
| | |
|
| | | //右上角的“+”图标
|
| | | var btnTopIcon = new TopLayoutMostRightView();
|
| | | var btnTopIcon = new MostRightIconControl(69, 69);
|
| | | btnTopIcon.UnSelectedImagePath = "Item/Add.png";
|
| | | btnTopIcon.SelectedImagePath = "Item/AddSelected.png";
|
| | | topFrameLayout.AddChidren(btnTopIcon);
|
| | | btnTopIcon.MouseUpEventHandler += (sender, e) =>
|
| | | btnTopIcon.InitControl();
|
| | | btnTopIcon.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //添加新的传感器
|
| | | this.AddNewSensorDevice();
|
| | | };
|
| | |
|
| | | listView = new VerticalScrolViewLayout();
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | listView = new VerticalListControl(29);
|
| | | listView.Y = Application.GetRealHeight(-6);
|
| | | listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | //初始化传感器列表信息
|
| | |
| | | private void InitSensorDevicesListInfo()
|
| | | {
|
| | | this.listView.RemoveAll();
|
| | | listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
|
| | |
|
| | | //获取指定防区全部的传感器设备的信息
|
| | | var listInfo = Common.LocalSafeguard.Current.GetSensorDevicesInfoByZoonID(this.zoonID);
|
| | | var listInfo = HdlSafeguardLogic.Current.GetSensorDevicesInfoByZoonID(this.zoonID);
|
| | | if (listInfo.Count == 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | new System.Threading.Thread(() =>
|
| | | {
|
| | | foreach (var info in listInfo)
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | int count = listInfo.Count - 1;
|
| | | for (int i = 0; i < listInfo.Count; i++)
|
| | | {
|
| | | this.AddRowLayout(info);
|
| | | });
|
| | | }
|
| | | if (this.Parent != null)
|
| | | {
|
| | | this.AddRowLayout(listInfo[i], i != count);
|
| | | }
|
| | | }
|
| | | if (listView.ChildrenCount == 0)
|
| | | {
|
| | | //没有合法的传感器
|
| | | return;
|
| | | }
|
| | | //调整列表控件的高度
|
| | | this.AdjustListviewHeight();
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | |
| | | /// 添加行
|
| | | /// </summary>
|
| | | /// <param name="sensorInfo">传感器信息</param>
|
| | | private void AddRowLayout(Safeguard.ZoneDeviceListData sensorInfo)
|
| | | /// <param name="addLine">是否添加底线</param>
|
| | | private void AddRowLayout(Safeguard.ZoneDeviceListData sensorInfo, bool addLine)
|
| | | {
|
| | | CommonDevice device = Common.LocalDevice.Current.GetDevice(sensorInfo.MacAddr, sensorInfo.Epoint);
|
| | | if (device == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | var rowLayout = new RowLayout();
|
| | | rowLayout.Height = ControlCommonResourse.ListViewRowHeight;
|
| | | //自定义控件
|
| | | var rowLayout = new DeviceRoomControl(device, listView.rowSpace / 2);
|
| | | listView.AddChidren(rowLayout);
|
| | |
|
| | | //图标
|
| | | var btnIcon = new RowLeftIconView();
|
| | | Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
|
| | | rowLayout.AddChidren(btnIcon);
|
| | |
|
| | | //设备名
|
| | | var btnDevice = new RowTopBlackView();
|
| | | btnDevice.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | rowLayout.AddChidren(btnDevice);
|
| | |
|
| | | //房间
|
| | | var btnRoom = new RowBottomGrayView();
|
| | | btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device);
|
| | | rowLayout.AddChidren(btnRoom);
|
| | |
|
| | | rowLayout.InitControl();
|
| | | rowLayout.frameTable.UseClickStatu = false;
|
| | | if (addLine == true)
|
| | | {
|
| | | //底线
|
| | | rowLayout.frameTable.AddBottomLine();
|
| | | }
|
| | | //旁路状态
|
| | | var txtStatu = new RowMostRightTextView();
|
| | | txtStatu.TextColor = UserCenterColor.Current.Red;
|
| | | rowLayout.AddChidren(txtStatu);
|
| | | var txtStatu = rowLayout.frameTable.AddMostRightView("", 350);
|
| | | txtStatu.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | |
|
| | | //旁路设置
|
| | | var btnBypass = new RowBypassButton();
|
| | | var btnBypass = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false);
|
| | | btnBypass.TextID = R.MyInternationalizationString.uBypass; |
| | | btnBypass.BackgroundColor = 0xff4a4a4a; |
| | | btnBypass.TextColor = UserCenterColor.Current.TextColor3; |
| | | btnBypass.TextAlignment = TextAlignment.Center;
|
| | | btnBypass.TextSize = 12;
|
| | | if (sensorInfo.IsBypass == 1)
|
| | | {
|
| | | //已设置旁路
|
| | |
| | | btnBypass.TextID = R.MyInternationalizationString.uCancelBypass;
|
| | | }
|
| | | rowLayout.AddLeftView(btnBypass);
|
| | | btnBypass.MouseUpEventHandler += (sender, e) =>
|
| | | btnBypass.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //设置旁路状态
|
| | | this.SetBypassStatu(sensorInfo, device);
|
| | | };
|
| | |
|
| | | //删除
|
| | | var btnDelete = new RowDeleteButton();
|
| | | var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false);
|
| | | btnDelete.TextID = R.MyInternationalizationString.uDelete; |
| | | btnDelete.BackgroundColor = 0xfff75858; |
| | | btnDelete.TextColor = UserCenterColor.Current.TextColor3; |
| | | btnDelete.TextAlignment = TextAlignment.Center;
|
| | | btnDelete.TextSize = 12;
|
| | | rowLayout.AddRightView(btnDelete);
|
| | | btnDelete.MouseUpEventHandler += (sender, e) =>
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //确认是否要删除?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
|
| | | this.ShowConfirmMsg(msg, "DeleteRow", rowLayout, device);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //删除传感器行
|
| | | this.DeleteRow(rowLayout, device);
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="rowLayout"></param>
|
| | | /// <param name="device"></param>
|
| | | public async void DeleteRow(RowLayout rowLayout, CommonDevice device)
|
| | | private async void DeleteRow(DeviceRoomControl rowLayout, CommonDevice device)
|
| | | {
|
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | bool result = await Common.LocalSafeguard.Current.DeleteSensorDevice(this.zoonID, new List<CommonDevice>() { device });
|
| | | bool result = await HdlSafeguardLogic.Current.DeleteSensorDevice(this.zoonID, new List<CommonDevice>() { device });
|
| | |
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //从画面中移除
|
| | | rowLayout.RemoveFromParent();
|
| | | rowLayout?.RemoveFromParent();
|
| | | //调节列表控件的高度
|
| | | this.AdjustListviewHeight();
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | //变更状态
|
| | | int statu = sensorInfo.IsBypass == 1 ? 0 : 1;
|
| | |
|
| | | bool result = await Common.LocalSafeguard.Current.SetByPassStatuToSafety(this.zoonID, device, statu);
|
| | | bool result = await HdlSafeguardLogic.Current.SetByPassStatuToSafety(this.zoonID, device, statu);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | |
| | |
|
| | | //显示选择界面
|
| | | var form = new SelectDeviceForm();
|
| | | this.AddForm(form, list, new List<string>(), true);
|
| | | form.AddForm(list, new List<string>(), true);
|
| | | form.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddSensor));
|
| | |
|
| | | //设备选择确定
|
| | |
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | | //添加设备到安防
|
| | | bool success = await Common.LocalSafeguard.Current.AddSensorDevice(this.zoonID, listDevice);
|
| | | bool success = await HdlSafeguardLogic.Current.AddSensorDevice(this.zoonID, listDevice);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | |
| | | continue;
|
| | | }
|
| | | //如果那个设备已经添加了,则不再显示
|
| | | if (Common.LocalSafeguard.Current.IsSensorDeviceExist(device) == true)
|
| | | if (HdlSafeguardLogic.Current.IsSensorDeviceExist(device) == true)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 调节列表控件的高度
|
| | | /// </summary>
|
| | | private void AdjustListviewHeight()
|
| | | {
|
| | | if (listView.ChildrenCount == 0)
|
| | | {
|
| | | //直接拉满屏幕
|
| | | listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
|
| | | return;
|
| | | }
|
| | | var realHeight = listView.ChildrenCount * listView.GetChildren(listView.ChildrenCount - 1).Height;
|
| | | realHeight += listView.rowSpace;
|
| | | if (realHeight < listView.Height)
|
| | | {
|
| | | //缩小控件高度
|
| | | listView.Height = realHeight;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|