黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
@@ -44,31 +44,31 @@
        #endregion
        #region ■ 初始化_____________________________
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_iasZone">传感器设备</param>
        public void ShowForm(IASZone i_iasZone)
        /// <param name="i_iasZone">传感器设备</param>
        public void ShowForm(IASZone i_iasZone)
        {
            this.ScrollEnabled = false;
            deviceIASZone = i_iasZone;
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBindTargets));
            HdlThreadLogic.Current.RunThread(() =>
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBindTargets));
            HdlThreadLogic.Current.RunThread(() =>
            {
                //初始化中部信息
                this.InitMiddleFrame();
            });
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private async void InitMiddleFrame()
            });
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private async void InitMiddleFrame()
        {
            this.listEsixtDevice.Clear();
@@ -82,7 +82,7 @@
            {
                //初始化控件
                this.InitMiddleControl();
            });
            });
        }
        /// <summary>
@@ -102,6 +102,11 @@
            var btnLux = frameNowLinght.AddLeftCaption(txtValue + ":" + pirLuxValue + "lux", 900);
            HdlThreadLogic.Current.RunThread(async () =>
            {
                //查看模板时,不允许编辑
                if (Common.Config.Instance.Home.IsShowTemplate == true)
                {
                    return;
                }
                while (this.Parent != null)
                {
                    //他们说这个东西要2秒刷新一次  获取PIR传感器的【lux值】
@@ -167,7 +172,7 @@
            btnLightView.TextID = R.MyInternationalizationString.uIlluminationValue;
            btnLightView.TextSize = 12;
            btnLightView.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnLightView.X = ControlCommonResourse.XXLeft;
            btnLightView.X = HdlControlResourse.XXLeft;
            btnLightView.Y = Application.GetRealHeight(71);
            frameLight.AddChidren(btnLightView);
            var btnLightValue = new NormalViewControl(200, 50, true);
@@ -233,6 +238,14 @@
                this.pirConfigure.levelSize = seekBar.Progress;
                btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
            };
            //查看模板时,不允许编辑
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                btnSwitch.CanClick = false;
                seekBar.Enable = false;
                btnMinus.CanClick = false;
                btnPlus.CanClick = false;
            }
            //暗
            var btnDark = new NormalViewControl(120, 50, true);
@@ -287,8 +300,8 @@
            frameLight.AddChidren(btnTipView);
            //底线
            var btnIfLine = new NormalViewControl(frameLight.Width, ControlCommonResourse.BottomLineHeight, false);
            btnIfLine.Y = frameLight.Height - ControlCommonResourse.BottomLineHeight;
            var btnIfLine = new NormalViewControl(frameLight.Width, HdlControlResourse.BottomLineHeight, false);
            btnIfLine.Y = frameLight.Height - HdlControlResourse.BottomLineHeight;
            btnIfLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            frameLight.AddChidren(btnIfLine);
@@ -330,7 +343,7 @@
            listView.AddChidren(frameResult);
            //触发目标
            var rowTarget = new FrameRowControl(listView.rowSpace / 2);
            rowTarget.LeftOffset = Application.GetRealWidth(138) - ControlCommonResourse.XXLeft;
            rowTarget.LeftOffset = Application.GetRealWidth(138) - HdlControlResourse.XXLeft;
            frameResult.AddChidren(rowTarget);
            rowTarget.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uTriggerTarget), 600);
            rowTarget.AddRightArrow();
@@ -347,8 +360,8 @@
                    if (listSaveDevice.Count > 0)
                    {
                        //随便丢一个名字上去
                        var device = Common.LocalDevice.Current.GetDevice(listSaveDevice[0]);
                        btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
                        var device = HdlDeviceCommonLogic.Current.GetDevice(listSaveDevice[0]);
                        btnTargetView.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
                    }
                    else
                    {
@@ -360,11 +373,11 @@
            foreach (string mainkey in this.listEsixtDevice)
            {
                var device = Common.LocalDevice.Current.GetDevice(mainkey);
                var device = HdlDeviceCommonLogic.Current.GetDevice(mainkey);
                if (device != null)
                {
                    //随便丢一个名字上去
                    btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
                    btnTargetView.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
                    break;
                }
            }
@@ -379,7 +392,7 @@
                }
                string strSecond = pirConfigure.transitionTime % 60 + Language.StringByID(R.MyInternationalizationString.uSecond);
                var rowDelay = new FrameRowControl(listView.rowSpace / 2);
                rowDelay.LeftOffset = Application.GetRealWidth(138) - ControlCommonResourse.XXLeft;
                rowDelay.LeftOffset = Application.GetRealWidth(138) - HdlControlResourse.XXLeft;
                frameResult.AddChidren(rowDelay);
                rowDelay.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uDelayed), 300);
                rowDelay.AddRightArrow();
