From b02e8275a21dc06bf54b66273485d44e007a2616 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 20 七月 2020 14:50:17 +0800
Subject: [PATCH] 新代码
---
ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs | 659 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 659 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
new file mode 100755
index 0000000..55dbad5
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
@@ -0,0 +1,659 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.DevicePirSensor
+{
+ /// <summary>
+ /// PIR浼犳劅鍣ㄧ粦瀹氱晫闈⑩槄
+ /// </summary>
+ public class PirSensorBindTargetSettionForm : EditorCommonForm
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 浼犳劅鍣ㄨ澶�
+ /// </summary>
+ private IASZone deviceIASZone = null;
+ /// <summary>
+ /// 宸茬粡瀛樺湪鐨勭粦瀹氳澶�
+ /// </summary>
+ private List<string> listEsixtDevice = new List<string>();
+ /// <summary>
+ /// 闇�瑕佷繚瀛樼殑璁惧瀵硅薄
+ /// </summary>
+ private List<string> listSaveDevice = null;
+ /// <summary>
+ /// PIR浼犳劅鍣ㄥ厜鐓х瓑绾ф�诲埢搴�
+ /// </summary>
+ private int lightLevelCount = -1;
+ /// <summary>
+ /// PIR浼犳劅鍣ㄧ殑Lux鍊�
+ /// </summary>
+ private int pirLuxValue = -1;
+ /// <summary>
+ /// pir鐨勯厤缃俊鎭�
+ /// </summary>
+ private IASZone.ConfigureParamates pirConfigure = null;
+ /// <summary>
+ /// 鏁版嵁鏄惁鏀瑰彉
+ /// </summary>
+ private bool isDataChanged = false;
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+ /// </summary>
+ /// <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(() =>
+ {
+ //鍒濆鍖栦腑閮ㄤ俊鎭�
+ this.InitMiddleFrame();
+ });
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+ /// </summary>
+ private async void InitMiddleFrame()
+ {
+ this.listEsixtDevice.Clear();
+
+ var result = await this.GetDeviceAllDefultData();
+ if (result == false)
+ {
+ return;
+ }
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //鍒濆鍖栨帶浠�
+ this.InitMiddleControl();
+ });
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栨帶浠�
+ /// </summary>
+ private void InitMiddleControl()
+ {
+ //娓呯┖bodyFrame
+ this.ClearBodyFrame();
+
+ //褰撳墠浜害鍊�
+ string txtValue = Language.StringByID(R.MyInternationalizationString.uNowBrightnessValue);
+ var frameNowLinght = new FrameRowControl();
+ frameNowLinght.UseClickStatu = false;
+ frameNowLinght.BackgroundColor = UserCenterColor.Current.White;
+ bodyFrameLayout.AddChidren(frameNowLinght);
+ var btnLux = frameNowLinght.AddLeftCaption(txtValue + "锛�" + pirLuxValue + "lux", 900);
+ HdlThreadLogic.Current.RunThread(async () =>
+ {
+ while (this.Parent != null)
+ {
+ //浠栦滑璇磋繖涓笢瑗胯2绉掑埛鏂颁竴娆� 鑾峰彇PIR浼犳劅鍣ㄧ殑銆恖ux鍊笺��
+ this.pirLuxValue = await HdlDevicePirSensorLogic.Current.GetPirSensorLux(deviceIASZone, ShowErrorMode.NO);
+ if (pirLuxValue != -1)
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ btnLux.Text = txtValue + "锛�" + pirLuxValue + "lux";
+ }, ShowErrorMode.NO);
+ }
+ await Task.Delay(2000);
+ }
+ }, ShowErrorMode.NO);
+
+
+ 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 = 0;
+
+ //濡傛灉婊¤冻浣庝寒搴︾幆澧�
+ var frameIfRow = new FrameRowControl(listView.rowSpace / 2);
+ frameIfRow.UseClickStatu = false;
+ listView.AddChidren(frameIfRow);
+ frameIfRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uIfTheLowBrightnessEnvironmentIsSatisfied), 700);
+ //寮�鍏虫寜閽�
+ var btnSwitch = frameIfRow.AddMostRightSwitchIcon();
+ btnSwitch.IsSelected = this.pirConfigure.levelEnable;
+ btnSwitch.ButtonClickEvent += (sender, e) =>
+ {
+ this.isDataChanged = true;
+ this.pirConfigure.levelEnable = !btnSwitch.IsSelected;
+ btnSwitch.IsSelected = this.pirConfigure.levelEnable;
+ //灞曞紑鎶樺彔
+ 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 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(940);
+ seekBar.Gravity = Gravity.Frame;
+ seekBar.X = Application.GetRealWidth(80);
+ seekBar.Y = Application.GetRealHeight(159);
+ seekBar.MaxValue = lightLevelCount;
+ seekBar.ProgressBarColor = 0xfffdb500;
+ frameLight.AddChidren(seekBar);
+ seekBar.ProgressChangedEvent += (div, value) =>
+ {
+ this.isDataChanged = true;
+ this.pirConfigure.levelSize = value;
+ btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
+ };
+ seekBar.Progress = pirConfigure.levelSize;
+
+ //鍑忓彿
+ 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(frameLight.Width, ControlCommonResourse.BottomLineHeight, false);
+ btnIfLine.Y = frameLight.Height - ControlCommonResourse.BottomLineHeight;
+ btnIfLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
+ frameLight.AddChidren(btnIfLine);
+
+ //鎵ц瀵硅薄鐨凢rame(鍥犲睍寮�鎶樺彔,浼樺厛澹版槑)
+ 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);
+ frameDo.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uResultDo), 600);
+ //鍙崇澶�
+ var btnResultRight = frameDo.AddMostRightEmptyIcon(58, 58);
+ frameDo.ChangedChidrenBindMode(btnResultRight, ChidrenBindMode.NotBind);
+ btnResultRight.UseClickStatu = false;
+ btnResultRight.UnSelectedImagePath = "Item/RightNext.png";
+ btnResultRight.SelectedImagePath = "Item/Down.png";
+ btnResultRight.IsSelected = true;
+ btnResultRight.ButtonClickEvent += (sender, e) =>
+ {
+ btnResultRight.IsSelected = !btnResultRight.IsSelected;
+ //灞曞紑鎶樺彔
+ 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();
+
+ listView.AddChidren(frameResult);
+ //瑙﹀彂鐩爣
+ var rowTarget = new FrameRowControl(listView.rowSpace / 2);
+ rowTarget.LeftOffset = Application.GetRealWidth(138) - ControlCommonResourse.XXLeft;
+ frameResult.AddChidren(rowTarget);
+ rowTarget.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uTriggerTarget), 600);
+ rowTarget.AddRightArrow();
+ rowTarget.AddBottomLine();
+ var btnTargetView = rowTarget.AddMostRightView("", 700);
+ rowTarget.ButtonClickEvent += (sender, e) =>
+ {
+ var form = new PirSensorTargetSelectForm();
+ form.AddForm(listSaveDevice == null ? listEsixtDevice : listSaveDevice);
+ form.FinishSelectEvent += (listSelect) =>
+ {
+ listSaveDevice = new List<string>();
+ listSaveDevice.AddRange(listSelect);
+ if (listSaveDevice.Count > 0)
+ {
+ //闅忎究涓竴涓悕瀛椾笂鍘�
+ var device = Common.LocalDevice.Current.GetDevice(listSaveDevice[0]);
+ btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
+ }
+ else
+ {
+ btnTargetView.Text = string.Empty;
+ }
+ this.isDataChanged = true;
+ };
+ };
+
+ foreach (string mainkey in this.listEsixtDevice)
+ {
+ var device = Common.LocalDevice.Current.GetDevice(mainkey);
+ if (device != null)
+ {
+ //闅忎究涓竴涓悕瀛椾笂鍘�
+ btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
+ break;
+ }
+ }
+
+ //寤舵椂(鍗婅嚜鍔ㄦ病鏈夊欢鏃剁殑姒傚康)
+ if (this.pirConfigure.mode == 1)
+ {
+ string strMinute = string.Empty;
+ if (pirConfigure.transitionTime / 60 > 0)
+ {
+ 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);
+ rowDelay.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uDelayed), 300);
+ rowDelay.AddRightArrow();
+ var btnDelayView = rowDelay.AddMostRightView(strMinute + strSecond, 700);
+ rowDelay.ButtonClickEvent += (sender, e) =>
+ {
+ this.ShowDelayListTime(btnDelayView);
+ };
+ }
+
+ //淇濆瓨
+ var btnSave = new BottomClickButton();
+ btnSave.TextID = R.MyInternationalizationString.uSave;
+ bodyFrameLayout.AddChidren(btnSave);
+ btnSave.ButtonClickEvent += (sender, e) =>
+ {
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ //淇濆瓨Pir浼犳劅鍣ㄦ暟鎹�
+ this.SavePirSensorData();
+ });
+ };
+ }
+
+ #endregion
+
+ #region 鈻� 鑾峰彇鍒濆鏁版嵁_______________________
+
+ /// <summary>
+ /// 鑾峰彇鍒濆鏁版嵁
+ /// </summary>
+ /// <returns></returns>
+ private async Task<bool> GetDeviceAllDefultData()
+ {
+ //鎵撳紑杩涘害鏉�
+ this.ShowProgressBar();
+
+ //鑾峰彇缁戝畾鐩爣璁惧
+ List<CommonDevice> listDevice = HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
+ if (listDevice == null)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return false;
+ }
+ this.listEsixtDevice.Clear();
+ foreach (var device in listDevice)
+ {
+ string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+ if (listEsixtDevice.Contains(mainKeys) == false)
+ {
+ listEsixtDevice.Add(mainKeys);
+ }
+ }
+ //鑾峰彇PIR浼犳劅鍣ㄧ殑銆愬厜鎰熺瓑绾ф�诲埢搴︺��
+ this.lightLevelCount = await HdlDevicePirSensorLogic.Current.GetPirLightAbilitySize(this.deviceIASZone);
+ if (lightLevelCount == -1)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return false;
+ }
+ if (lightLevelCount > 100)
+ {
+ lightLevelCount = 100;
+ }
+
+ //鑾峰彇pir鐨勯厤缃俊鎭�
+ this.pirConfigure = HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
+ if (pirConfigure == null)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return false;
+ }
+ //鑾峰彇PIR浼犳劅鍣ㄧ殑銆恖ux鍊笺��
+ this.pirLuxValue = await HdlDevicePirSensorLogic.Current.GetPirSensorLux(deviceIASZone);
+ if (pirLuxValue == -1)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return false;
+ }
+
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+
+ return true;
+ }
+
+ #endregion
+
+ #region 鈻� 鏄剧ず寤舵椂鏃堕棿_______________________
+
+ /// <summary>
+ /// 鏄剧ず寤舵椂鏃堕棿鍒楄〃
+ /// </summary>
+ /// <param name="btnTime"></param>
+ private void ShowDelayListTime(NormalViewControl btnTime)
+ {
+ //鍒�
+ string strMinute = Language.StringByID(R.MyInternationalizationString.uMinute);
+ //绉�
+ string strSecond = Language.StringByID(R.MyInternationalizationString.uSecond);
+ var listfirst = new List<string>();
+ var listSecond = new List<List<string>>();
+ for (int i = 0; i <= 29; i++)
+ {
+ listfirst.Add(i.ToString().PadLeft(2, '0') + strMinute);
+ var listTemp = new List<string>();
+ for (int j = 0; j <= 59; j++)
+ {
+ if (i == 0 && j == 0)
+ {
+ continue;
+ }
+ listTemp.Add(j.ToString().PadLeft(2, '0') + strSecond);
+ }
+ listSecond.Add(listTemp);
+ }
+ //鍔犱竴涓�30鍒嗛挓鍚�
+ listfirst.Add("30" + strMinute);
+ var listTemp2 = new List<string>() { "00" + strSecond };
+ listSecond.Add(listTemp2);
+
+ string value = (this.pirConfigure.transitionTime / 60).ToString().PadLeft(2, '0') + strMinute;
+ int index1 = listfirst.IndexOf(value);
+ if (index1 == -1)
+ {
+ index1 = 0;
+ }
+ value = (this.pirConfigure.transitionTime % 60).ToString().PadLeft(2, '0') + strSecond;
+ int index2 = listSecond[index1].IndexOf(value);
+ if (index2 == -1)
+ {
+ index2 = 0;
+ }
+
+ PickerView.ShowSecondary(listfirst, listSecond, (value1, value2) =>
+ {
+ btnTime.Text = listfirst[value1].TrimStart('0') + listSecond[value1][value2];
+ int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2));
+ int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
+ int delaySecond = minute * 60 + second;
+ //鏇存敼鏁板��
+ this.pirConfigure.transitionTime = delaySecond;
+ this.isDataChanged = true;
+ },
+ index1, index2,
+ Language.StringByID(R.MyInternationalizationString.uDelayed),
+ Language.StringByID(R.MyInternationalizationString.uFinish),
+ Language.StringByID(R.MyInternationalizationString.uCancel));
+ }
+
+ #endregion
+
+ #region 鈻� 鏁版嵁淇濆瓨___________________________
+
+ /// <summary>
+ /// 淇濆瓨Pir浼犳劅鍣ㄦ暟鎹�
+ /// </summary>
+ private void SavePirSensorData()
+ {
+ if (this.isDataChanged == false)
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //鏁版嵁娌℃湁鍙樻洿杩�,鍏抽棴鐣岄潰
+ this.CloseForm();
+ });
+ return;
+ }
+
+ //鎵撳紑杩涘害鏉�
+ this.ShowProgressBar();
+
+ if (listSaveDevice != null)
+ {
+ //鍒犻櫎缁戝畾鐩爣
+ var listDelDevice = new List<CommonDevice>();
+ var listLightDevice = new List<CommonDevice>();
+ foreach (string mainKey in listEsixtDevice)
+ {
+ if (this.listSaveDevice.Contains(mainKey) == false)
+ {
+ var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
+ listDelDevice.Add(myDevice);
+ if (myDevice.Type == DeviceType.DimmableLight)
+ {
+ //濡傛灉鏄皟鍏夊櫒鐨勮瘽,鐗规畩涓�鐐�
+ listLightDevice.Add(myDevice);
+ }
+ }
+ }
+ if (listDelDevice.Count > 0)
+ {
+ //鍒犻櫎鐩爣
+ var listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listDelDevice);
+ if (listSucess == null || listSucess.Count == 0)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ return;
+ }
+ if (listLightDevice.Count > 0)
+ {
+ //鍒犻櫎璋冨厜鍣ㄩ暈
+ listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listLightDevice, 8);
+ if (listSucess == null || listSucess.Count == 0)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ return;
+ }
+ }
+ }
+ //缁戝畾鐩爣
+ var listBind = new List<CommonDevice>();
+ listLightDevice = new List<CommonDevice>();
+ foreach (var mainKey in listSaveDevice)
+ {
+ var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
+ listBind.Add(myDevice);
+ if (myDevice.Type == DeviceType.DimmableLight)
+ {
+ //濡傛灉鏄皟鍏夊櫒鐨勮瘽,鐗规畩涓�鐐�
+ listLightDevice.Add(myDevice);
+ }
+ }
+ if (listSaveDevice.Count > 0)
+ {
+ //缁戝畾鐩爣
+ var listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listBind);
+ if (listSucess == null || listSucess.Count == 0)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ return;
+ }
+ if (listLightDevice.Count > 0)
+ {
+ //缁戝畾璋冨厜闀�
+ listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listLightDevice, 8);
+ if (listSucess == null || listSucess.Count == 0)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ return;
+ }
+ }
+ }
+ }
+ //淇濆瓨pir閰嶇疆淇℃伅
+ var result = HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure);
+ if (result == false)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ return;
+ }
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //鐣岄潰鍏抽棴
+ this.CloseForm();
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 涓�鑸柟娉昣__________________________
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0