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/Panel/PanelFangyueFreshAirButtonSettionForm.cs | 544 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 544 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs new file mode 100644 index 0000000..db51608 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs @@ -0,0 +1,544 @@ +锘縰sing System; +using System.Collections.Generic; +using Shared.Common; +using Shared.Phone.UserCenter.Device.Bind; +using Shared.Phone.UserCenter.DeviceBind; +using ZigBee.Common; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.DevicePanel +{ + /// <summary> + /// 鏂规偊鏂伴闈㈡澘鐨勬寜閿厤缃晫闈� + /// </summary> + public class PanelFangyueFreshAirButtonSettionForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private FrameListControl listview = null; + /// <summary> + /// 璁惧鐨勬煇涓�鍥炶矾 + /// </summary> + private CommonDevice deviceObj = null; + /// <summary> + /// 鏂伴鐩爣鍚嶅瓧 + /// </summary> + private string bindFreshAirName = string.Empty; + /// <summary> + /// 娓╁害鐩爣鍚嶅瓧 + /// </summary> + private string bindTemperatureName = string.Empty; + /// <summary> + /// 婀垮害鐩爣鍚嶅瓧 + /// </summary> + private string bindHumidityName = string.Empty; + /// <summary> + /// PM鐩爣鍚嶅瓧 + /// </summary> + private string bindPmName = string.Empty; + /// <summary> + /// 琚粦鐩爣鏄柊椋� + /// </summary> + private CommonDevice bindFreshAirDev; + /// <summary> + /// 琚粦鐩爣鏄俯搴� + /// </summary> + private CommonDevice bindTemperatureDev; + /// <summary> + /// 琚粦鐩爣鏄箍搴� + /// </summary> + private CommonDevice bindHumidityDev; + /// <summary> + /// 琚粦鐩爣鏄疨M2.5 + /// </summary> + private CommonDevice bindPMDev; + // <summary> + /// 鎸夐敭涓缁戝畾鐨勭洰鏍囧垪琛� + /// </summary> + public List<BindObj.BindListResponseObj> bindList = new List<BindObj.BindListResponseObj>(); + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_device">璁惧鐨勬煇涓�鍥炶矾</param> + public void ShowForm(CommonDevice i_device) + { + this.deviceObj = i_device; + //鑾峰彇鏁版嵁 + InitInfo(deviceObj); + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPanelSettion)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + + //鍒濆鍖栧彸涓婅鑿滃崟 + this.InitTopRightMenu(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + var listBackControl = new VerticalFrameControl(); + listBackControl.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listBackControl); + + //鍥剧墖 + var btnPic = new PicViewControl(426, 426); + btnPic.Y = Application.GetRealHeight(150); + btnPic.UnSelectedImagePath = "RealDevice/ButtonPanelFangyueFreshAir.png"; + btnPic.Gravity = Gravity.CenterHorizontal; + listBackControl.frameTable.AddChidren(btnPic); + + //鍒濆鍖栨甯� + var tableContr = new InformationEditorControl(); + this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 1028); + + //鍒濆鍖栬彍鍗曡 + this.InitMenuRow(); + + //鍒濆鍖栨甯冨畬鎴� + tableContr.FinishInitControl(); + tableContr = null; + + //淇濆瓨 + var btnFinish = new BottomClickButton(); + btnFinish.TextID = R.MyInternationalizationString.uSave; + bodyFrameLayout.AddChidren(btnFinish); + btnFinish.ButtonClickEvent += (sender, e) => + { + //鍏抽棴鑷韩 + this.CloseForm(); + }; + } + + /// <summary> + /// 鍒濆鍖栬彍鍗曡 + /// </summary> + private void InitMenuRow() + { + this.listview.RemoveAll(); + //娣诲姞鏂伴鐩爣 + this.AddFreshAirRow(); + //PM2.5鏉ユ簮 + this.AddPMRow(); + //娣诲姞娓╁害鏉ユ簮 + this.AddTemperatureSensorRow(); + //娣诲姞婀垮害鏉ユ簮 + this.AddHumiditySourceRow(); + //浜害璋冭妭 + this.AddLevelRow(); + } + #endregion + + #region 鈻� 鍒濆鍖栨暟鎹甠________________________ + + /// <summary> + /// 鍒濆鍖栨暟鎹� + /// </summary> + void InitInfo(CommonDevice curControlDev) + { + System.Threading.Tasks.Task.Run(async () => + { + try + { + Application.RunOnMainThread(() => + { + CommonPage.Loading.Start(""); + }); + + var result = await GetBindName(curControlDev); + if (!result) + { + + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5007" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); + }); + } + } + catch (Exception ex) + { + var mess = ex.Message; + } + finally + { + Application.RunOnMainThread(() => + { + this.InitMenuRow(); + CommonPage.Loading.Hide(); + }); + } + }); + } + + /// <summary> + /// 鑾峰彇缁戝畾鐩爣 + /// </summary> + /// <param name="curControlDev"></param> + /// <returns></returns> + private async System.Threading.Tasks.Task<bool> GetBindName(CommonDevice curDev) + { + bool result = false; + //鑾峰彇闈㈡澘涓瓨鍦ㄧ殑缁戝畾鐩爣 + FreshAir curControlDev = curDev as FreshAir; + var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev); + if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null) + { + bindList = panelBindListRes.getAllBindResponseData.BindList; + foreach (var bDev in bindList) + { + var device = Common.LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint); + if (device == null) + { + continue; + } + if (device.Type == DeviceType.FreshAir) + { + //鑾峰彇璁惧绫诲瀷鐨� + var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); + //鏂伴闈㈡澘鐨勬柊椋庤澶囷紝鍒欎笉鏄剧ず + if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir) + { + continue; + } + if (string.IsNullOrEmpty(bDev.ESName)) + { + bindFreshAirName = Common.LocalDevice.Current.GetDeviceEpointName(device); + } + else + { + bindFreshAirName = bDev.ESName; + } + + bindFreshAirDev = device; + } + if (device.Type == DeviceType.TemperatureSensor) + { + var bD = device as TemperatureSensor; + if (bD.SensorDiv == 1) + { + if (string.IsNullOrEmpty(bDev.ESName)) + { + bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device); + } + else + { + bindTemperatureName = bDev.ESName; + } + bindTemperatureDev = device; + } + if (bD.SensorDiv == 2) + { + if (string.IsNullOrEmpty(bDev.ESName)) + { + bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device); + } + else + { + bindHumidityName = bDev.ESName; + } + + bindHumidityDev = device; + } + } + if (device.Type == DeviceType.FreshAirHumiditySensor) + { + if (string.IsNullOrEmpty(bDev.ESName)) + { + bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device); + } + else + { + bindHumidityName = bDev.ESName; + } + + bindHumidityDev = device; + } + if (device.Type == DeviceType.PMSensor) + { + if (bDev.BindCluster == 1026) + { + bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor); + bindTemperatureDev = device; + } + if (bDev.BindCluster == 1029) + { + bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor); + bindHumidityDev = device; + } + if (bDev.BindCluster == 1066) + { + if (string.IsNullOrEmpty(bDev.ESName)) + { + bindPmName = Common.LocalDevice.Current.GetDeviceEpointName(device); + } + else + { + bindPmName = bDev.ESName; + } + + bindPMDev = device; + } + } + } + result = true; + } + return result; + } + + #endregion + + #region 鈻� 鏂伴鐩爣_________________________ + /// <summary> + /// 鏂伴鐩爣琛� + /// </summary> + private void AddFreshAirRow() + { + //鏂伴鐩爣 + var rowNewWind = new FrameRowControl(listview.rowSpace / 2); + listview.AddChidren(rowNewWind); + rowNewWind.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNewWindTarget), 600); + //搴曠嚎 + rowNewWind.AddBottomLine(); + //鍙崇澶� + rowNewWind.AddRightArrow(); + + var msg = Language.StringByID(R.MyInternationalizationString.nothing); + if (!string.IsNullOrEmpty(bindFreshAirName)) + { + msg = bindFreshAirName; + } + var btnNewWindStatu = rowNewWind.AddMostRightView(msg, 700); + + rowNewWind.ButtonClickEvent += (sender, e) => + { + var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindFreshAirDev, BindInfo.BindType.FreshAir); + Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp); + Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; + paneTargetsBaseFormp.Show(); + paneTargetsBaseFormp.actionFreshAirTarget += (bindName) => + { + Application.RunOnMainThread(() => + { + if (string.IsNullOrEmpty(bindName)) + { + btnNewWindStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); + } + else + { + btnNewWindStatu.Text = bindName; + } + }); + }; + }; + } + #endregion + + #region 鈻� PM2.5鏉ユ簮_________________________ + /// <summary> + /// PM2.5鏉ユ簮琛� + /// </summary> + private void AddPMRow() + { + //PM2.5 + var rowPM = new FrameRowControl(listview.rowSpace / 2); + listview.AddChidren(rowPM); + rowPM.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.PM25Source), 600); + //搴曠嚎 + rowPM.AddBottomLine(); + //鍙崇澶� + rowPM.AddRightArrow(); + var msg = Language.StringByID(R.MyInternationalizationString.nothing); + if (!string.IsNullOrEmpty(bindPmName)) + { + msg = bindPmName; + } + var btnPMStatu = rowPM.AddMostRightView(msg, 700); + rowPM.ButtonClickEvent += (sender, e) => + { + var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindPMDev, BindInfo.BindType.PM); + Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp); + Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; + paneTargetsBaseFormp.Show(); + paneTargetsBaseFormp.actionPMTarget += (bindName) => + { + Application.RunOnMainThread(() => + { + if (string.IsNullOrEmpty(bindName)) + { + btnPMStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); + } + else + { + btnPMStatu.Text = bindName; + } + }); + }; + }; + } + #endregion + + #region 鈻� 娓╁害鏉ユ簮_________________________ + /// <summary> + /// 娓╁害鏉ユ簮琛� + /// </summary> + private void AddTemperatureSensorRow() + { + //娓╁害鏉ユ簮 + var rowTemPerature = new FrameRowControl(listview.rowSpace / 2); + listview.AddChidren(rowTemPerature); + rowTemPerature.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.TemperatureSource), 600); + //搴曠嚎 + rowTemPerature.AddBottomLine(); + //鍙崇澶� + rowTemPerature.AddRightArrow(); + var msg = Language.StringByID(R.MyInternationalizationString.nothing); + if (!string.IsNullOrEmpty(bindTemperatureName)) + { + msg = bindTemperatureName; + } + var btnTemperatureStatu = rowTemPerature.AddMostRightView(msg, 700); + rowTemPerature.ButtonClickEvent += (sender, e) => + { + var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindTemperatureDev, BindInfo.BindType.Temperature); + Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp); + Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; + paneTargetsBaseFormp.Show(); + paneTargetsBaseFormp.actionTemperatureTarget += (bindName) => + { + Application.RunOnMainThread(() => + { + if (string.IsNullOrEmpty(bindName)) + { + btnTemperatureStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); + } + else + { + btnTemperatureStatu.Text = bindName; + } + }); + }; + }; + } + #endregion + + #region 鈻� 婀垮害鏉ユ簮_________________________ + /// <summary> + /// 婀垮害鏉ユ簮琛� + /// </summary> + private void AddHumiditySourceRow() + { + //婀垮害 + var rowHumidity = new FrameRowControl(listview.rowSpace / 2); + listview.AddChidren(rowHumidity); + rowHumidity.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.HumiditySource), 600); + //搴曠嚎 + rowHumidity.AddBottomLine(); + //鍙崇澶� + rowHumidity.AddRightArrow(); + var msg = Language.StringByID(R.MyInternationalizationString.nothing); + if (!string.IsNullOrEmpty(bindHumidityName)) + { + msg = bindHumidityName; + } + var btnHumidityStatu = rowHumidity.AddMostRightView(msg, 700); + rowHumidity.ButtonClickEvent += (sender, e) => + { + var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindHumidityDev, BindInfo.BindType.Humidity); + Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp); + Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; + paneTargetsBaseFormp.Show(); + paneTargetsBaseFormp.actionHumidityTarget += (bindName) => + { + Application.RunOnMainThread(() => + { + if (string.IsNullOrEmpty(bindName)) + { + btnHumidityStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); + } + else + { + btnHumidityStatu.Text = bindName; + } + }); + }; + }; + } + #endregion + + #region 鈻� 浜害璋冭妭_________________________ + /// <summary> + /// 浜害璋冭妭琛� + /// </summary> + private void AddLevelRow() + { + //浜害璋冭妭 + var rowLight = new FrameRowControl(listview.rowSpace / 2); + listview.AddChidren(rowLight); + rowLight.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uLightRegulation), 600); + //搴曠嚎 + rowLight.AddBottomLine(); + //鍙崇澶� + rowLight.AddRightArrow(); + rowLight.ButtonClickEvent += (sender, e) => + { + var form = new PanelBrightnessAdjustForm(); + form.AddForm(this.deviceObj); + }; + } + #endregion + + #region 鈻� 鍙充笂瑙掕彍鍗昣________________________ + /// <summary> + /// 鍒濆鍖栧彸涓婅鑿滃崟 + /// </summary> + private void InitTopRightMenu() + { + //妫�娴嬫鍥炶矾鏄惁鎷ユ湁瀹氫綅鍔熻兘 + if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(deviceObj) == false) + { + return; + } + var btnIcon = new MostRightIconControl(69, 69); + btnIcon.UnSelectedImagePath = "Item/More.png"; + topFrameLayout.AddChidren(btnIcon); + btnIcon.InitControl(); + btnIcon.ButtonClickEvent += ((sender, e) => + { + //鏄剧ず鍙充笂瑙掕彍鍗曠晫闈� + this.ShowTopRightMenu(); + }); + } + + /// <summary> + /// 鏄剧ず鍙充笂瑙掕彍鍗曠晫闈� + /// </summary> + private void ShowTopRightMenu() + { + var frame = new TopRightMenuControl(1, 1); + //瀹氫綅 + string deviceMenu = Language.StringByID(R.MyInternationalizationString.uFixedPosition); + frame.AddRowMenu(deviceMenu, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () => + { + //鍙戦�佸畾浣嶅姛鑳� + Common.LocalDevice.Current.SetFixedPositionCommand(deviceObj); + }); + } + + #endregion + } +} -- Gitblit v1.8.0