From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceFreshAirDetailCardForm.cs | 405 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 405 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceFreshAirDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceFreshAirDetailCardForm.cs new file mode 100755 index 0000000..8c05c1f --- /dev/null +++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceFreshAirDetailCardForm.cs @@ -0,0 +1,405 @@ +锘縰sing System; +using System.Collections.Generic; +using Shared.Common; +using Shared.Phone.UserCenter; +using ZigBee.Device; + +namespace Shared.Phone.MainPage.ControlForm +{ + /// <summary> + /// 鏂伴绫诲瀷鐨勬繁搴﹀崱鐗囩晫闈� + /// </summary> + public class DeviceFreshAirDetailCardForm : DeviceDetailCardCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + /// <summary> + /// 鐣岄潰涓婂彲浠ユ搷浣滅殑鎺т欢 + /// </summary> + private List<ButtonBase> listControl = new List<ButtonBase>(); + /// <summary> + /// 鎺т欢 + /// </summary> + private FreshAir freshAirDev = null; + /// <summary> + /// 鐘舵�佹帶浠� + /// </summary> + private NormalViewControl btnStatu = null; + /// <summary> + /// 褰撳墠鐨勬枃鏈� + /// </summary> + private string CurrentText = string.Empty; + + /// <summary> + /// 璁惧鍚嶇О鎺т欢 + /// </summary> + private NormalViewControl btnDeviceName = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack) + { + //宸︽粦涓嶈兘 + this.ScrollEnabled = true; + this.freshAirDev = (FreshAir)this.device; + //鍏堟竻绌� + this.listControl = new List<ButtonBase>(); + InitFreshAirControl(frameWhiteBack); + UpdateStatus(); + } + + /// <summary> + /// 鍒濆鍖栨柊椋庢帶浠� + /// </summary> + /// <param name="frameWhiteBack"></param> + private void InitFreshAirControl(FrameLayout frameWhiteBack) + { + //鏂伴鎺т欢鐨勫鍣� + var frameAcBack = new FrameLayout(); + frameAcBack.Y = Application.GetRealHeight(262); + frameAcBack.Width = Application.GetMinRealAverage(444); + frameAcBack.Height = Application.GetMinRealAverage(444); + frameAcBack.Gravity = Gravity.CenterHorizontal; + frameAcBack.BackgroundImagePath = "FreshAir/FreshAirPic.png"; + frameWhiteBack.AddChidren(frameAcBack); + + //鏂伴鑷姩Layout銆愪负浜嗘墿澶х偣鍑昏寖鍥淬�� + var autoFrameLayout = new NormalViewControl(213 + 40, 63 + 80, true); + autoFrameLayout.X = Application.GetRealWidth(275 - 20); + autoFrameLayout.Y = Application.GetRealHeight(821 - 20); + frameWhiteBack.AddChidren(autoFrameLayout); + autoFrameLayout.ButtonClickEvent += HandlerAuto; + + // 鑷姩锛堢1涓紝listControl銆�0銆戯級 + var btnAuto = new NormalViewControl(213, 63, true); + btnAuto.X = Application.GetRealWidth(275); + btnAuto.Y = Application.GetRealHeight(821); + btnAuto.TextID = R.MyInternationalizationString.Mode_Auto; + btnAuto.TextColor = ZigbeeColor.Current.XMGray3; + btnAuto.IsBold = false; + btnAuto.TextAlignment = TextAlignment.Center; + frameWhiteBack.AddChidren(btnAuto); + + this.listControl.Add(btnAuto); + btnAuto.ButtonClickEvent += HandlerAuto; + + //鑷姩涓嬪垝绾匡紙绗�2涓紝listControl銆�1銆戯級 + var btnAutoLine = new NormalViewControl(72, 12, true); + btnAutoLine.X = Application.GetRealWidth(346); + btnAutoLine.Y = Application.GetRealHeight(896); + btnAutoLine.BackgroundColor = ZigbeeColor.Current.XMOrange; + btnAutoLine.Visible = false; + frameWhiteBack.AddChidren(btnAutoLine); + this.listControl.Add(btnAutoLine); + btnAutoLine.ButtonClickEvent += HandlerAuto; + + //鏂伴鎵嬪姩Layout銆愪负浜嗘墿澶х偣鍑昏寖鍥淬�� + var manualFrameLayout = new NormalViewControl(213 + 40, 63 + 80, true); + manualFrameLayout.X = Application.GetRealWidth(488 - 20); + manualFrameLayout.Y = Application.GetRealHeight(821 - 20); + frameWhiteBack.AddChidren(manualFrameLayout); + manualFrameLayout.ButtonClickEvent += HandlerManual; + + //鎵嬪姩锛堢3涓紝listControl銆�2銆戯級 + var btnManual = new NormalViewControl(213, 63, true); + btnManual.X = Application.GetRealWidth(488); + btnManual.Y = btnAuto.Y; + btnManual.TextID = R.MyInternationalizationString.Manual; + btnManual.TextColor = ZigbeeColor.Current.XMGray3; + btnManual.IsBold = false; + btnManual.TextAlignment = TextAlignment.Center; + frameWhiteBack.AddChidren(btnManual); + this.listControl.Add(btnManual); + btnManual.ButtonClickEvent += HandlerManual; + + //鎵嬪姩涓嬪垝绾匡紙绗�4涓紝listControl銆�3銆戯級 + var btnManualLine = new NormalViewControl(72, 12, true); + btnManualLine.X = Application.GetRealWidth(560); + btnManualLine.BackgroundColor = ZigbeeColor.Current.XMOrange; + btnManualLine.Y = btnAutoLine.Y; + btnManualLine.Visible = false; + frameWhiteBack.AddChidren(btnManualLine); + this.listControl.Add(btnManualLine); + btnManualLine.ButtonClickEvent += HandlerManual; + + //楂橀锛堢5涓紝listControl銆�4銆戯級 + var btnHighSpeed = new IconViewControl(81); + btnHighSpeed.X = Application.GetRealWidth(207); + btnHighSpeed.Y = Application.GetRealHeight(999); + btnHighSpeed.UnSelectedImagePath = "AC/Fan_Height.png"; + btnHighSpeed.SelectedImagePath = "AC/Fan_HeightSelected.png"; + frameWhiteBack.AddChidren(btnHighSpeed); + this.listControl.Add(btnHighSpeed); + btnHighSpeed.ButtonClickEvent += (sender, e) => + { + if (freshAirDev.currentFanStatus == 0) + { + return; + } + if (freshAirDev.currentFanMode == 5) + { + var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AutoModeForbiddenOperate)); + msgContr.Show(); + return; + } + + if (!btnHighSpeed.IsSelected) + { + this.listControl[4].Enable = false; + this.SetFanComand(3); + } + }; + + //寮�鍏筹紙绗�6涓紝listControl銆�5銆戯級 + var btnSwitch = new IconViewControl(81); + btnSwitch.X = Application.GetRealWidth(444); + btnSwitch.Y = btnHighSpeed.Y; + btnSwitch.UnSelectedImagePath = "AC/OpenOrClose.png"; + btnSwitch.SelectedImagePath = "AC/OpenOrCloseSelected.png"; + frameWhiteBack.AddChidren(btnSwitch); + this.listControl.Add(btnSwitch); + btnSwitch.ButtonClickEvent += (sender, e) => + { + btnSwitch.IsSelected = !btnSwitch.IsSelected; + if (btnSwitch.IsSelected) + { + this.listControl[5].Enable = false; + this.SetFanComand(4); + } + else + { + this.listControl[5].Enable = false; + this.SetFanComand(0); + } + }; + + //浣庨锛堢7涓紝listControl銆�6銆戯級 + var btnLowSpeed = new IconViewControl(81); + btnLowSpeed.X = Application.GetRealWidth(677); + btnLowSpeed.Y = btnHighSpeed.Y; + btnLowSpeed.UnSelectedImagePath = "AC/Fan_Low.png"; + btnLowSpeed.SelectedImagePath = "AC/Fan_LowSelected.png"; + frameWhiteBack.AddChidren(btnLowSpeed); + this.listControl.Add(btnLowSpeed); + btnLowSpeed.ButtonClickEvent += (sender, e) => + { + if (freshAirDev.currentFanStatus == 0) + { + return; + } + if (freshAirDev.currentFanMode == 5) + { + var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AutoModeForbiddenOperate)); + msgContr.Show(); + return; + } + if (!btnLowSpeed.IsSelected) + { + this.listControl[6].Enable = false; + this.SetFanComand(1); + } + }; + } + + /// <summary> + /// 鑷姩浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void HandlerAuto(object sender, MouseEventArgs e) + { + if (freshAirDev.currentFanStatus == 0) + { + return; + } + if (freshAirDev.currentFanMode == 5) + { + return; + } + if (!listControl[0].IsSelected) + { + this.listControl[0].Enable = false; + this.SetFanComand(5); + } + } + + /// <summary> + /// 鎵嬪姩浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void HandlerManual(object sender, MouseEventArgs e) + { + if (freshAirDev.currentFanStatus == 0) + { + return; + } + if (freshAirDev.currentFanMode == 15) + { + return; + } + if (!this.listControl[2].IsSelected) + { + this.listControl[2].Enable = false; + this.SetFanComand(15); + } + } + #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璁惧灞炴�т笂鎶�) + { + if (report.DeviceStatusReport.CluterID == 514) + { + var attriButeList = report.DeviceStatusReport.AttriBute; + foreach (var attList in attriButeList) + { + if (attList.AttributeId == 0) + { + //椋庨�� + HdlThreadLogic.Current.RunMain(() => + { + UpdateStatus(); + }); + + //宸茬粡鎺ユ敹鍒扮綉鍏崇殑鍙嶉 + return true; + } + } + } + } + this.listControl[0].Enable = true; + this.listControl[2].Enable = true; + this.listControl[4].Enable = true; + this.listControl[5].Enable = true; + this.listControl[6].Enable = true; + return false; + } + #endregion + + #region 鈻� 璁剧疆鏂规硶 + /// <summary> + ///鍛戒护 + ///0:Off + ///1:Low + ///3:High + ///4:On + ///5:Auto + /// 15:Manual + /// </summary> + private void SetFanComand(int command) + { + //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅 + this.StartCheckResponeResult(this.listControl, (result) => + { + //鎺ユ敹鍒扮綉鍏冲洖澶� + if (result == true) + { + } + }); + + switch (command) + { + case 0: + freshAirDev.Close(); + break; + case 1: + freshAirDev.SetLowSpeed(); + break; + case 3: + freshAirDev.SetHighSpeed(); + break; + case 4: + freshAirDev.Open(); + break; + case 5: + freshAirDev.SetAuto(); + break; + case 15: + freshAirDev.SetManual(); + break; + } + } + #endregion + + #region 鈻� 鍒锋柊鐘舵�乢____________ + /// <summary> + /// 鍒锋柊鐘舵�� + /// </summary> + private void UpdateStatus() + { + //璁剧疆鐘舵�佹枃瀛� + if (freshAirDev.currentFanStatus == 4) + { + this.listControl[5].Enable = true; + //鎵撳紑 + this.listControl[5].IsSelected = true; + //璁剧疆鐘舵�佹枃瀛� + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uOpen1)); + } + if (freshAirDev.currentFanStatus == 0) + { + //鍏抽棴 + this.listControl[0].TextColor = ZigbeeColor.Current.XMGray3; + this.listControl[0].IsBold = false; + this.listControl[1].Visible = false; + this.listControl[2].TextColor = ZigbeeColor.Current.XMGray3; + this.listControl[2].IsBold = false; + this.listControl[3].Visible = false; + this.listControl[4].IsSelected = false; + this.listControl[5].IsSelected = false; + this.listControl[6].IsSelected = false; + this.listControl[5].Enable = true; + //璁剧疆鐘舵�佹枃瀛� + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); + return; + } + + //璁剧疆妯″紡 + if (freshAirDev.currentFanMode == 5) + { + this.listControl[0].TextColor = ZigbeeColor.Current.XMGray1; + this.listControl[0].IsBold = true; + this.listControl[1].Visible = true; + this.listControl[2].TextColor = ZigbeeColor.Current.XMGray3; + this.listControl[2].IsBold = false; + this.listControl[3].Visible = false; + this.listControl[0].Enable = true; + } + else if (freshAirDev.currentFanMode == 15) + { + this.listControl[0].TextColor = ZigbeeColor.Current.XMGray3; + this.listControl[0].IsBold = false; + this.listControl[1].Visible = false; + this.listControl[2].TextColor = ZigbeeColor.Current.XMGray1; + this.listControl[2].IsBold = true; + this.listControl[3].Visible = true; + this.listControl[2].Enable = true; + } + + //璁剧疆椋庨�� + if (freshAirDev.currentFanSpeed == 1) + { + this.listControl[4].IsSelected = false; + this.listControl[6].IsSelected = true; + this.listControl[6].Enable = true; + } + else if (freshAirDev.currentFanSpeed == 3) + { + this.listControl[4].IsSelected = true; + this.listControl[6].IsSelected = false; + this.listControl[4].Enable = true; + } + } + #endregion + } +} -- Gitblit v1.8.0