| | |
| | | /// </summary>
|
| | | private int lightLevelCount = -1;
|
| | | /// <summary>
|
| | | /// 灯光的配置
|
| | | /// PIR传感器的Lux值
|
| | | /// </summary>
|
| | | private IASZone.ConfigureParamates Lightconfigure = null;
|
| | | private int pirLuxValue = -1;
|
| | | /// <summary>
|
| | | /// 旧数据
|
| | | /// pir的配置信息
|
| | | /// </summary>
|
| | | private List<int> listOldData = new List<int>();
|
| | | private IASZone.ConfigureParamates pirConfigure = null;
|
| | | /// <summary>
|
| | | /// 数据是否改变
|
| | | /// </summary>
|
| | | private bool isDataChanged = false;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listView = new VerticalListControl(23);
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | //当前亮度值
|
| | | var frameNowLinght = new FrameRowControl();
|
| | | frameNowLinght.UseClickStatu = false;
|
| | | frameNowLinght.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(frameNowLinght);
|
| | | frameNowLinght.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowBrightnessValue) + ":" + pirLuxValue + "lux", 900);
|
| | |
|
| | | var listView = new VerticalListControl(0);
|
| | | listView.Y = Application.GetRealHeight(150);
|
| | | listView.Height = Application.GetRealHeight(585);
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | //照明等级Frame(因展开折叠,优先声明)
|
| | | var frameLight = new FrameLayout();
|
| | | frameLight.Height = Application.GetRealHeight(363);
|
| | | frameLight.Height = 0;
|
| | |
|
| | | //如果满足-----------------------------------------------------------
|
| | | //如果满足低亮度环境
|
| | | var frameIfRow = new FrameRowControl(listView.rowSpace / 2);
|
| | | frameIfRow.UseClickStatu = false;
|
| | | listView.AddChidren(frameIfRow);
|
| | | frameIfRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uIfSatisfied), 600);
|
| | | //右箭头
|
| | | var btnIfRinght = frameIfRow.AddMostRightEmptyIcon(58, 58);
|
| | | frameIfRow.ChangedChidrenBindMode(btnIfRinght, ChidrenBindMode.NotBind);
|
| | | btnIfRinght.UseClickStatu = false;
|
| | | btnIfRinght.UnSelectedImagePath = "Item/RightNext.png";
|
| | | btnIfRinght.SelectedImagePath = "Item/Down.png";
|
| | | btnIfRinght.IsSelected = true;
|
| | | btnIfRinght.ButtonClickEvent += (sender, e) =>
|
| | | frameIfRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uIfTheLowBrightnessEnvironmentIsSatisfied), 700);
|
| | | //开关按钮
|
| | | var btnSwitch = frameIfRow.AddMostRightSwitchIcon();
|
| | | btnSwitch.IsSelected = this.pirConfigure.levelEnable;
|
| | | btnSwitch.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | btnIfRinght.IsSelected = !btnIfRinght.IsSelected;
|
| | | this.isDataChanged = true;
|
| | | this.pirConfigure.levelEnable = !btnSwitch.IsSelected;
|
| | | btnSwitch.IsSelected = this.pirConfigure.levelEnable;
|
| | | //展开折叠
|
| | | frameLight.Height = frameLight.Height > 10 ? 0 : Application.GetRealHeight(363);
|
| | | if (frameLight.Height > 10)
|
| | | {
|
| | | frameLight.Height = 0;
|
| | | listView.Height -= Application.GetRealHeight(558);
|
| | | }
|
| | | else
|
| | | {
|
| | | frameLight.Height = Application.GetRealHeight(558);
|
| | | listView.Height += Application.GetRealHeight(558);
|
| | | }
|
| | | };
|
| | | //底线
|
| | | frameIfRow.AddBottomLine();
|
| | | if (btnSwitch.IsSelected == true)
|
| | | {
|
| | | frameLight.Height = Application.GetRealHeight(558);
|
| | | listView.Height += Application.GetRealHeight(558);
|
| | | }
|
| | |
|
| | | listView.AddChidren(frameLight);
|
| | | //照明等级
|
| | | var btnLight = new NormalViewControl(500, 50, true);
|
| | | btnLight.TextID = R.MyInternationalizationString.uLightLevel;
|
| | | btnLight.TextSize = 12;
|
| | | btnLight.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnLight.X = Application.GetRealWidth(138);
|
| | | btnLight.Y = Application.GetRealHeight(58);
|
| | | frameLight.AddChidren(btnLight);
|
| | | //照度值
|
| | | var btnLightView = new NormalViewControl(500, 50, true);
|
| | | btnLightView.TextID = R.MyInternationalizationString.uIlluminationValue;
|
| | | btnLightView.TextSize = 12;
|
| | | btnLightView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnLightView.X = ControlCommonResourse.XXLeft;
|
| | | btnLightView.Y = Application.GetRealHeight(71);
|
| | | frameLight.AddChidren(btnLightView);
|
| | | var btnLightValue = new NormalViewControl(200, 50, true);
|
| | | btnLightValue.Y = btnLightView.Y;
|
| | | btnLightValue.X = Application.GetRealWidth(196);
|
| | | btnLightValue.TextSize = 12;
|
| | | btnLightValue.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
|
| | | frameLight.AddChidren(btnLightValue);
|
| | |
|
| | | //进度条
|
| | | var seekBar = new SeekBarControl(900);
|
| | | var seekBar = new SeekBarControl(940);
|
| | | seekBar.Gravity = Gravity.Frame;
|
| | | seekBar.X = Application.GetRealWidth(125);
|
| | | seekBar.Y = Application.GetRealHeight(142);
|
| | | seekBar.MaxValue = lightLevelCount - 1;
|
| | | seekBar.X = Application.GetRealWidth(80);
|
| | | seekBar.Y = Application.GetRealHeight(159);
|
| | | seekBar.MaxValue = lightLevelCount;
|
| | | seekBar.ProgressBarColor = 0xfffdb500;
|
| | | frameLight.AddChidren(seekBar);
|
| | | seekBar.ProgressChangedEvent += (div, value) =>
|
| | | {
|
| | | //因为它的等级刻度从左往右是从大到小的
|
| | | this.Lightconfigure.levelSize = lightLevelCount - value;
|
| | | this.isDataChanged = true;
|
| | | this.pirConfigure.levelSize = value;
|
| | | btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
|
| | | };
|
| | | seekBar.Progress = lightLevelCount - Lightconfigure.levelSize;
|
| | | seekBar.Progress = pirConfigure.levelSize;
|
| | |
|
| | | //低
|
| | | var btnDown = new NormalViewControl(300, 50, true);
|
| | | btnDown.TextID = R.MyInternationalizationString.uLow;
|
| | | btnDown.TextSize = 12;
|
| | | btnDown.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnDown.X = Application.GetRealWidth(138);
|
| | | btnDown.Y = btnLight.Bottom + Application.GetRealHeight(115);
|
| | | frameLight.AddChidren(btnDown);
|
| | | //高
|
| | | var btnUp = new NormalViewControl(300, 50, true);
|
| | | btnUp.TextID = R.MyInternationalizationString.uHigh;
|
| | | btnUp.TextSize = 12;
|
| | | btnUp.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnUp.TextAlignment = TextAlignment.CenterRight;
|
| | | btnUp.X = frameLight.Width - ControlCommonResourse.XXLeft - Application.GetRealWidth(300);
|
| | | btnUp.Y = btnDown.Y;
|
| | | frameLight.AddChidren(btnUp);
|
| | | //减号
|
| | | var btnMinus = new IconViewControl(104);
|
| | | btnMinus.UseClickStatu = true;
|
| | | btnMinus.X = Application.GetRealWidth(847);
|
| | | btnMinus.Y = Application.GetRealHeight(45);
|
| | | btnMinus.UnSelectedImagePath = "Item/MinusSign2.png";
|
| | | btnMinus.SelectedImagePath = "Item/MinusSign2Selected.png";
|
| | | frameLight.AddChidren(btnMinus);
|
| | | btnMinus.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (seekBar.Progress <= 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.isDataChanged = true;
|
| | | seekBar.Progress -= 1;
|
| | | this.pirConfigure.levelSize = seekBar.Progress;
|
| | | btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
|
| | | };
|
| | |
|
| | | //加号
|
| | | var btnPlus = new IconViewControl(104);
|
| | | btnPlus.UseClickStatu = true;
|
| | | btnPlus.X = btnMinus.Right;
|
| | | btnPlus.Y = btnMinus.Y;
|
| | | btnPlus.UnSelectedImagePath = "Item/PlusSign2.png";
|
| | | btnPlus.SelectedImagePath = "Item/PlusSign2Selected.png";
|
| | | frameLight.AddChidren(btnPlus);
|
| | | btnPlus.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (seekBar.Progress >= 100)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.isDataChanged = true;
|
| | | seekBar.Progress += 1;
|
| | | this.pirConfigure.levelSize = seekBar.Progress;
|
| | | btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
|
| | | };
|
| | |
|
| | | //暗
|
| | | var btnDark = new NormalViewControl(120, 50, true);
|
| | | btnDark.TextID = R.MyInternationalizationString.uDark;
|
| | | btnDark.TextSize = 12;
|
| | | btnDark.TextAlignment = TextAlignment.Center;
|
| | | btnDark.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnDark.X = Application.GetRealWidth(70);
|
| | | btnDark.Y = seekBar.Bottom;
|
| | | frameLight.AddChidren(btnDark);
|
| | | var btnZero = new NormalViewControl(120, 50, true);
|
| | | btnZero.X = btnDark.X;
|
| | | btnZero.Y = btnDark.Bottom;
|
| | | btnZero.TextSize = 12;
|
| | | btnZero.TextAlignment = TextAlignment.Center;
|
| | | btnZero.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnZero.Text = "0lux";
|
| | | frameLight.AddChidren(btnZero);
|
| | |
|
| | | //亮
|
| | | var btnBright = new NormalViewControl(120, 50, true);
|
| | | btnBright.TextID = R.MyInternationalizationString.uBright;
|
| | | btnBright.TextSize = 12;
|
| | | btnBright.TextAlignment = TextAlignment.Center;
|
| | | btnBright.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnBright.X = frameLight.Width - Application.GetRealWidth(120 + 50);
|
| | | btnBright.Y = btnDark.Y;
|
| | | frameLight.AddChidren(btnBright);
|
| | | var btnPersent = new NormalViewControl(120, 50, true);
|
| | | btnPersent.X = btnBright.X;
|
| | | btnPersent.Y = btnBright.Bottom;
|
| | | btnPersent.TextSize = 12;
|
| | | btnPersent.TextAlignment = TextAlignment.Center;
|
| | | btnPersent.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnPersent.Text = "100lux";
|
| | | frameLight.AddChidren(btnPersent);
|
| | |
|
| | | var btnIcon = new IconViewControl(58);
|
| | | btnIcon.X = Application.GetRealWidth(109);
|
| | | btnIcon.Y = Application.GetRealHeight(431);
|
| | | btnIcon.UnSelectedImagePath = "Item/Tips.png";
|
| | | frameLight.AddChidren(btnIcon);
|
| | | //在室内条件下,黄昏照度值约为10lux,阴天照度值约为5~50lux,请根据实际需要进行调节
|
| | | var btnTipView = new NormalViewControl(790, 100, true);
|
| | | btnTipView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnTipView.TextSize = 12;
|
| | | btnTipView.IsMoreLines = true;
|
| | | btnTipView.TextAlignment = TextAlignment.Center;
|
| | | btnTipView.TextID = R.MyInternationalizationString.uPirBrightnessTipMsg;
|
| | | btnTipView.X = btnIcon.Right + Application.GetRealWidth(23);
|
| | | btnTipView.Y = btnIcon.Y;
|
| | | frameLight.AddChidren(btnTipView);
|
| | |
|
| | | //底线
|
| | | var btnIfLine = new NormalViewControl(seekBar.Width, ControlCommonResourse.BottomLineHeight, false);
|
| | | btnIfLine.X = btnDown.X;
|
| | | btnIfLine.Y = btnDown.Bottom + Application.GetRealHeight(69);
|
| | | var btnIfLine = new NormalViewControl(frameLight.Width, ControlCommonResourse.BottomLineHeight, false);
|
| | | btnIfLine.Y = frameLight.Height - ControlCommonResourse.BottomLineHeight;
|
| | | btnIfLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | frameLight.AddChidren(btnIfLine);
|
| | |
|
| | | //执行对象的Frame(因展开折叠,优先声明)
|
| | | var frameResult = new FrameListControl(23);
|
| | | var frameResult = new FrameListControl(29);
|
| | | frameResult.Height = Application.GetRealHeight(310);
|
| | |
|
| | | //就会--------------------------------------------------
|
| | | listView.rowSpace = Application.GetRealHeight(20);//切换间距
|
| | | var frameDo = new FrameRowControl(listView.rowSpace / 2);
|
| | | frameDo.UseClickStatu = false;
|
| | | listView.AddChidren(frameDo);
|
| | |
| | | {
|
| | | btnResultRight.IsSelected = !btnResultRight.IsSelected;
|
| | | //展开折叠
|
| | | frameResult.Height = frameResult.Height > 10 ? 0 : Application.GetRealHeight(310);
|
| | | if (frameResult.Height > 10)
|
| | | {
|
| | | frameResult.Height = 0;
|
| | | listView.Height -= Application.GetRealHeight(310);
|
| | | }
|
| | | else
|
| | | {
|
| | | frameResult.Height = Application.GetRealHeight(310);
|
| | | listView.Height += Application.GetRealHeight(310);
|
| | | }
|
| | | };
|
| | | //底线
|
| | | frameDo.AddBottomLine();
|
| | |
| | | frameResult.AddChidren(rowTarget);
|
| | | rowTarget.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uTriggerTarget), 600);
|
| | | rowTarget.AddRightArrow();
|
| | | rowTarget.AddBottomLine();
|
| | | var btnTargetView = rowTarget.AddMostRightView("", 700);
|
| | | rowTarget.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
| | | {
|
| | | btnTargetView.Text = string.Empty;
|
| | | }
|
| | | this.isDataChanged = true;
|
| | | };
|
| | | };
|
| | |
|
| | |
| | | }
|
| | |
|
| | | //延时
|
| | | string strMinute = Lightconfigure.transitionTime / 60 + Language.StringByID(R.MyInternationalizationString.uMinute);
|
| | | string strSecond = Lightconfigure.transitionTime % 60 + Language.StringByID(R.MyInternationalizationString.uSecond);
|
| | | string strMinute = pirConfigure.transitionTime / 60 + Language.StringByID(R.MyInternationalizationString.uMinute);
|
| | | string strSecond = pirConfigure.transitionTime % 60 + Language.StringByID(R.MyInternationalizationString.uSecond);
|
| | | var rowDelay = new FrameRowControl(listView.rowSpace / 2);
|
| | | rowDelay.LeftOffset = Application.GetRealWidth(138) - ControlCommonResourse.XXLeft;
|
| | | frameResult.AddChidren(rowDelay);
|
| | |
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | this.listOldData.Clear();
|
| | |
|
| | | //获取绑定目标设备
|
| | | List<CommonDevice> listDevice = await HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
|
| | |
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | this.listEsixtDevice.Clear();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | this.listEsixtDevice.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device));
|
| | |
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | //获取灯光的配置信息
|
| | | this.Lightconfigure = await HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
|
| | | if (Lightconfigure == null)
|
| | | if (lightLevelCount > 100)
|
| | | {
|
| | | lightLevelCount = 100;
|
| | | }
|
| | |
|
| | | //获取pir的配置信息
|
| | | this.pirConfigure = await HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
|
| | | if (pirConfigure == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | //记录旧数据
|
| | | this.listOldData.Add(Lightconfigure.levelSize);
|
| | | this.listOldData.Add(Lightconfigure.transitionTime);
|
| | | //获取PIR传感器的【lux值】
|
| | | this.pirLuxValue = await HdlDevicePirSensorLogic.Current.GetPirSensorLux(deviceIASZone);
|
| | | if (pirLuxValue == -1)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | |
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | |
| | | var listTemp2 = new List<string>() { "00" + strSecond };
|
| | | listSecond.Add(listTemp2);
|
| | |
|
| | | string value = (this.Lightconfigure.transitionTime / 60).ToString().PadLeft(2, '0') + strMinute;
|
| | | string value = (this.pirConfigure.transitionTime / 60).ToString().PadLeft(2, '0') + strMinute;
|
| | | int index1 = listfirst.IndexOf(value);
|
| | | if (index1 == -1)
|
| | | {
|
| | | index1 = 0;
|
| | | }
|
| | | value = (this.Lightconfigure.transitionTime % 60).ToString().PadLeft(2, '0') + strSecond;
|
| | | value = (this.pirConfigure.transitionTime % 60).ToString().PadLeft(2, '0') + strSecond;
|
| | | int index2 = listSecond[index1].IndexOf(value);
|
| | | if (index2 == -1)
|
| | | {
|
| | |
| | | int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
|
| | | int delaySecond = minute * 60 + second;
|
| | | //更改数值
|
| | | this.Lightconfigure.transitionTime = delaySecond;
|
| | | this.pirConfigure.transitionTime = delaySecond;
|
| | | this.isDataChanged = true;
|
| | | },
|
| | | index1, index2,
|
| | | Language.StringByID(R.MyInternationalizationString.uDelayed),
|
| | |
| | | /// </summary>
|
| | | private async void SavePirSensorData()
|
| | | {
|
| | | if (listOldData[0] == Lightconfigure.levelSize && listOldData[1] == Lightconfigure.transitionTime
|
| | | && listSaveDevice == null)
|
| | | if (this.isDataChanged == false)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | if (listOldData[0] != Lightconfigure.levelSize || listOldData[1] != Lightconfigure.transitionTime)
|
| | | //保存pir配置信息
|
| | | var result = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure);
|
| | | if (result == false)
|
| | | {
|
| | | //保存灯光配置
|
| | | var result = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.Lightconfigure);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|