From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期二, 21 七月 2020 09:46:53 +0800 Subject: [PATCH] 请合并最新多功能面板代码 --- ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceRelayDetailCardForm.cs | 306 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 306 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceRelayDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceRelayDetailCardForm.cs new file mode 100755 index 0000000..6a1ef7c --- /dev/null +++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceRelayDetailCardForm.cs @@ -0,0 +1,306 @@ +锘縰sing Shared.Phone.UserCenter; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.MainPage.ControlForm +{ + /// <summary> + /// 缁х數鍣ㄧ被鍨嬬殑娣卞害鍗$墖鐣岄潰(鍚┖姘斿紑鍏�) + /// </summary> + public class DeviceRelayDetailCardForm : DeviceDetailCardCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鐣岄潰涓婂彲浠ユ搷浣滅殑鎺т欢 + /// </summary> + private List<ButtonBase> listControl = new List<ButtonBase>(); + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 搴曞眰鍒濆鍖栦腑閮ㄦ帶浠跺畬鎴愪箣鍚� + /// </summary> + /// <param name="frameWhiteBack"></param> + public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack) + { + //鍏堟竻绌� + this.listControl = new List<ButtonBase>(); + + if (this.device.DfunctionType == DeviceFunctionType.A寮�鍏�) + { + //鍒濆鍖栧紑鍏崇被鍨嬫帶浠� + this.InitSwitchControl(frameWhiteBack); + } + else if (this.device.DfunctionType == DeviceFunctionType.A鎻掑骇) + { + //鍒濆鍖栨彃搴х被鍨嬫帶浠� + this.InitPlugControl(frameWhiteBack); + } + else + { + //鍒濆鍖栫伅鍏夌被鍨嬫帶浠� + this.InitLightControl(frameWhiteBack); + } + //璁剧疆鐘舵�佹枃瀛� + this.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + } + + #endregion + + #region 鈻� 鍒濆鍖栫伅鍏夌被鍨媉____________________ + + /// <summary> + /// 鍒濆鍖栫伅鍏夌被鍨嬫帶浠� + /// </summary> + /// <param name="frameWhiteBack"></param> + private void InitLightControl(FrameLayout frameWhiteBack) + { + //鐏厜鍥剧墖 + var picLight = new PicViewControl(377, 435); + picLight.Y = Application.GetRealHeight(389); + picLight.UnSelectedImagePath = "Light/DeskLamp.png"; + picLight.SelectedImagePath = "Light/DeskLampSelected.png"; + picLight.Gravity = Gravity.CenterHorizontal; + frameWhiteBack.AddChidren(picLight); + listControl.Add(picLight); + + //寮�鍏� + var btnSwitch = new IconViewControl(81); + btnSwitch.UnSelectedImagePath = "Item/Switch.png"; + btnSwitch.SelectedImagePath = "Item/SwitchSelected.png"; + btnSwitch.Y = picLight.Bottom + Application.GetRealHeight(173); + btnSwitch.Gravity = Gravity.CenterHorizontal; + frameWhiteBack.AddChidren(btnSwitch); + listControl.Add(btnSwitch); + + //璁剧疆鍒濆鐘舵�� + if (((LightBase)this.device).OnOffStatus == 1) + { + picLight.IsSelected = true; + btnSwitch.IsSelected = true; + } + + picLight.ButtonClickEvent += (sender, e) => + { + //鍙戦�佸紑鍏冲懡浠� + this.SetSwitchCommand(!picLight.IsSelected); + }; + btnSwitch.ButtonClickEvent += (sender, e) => + { + //鍙戦�佸紑鍏冲懡浠� + this.SetSwitchCommand(!btnSwitch.IsSelected); + }; + } + + #endregion + + #region 鈻� 鍒濆鍖栧紑鍏崇被鍨媉____________________ + + /// <summary> + /// 鍒濆鍖栧紑鍏崇被鍨嬫帶浠� + /// </summary> + /// <param name="frameWhiteBack"></param> + private void InitSwitchControl(FrameLayout frameWhiteBack) + { + //寮�鍏崇殑鑳屾櫙鍥剧墖 + var picSwitchBack = new FrameLayout(); + picSwitchBack.Height = this.GetPictrueRealSize(579); + picSwitchBack.Width = this.GetPictrueRealSize(579); + picSwitchBack.Y = Application.GetRealHeight(340); + picSwitchBack.BackgroundImagePath = "Light/OnOff.png"; + picSwitchBack.Gravity = Gravity.CenterHorizontal; + frameWhiteBack.AddChidren(picSwitchBack); + + //鍏抽棴 + var btnClose = new IconViewControl(81); + btnClose.UnSelectedImagePath = "Light/OFF.png"; + btnClose.SelectedImagePath = "Light/OFFSelected.png"; + btnClose.X = this.GetPictrueRealSize(101); + btnClose.Y = this.GetPictrueRealSize(248); + picSwitchBack.AddChidren(btnClose); + listControl.Add(btnClose); + + //鎵撳紑 + var btnOpen = new IconViewControl(81); + btnOpen.UnSelectedImagePath = "Light/ON.png"; + btnOpen.SelectedImagePath = "Light/ONSelected.png"; + btnOpen.X = this.GetPictrueRealSize(397); + btnOpen.Y = btnClose.Y; + picSwitchBack.AddChidren(btnOpen); + listControl.Add(btnOpen); + + //璁剧疆鍒濆鐘舵�� + if (((LightBase)this.device).OnOffStatus == 1) + { + btnOpen.IsSelected = true; + } + else + { + btnClose.IsSelected = true; + } + + btnClose.ButtonClickEvent += (sender, e) => + { + if (btnClose.IsSelected == true) { return; } + //鍙戦�佸紑鍏冲懡浠� + this.SetSwitchCommand(false); + }; + btnOpen.ButtonClickEvent += (sender, e) => + { + if (btnOpen.IsSelected == true) { return; } + //鍙戦�佸紑鍏冲懡浠� + this.SetSwitchCommand(true); + }; + } + + #endregion + + #region 鈻� 鍒濆鍖栨彃搴х被鍨媉____________________ + + /// <summary> + /// 鍒濆鍖栨彃搴х被鍨嬫帶浠� + /// </summary> + /// <param name="frameWhiteBack"></param> + private void InitPlugControl(FrameLayout frameWhiteBack) + { + //鎻掑骇鍥剧墖 + var picPlug = new PicViewControl(567, 567); + picPlug.Y = Application.GetRealHeight(334); + picPlug.UnSelectedImagePath = "Light/Plug.png"; + picPlug.SelectedImagePath = "Light/PlugSelected.png"; + picPlug.Gravity = Gravity.CenterHorizontal; + frameWhiteBack.AddChidren(picPlug); + listControl.Add(picPlug); + + //寮�鍏� + var btnSwitch = new IconViewControl(81); + btnSwitch.UnSelectedImagePath = "Item/Switch.png"; + btnSwitch.SelectedImagePath = "Item/SwitchSelected.png"; + btnSwitch.Y = picPlug.Bottom + Application.GetRealHeight(89); + btnSwitch.Gravity = Gravity.CenterHorizontal; + frameWhiteBack.AddChidren(btnSwitch); + listControl.Add(btnSwitch); + + //璁剧疆鍒濆鐘舵�� + if (((LightBase)this.device).OnOffStatus == 1) + { + picPlug.IsSelected = true; + btnSwitch.IsSelected = true; + } + + picPlug.ButtonClickEvent += (sender, e) => + { + //鍙戦�佸紑鍏冲懡浠� + this.SetSwitchCommand(!picPlug.IsSelected); + }; + btnSwitch.ButtonClickEvent += (sender, e) => + { + //鍙戦�佸紑鍏冲懡浠� + this.SetSwitchCommand(!btnSwitch.IsSelected); + }; + } + + #endregion + + #region 鈻� 鍒锋柊寮�鍏崇姸鎬乢______________________ + + /// <summary> + /// 鍒锋柊寮�鍏崇姸鎬� + /// </summary> + /// <param name="isOpen">鎵撳紑鐘舵��</param> + private void RefreshSwitchStatu(bool isOpen) + { + //鍙樻洿鐘舵�� + if (this.device.DfunctionType == DeviceFunctionType.A寮�鍏�) + { + //寮�鐘舵�� + listControl[1].IsSelected = isOpen; + //鍏崇姸鎬� 鍙栧弽寮�鐘舵�� + listControl[0].IsSelected = !isOpen; + } + else + { + //寮�鍏充互澶� + listControl[0].IsSelected = isOpen; + listControl[1].IsSelected = isOpen; + } + //璁剧疆鐘舵�佹枃瀛� + this.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + } + + #endregion + + #region 鈻� 鏄惁鑾峰彇缃戝叧鍙嶉鐨勭粨鏋淿____________ + + /// <summary> + /// 妫�娴嬬綉鍏崇殑鍙嶉缁撴灉(灞炴�т笂鎶ョ殑瀵硅薄锛歞evice.DeviceStatusReport) + /// </summary> + /// <param name="comandDiv">鍛戒护鍖哄垎</param> + /// <param name="report">涓婃姤鏁版嵁</param> + /// <returns></returns> + public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report) + { + if (comandDiv == ReceiveComandDiv.A璁惧灞炴�т笂鎶�) + { + HdlThreadLogic.Current.RunMain(() => + { + //鍙樻洿鍗$墖鐘舵�� + this.RefreshSwitchStatu(((LightBase)this.device).OnOffStatus == 1); + }); + return true; + } + return false; + } + + #endregion + + #region 鈻� 鍙戦�佸紑鍏冲懡浠______________________ + + /// <summary> + /// 鍙戦�佸紑鍏冲懡浠� + /// </summary> + /// <param name="isOpen"></param> + private void SetSwitchCommand(bool isOpen) + { + //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + ((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0; + //鍙樻洿鍗$墖鐘舵�� + this.RefreshSwitchStatu(((LightBase)this.device).OnOffStatus == 1); + return; + } + //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅 + this.StartCheckResponeResult(this.listControl, (result) => + { + //鎺ユ敹鍒扮綉鍏冲洖澶� + if (result == true) + { + HdlThreadLogic.Current.RunMain(() => + { + //鍙樻洿鍗$墖鐘舵�� + bool statu = ((LightBase)this.device).OnOffStatus == 1; + this.RefreshSwitchStatu(statu); + }); + } + }); + if (isOpen == true) + { + //鎵撳紑 + this.device.SwitchControl(1); + } + else + { + //鍏抽棴 + this.device.SwitchControl(0); + } + } + + #endregion + } +} -- Gitblit v1.8.0