黄学彪
2019-11-04 c7698e163e43cea9e7f8ee45f8e3f91c9265cca4
ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs
File was renamed from ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs
@@ -8,7 +8,7 @@
    /// <summary>
    /// 已经设置了的传感器的一览画面
    /// </summary>
    public class SensorDeviceSettionListForm : EditorCommonForm
    public class GarrisonAreaExistSensorForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
@@ -48,12 +48,6 @@
                this.AddNewSensorDevice();
            };
            listView = new VerticalListControl(29);
            listView.Y = Application.GetRealHeight(-6);
            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
            //初始化传感器列表信息
            this.InitSensorDevicesListInfo();
        }
@@ -63,35 +57,34 @@
        /// </summary>
        private void InitSensorDevicesListInfo()
        {
            this.listView.RemoveAll();
            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
            //清空bodyFrameLayout
            this.ClearBodyFrame();
            //获取指定防区全部的传感器设备的信息
            var listInfo = HdlSafeguardLogic.Current.GetSensorDevicesInfoByZoonID(this.zoonID);
            if (listInfo.Count == 0)
            {
                //还没有设置传感器哦
                this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDoNotHadSettionSensorMsg));
                this.listView = null;
                return;
            }
            HdlThreadLogic.Current.RunThread(() =>
            listView = new VerticalListControl(29);
            listView.Y = Application.GetRealHeight(-6);
            listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
            HdlThreadLogic.Current.RunMainInThread(() =>
            {
                Application.RunOnMainThread(() =>
                int count = listInfo.Count - 1;
                for (int i = 0; i < listInfo.Count; i++)
                {
                    int count = listInfo.Count - 1;
                    for (int i = 0; i < listInfo.Count; i++)
                    {
                        if (this.Parent != null)
                        {
                            this.AddRowLayout(listInfo[i], i != count);
                        }
                    }
                    if (listView.ChildrenCount == 0)
                    {
                        //没有合法的传感器
                        return;
                    }
                    //调整列表控件的高度
                    this.AdjustListviewHeight();
                });
                    this.AddRowLayout(listInfo[i], i != count);
                }
                //调整列表控件的高度
                this.listView.AdjustRealHeight(Application.GetRealHeight(23));
            });
        }
@@ -177,24 +170,21 @@
        /// <param name="device"></param>
        private async void DeleteRow(DeviceRoomControl rowLayout, CommonDevice device)
        {
            //开启进度条
            this.ShowProgressBar();
            bool result = await HdlSafeguardLogic.Current.DeleteSensorDevice(this.zoonID, new List<CommonDevice>() { device });
            //关闭进度条
            this.CloseProgressBar();
            if (result == false)
            {
                return;
            }
            Application.RunOnMainThread(() =>
            //从画面中移除
            rowLayout?.RemoveFromParent();
            //调整列表控件的高度
            this.listView.AdjustRealHeight(Application.GetRealHeight(23));
            if (this.listView.ChildrenCount == 0)
            {
                //从画面中移除
                rowLayout?.RemoveFromParent();
                //调节列表控件的高度
                this.AdjustListviewHeight();
            });
                //初始化传感器列表信息
                this.InitSensorDevicesListInfo();
            }
        }
        #endregion
@@ -244,27 +234,16 @@
            {
                if (listDevice.Count == 0)
                {
                    Application.RunOnMainThread(() =>
                    {
                        //关闭界面
                        form.CloseForm();
                    });
                    //关闭界面
                    form.CloseForm();
                    return;
                }
                //开启进度条
                this.ShowProgressBar();
                //添加设备到安防
                bool success = await HdlSafeguardLogic.Current.AddSensorDevice(this.zoonID, listDevice);
                //关闭进度条
                this.CloseProgressBar();
                if (success == true)
                {
                    Application.RunOnMainThread(() =>
                    {
                        //关闭界面
                        form.CloseForm();
                    });
                    //关闭界面
                    form.CloseForm();
                    //刷新列表
                    this.InitSensorDevicesListInfo();
                }
@@ -294,30 +273,6 @@
                listNew.Add(device);
            }
            return listNew;
        }
        #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