@@ -388,8 +401,12 @@
                {
                    this.ShowDelayListTime(btnDelayView);
                };
                //查看模板时,不允许编辑
                if (Common.Config.Instance.Home.IsShowTemplate == true)
                {
                    rowDelay.CanClick = false;
                }
            }
            //保存
            var btnSave = new BottomClickButton();
            btnSave.TextID = R.MyInternationalizationString.uSave;
@@ -402,6 +419,11 @@
                    this.SavePirSensorData();
                });
            };
            //查看模板时,不允许编辑
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                btnSave.CanClick = false;
            }
        }
        #endregion
@@ -418,7 +440,7 @@
            this.ShowProgressBar();
            //获取绑定目标设备
            List<CommonDevice> listDevice = await HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
            List<CommonDevice> listDevice = HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
            if (listDevice == null)
            {
                //关闭进度条
@@ -428,7 +450,7 @@
            this.listEsixtDevice.Clear();
            foreach (var device in listDevice)
            {
                string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
                string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
                if (listEsixtDevice.Contains(mainKeys) == false)
                {
                    listEsixtDevice.Add(mainKeys);
@@ -448,7 +470,7 @@
            }
            //获取pir的配置信息
            this.pirConfigure = await HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
            this.pirConfigure = HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
            if (pirConfigure == null)
            {
                //关闭进度条
@@ -520,7 +542,13 @@
            PickerView.ShowSecondary(listfirst, listSecond, (value1, value2) =>
             {
                 btnTime.Text = listfirst[value1] + listSecond[value1][value2];
                 string textValue = listSecond[value1][value2];
                 if (value1 != 0)
                 {
                     textValue = listfirst[value1].TrimStart('0') + textValue;
                 }
                 btnTime.Text = textValue;
                 int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2));
                 int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
                 int delaySecond = minute * 60 + second;
@@ -541,7 +569,7 @@
        /// <summary>
        /// 保存Pir传感器数据
        /// </summary>
        private async void SavePirSensorData()
        private void SavePirSensorData()
        {
            if (this.isDataChanged == false)
            {
@@ -565,7 +593,7 @@
                {
                    if (this.listSaveDevice.Contains(mainKey) == false)
                    {
                        var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
                        var myDevice = HdlDeviceCommonLogic.Current.GetDevice(mainKey);
                        listDelDevice.Add(myDevice);
                        if (myDevice.Type == DeviceType.DimmableLight)
                        {
@@ -577,7 +605,7 @@
                if (listDelDevice.Count > 0)
                {
                    //删除目标
                    var listSucess = await HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listDelDevice);
                    var listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listDelDevice);
                    if (listSucess == null || listSucess.Count == 0)
                    {
                        //关闭进度条
@@ -587,7 +615,7 @@
                    if (listLightDevice.Count > 0)
                    {
                        //删除调光器镞
                        listSucess = await HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listLightDevice, 8);
                        listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listLightDevice, 8);
                        if (listSucess == null || listSucess.Count == 0)
                        {
                            //关闭进度条
@@ -601,7 +629,7 @@
                listLightDevice = new List<CommonDevice>();
                foreach (var mainKey in listSaveDevice)
                {
                    var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
                    var myDevice = HdlDeviceCommonLogic.Current.GetDevice(mainKey);
                    listBind.Add(myDevice);
                    if (myDevice.Type == DeviceType.DimmableLight)
                    {
@@ -612,7 +640,7 @@
                if (listSaveDevice.Count > 0)
                {
                    //绑定目标
                    var listSucess = await HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listBind);
                    var listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listBind);
                    if (listSucess == null || listSucess.Count == 0)
                    {
                        //关闭进度条
@@ -622,7 +650,7 @@
                    if (listLightDevice.Count > 0)
                    {
                        //绑定调光镞
                        listSucess = await HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listLightDevice, 8);
                        listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listLightDevice, 8);
                        if (listSucess == null || listSucess.Count == 0)
                        {
                            //关闭进度条
@@ -633,7 +661,7 @@
                }
            }
            //保存pir配置信息
            var result = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure);
            var result = HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure);
            if (result == false)
            {
                //关闭进度条