From c1de48884fa145a16a0f8bcee93274dcfaa0ff82 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 07 五月 2020 10:40:28 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-2020xm --- ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs | 536 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 536 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs new file mode 100755 index 0000000..49d8a27 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/SiphonateDirectionAndLimitSettionForm.cs @@ -0,0 +1,536 @@ +锘縰sing Shared.Common; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.DeviceCurtain +{ + /// <summary> + /// 鍗峰笜鐨勪笂涓嬮檺浣嶇殑閰嶇疆鐣岄潰 + /// </summary> + public class SiphonateDirectionAndLimitSettionForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + ///绐楀笜鐨勫洖璺� + /// </summary> + private Rollershade curtainDevice = null; + /// <summary> + /// 绐楀笜鏁版嵁 + /// </summary> + private CurtainData curtainData = null; + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_listdevice">绐楀笜鐨勫洖璺�</param> + public void ShowForm(Rollershade i_CurtainDevice) + { + this.curtainDevice = i_CurtainDevice; + + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDirectionAndLimit)); + + HdlThreadLogic.Current.RunThread(() => + { + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + }); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //鑾峰彇璁惧鍒濆鏁版嵁 + var result = this.InitCurtainDefultData(); + if (result == false) + { + //鏄剧ず閲嶆柊鍔犺浇鐨勭晫闈� + this.ShowReLoadView(); + return; + } + HdlThreadLogic.Current.RunMain(() => + { + //娓呯┖bodyFrame + bodyFrameLayout.BackgroundColor = UserCenterColor.Current.White; + this.ClearBodyFrame(); + + this.listView = new VerticalListControl(29); + listView.Y = Application.GetRealHeight(-6); + listView.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listView); + + //娣诲姞鏂瑰悜琛� + this.AddDirectionRow(); + //娣诲姞闄愪綅琛� + this.AddLimitRow(); + //娣诲姞閲嶇疆鐢垫満琛� + this.AddElectricalMachineryRow(); + //淇濆瓨 + var btnSave = new BottomClickButton(); + btnSave.TextID = R.MyInternationalizationString.uSave; + bodyFrameLayout.AddChidren(btnSave); + btnSave.ButtonClickEvent += (sender, e) => + { + //杩欎釜淇濆瓨娌″暐鎰忎箟 + this.CloseForm(); + }; + }); + } + + #endregion + + #region 鈻� 鏂瑰悜琛宊____________________________ + + /// <summary> + /// 娣诲姞鏂瑰悜琛� + /// </summary> + private void AddDirectionRow() + { + var rowDirection = new FrameRowControl(listView.rowSpace / 2); + listView.AddChidren(rowDirection); + //鏂瑰悜 + rowDirection.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uDirection), 600); + //鍙崇澶� + rowDirection.AddRightArrow(); + //鐘舵�� + var btnStatu = rowDirection.AddMostRightView("", 300); + btnStatu.TextID = curtainData.Direction == false ? R.MyInternationalizationString.uForwardDirection : R.MyInternationalizationString.uReverseDirection; + //搴曠嚎 + rowDirection.AddBottomLine(); + + int nowSelectNo = curtainData.Direction == false ? 0 : 1; + rowDirection.ButtonClickEvent += (sender, e) => + { + var listText = new List<string>(); + listText.Add(Language.StringByID(R.MyInternationalizationString.uForwardDirection));//姝e悜 + listText.Add(Language.StringByID(R.MyInternationalizationString.uReverseDirection));//鍙嶅悜 + + var form = new BottomItemSelectForm(); + form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, nowSelectNo); + form.FinishSelectEvent += async (index) => + { + //鍙樻洿鏂瑰悜 + var result = await HdlDeviceCurtainLogic.Current.SetCurtainDirection(curtainDevice, index == 0 ? false : true); + if (result == false) + { + return; + } + nowSelectNo = index; + btnStatu.Text = listText[index]; + curtainData.Direction = index == 0 ? false : true; + }; + }; + } + + #endregion + + #region 鈻� 闄愪綅琛宊____________________________ + + /// <summary> + /// 娣诲姞闄愪綅琛� + /// </summary> + private void AddLimitRow() + { + var frameBack = new FrameLayout(); + frameBack.Height = Application.GetRealHeight(714); + + var rowLimit = new FrameRowControl(listView.rowSpace / 2); + rowLimit.UseClickStatu = false; + listView.AddChidren(rowLimit); + //闄愪綅 + rowLimit.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uLimit), 600); + //鍙崇澶� + var btnRinght = rowLimit.AddMostRightEmptyIcon(58, 58); + rowLimit.ChangedChidrenBindMode(btnRinght, ChidrenBindMode.NotBind); + btnRinght.UseClickStatu = false; + btnRinght.UnSelectedImagePath = "Item/RightNext.png"; + btnRinght.SelectedImagePath = "Item/Down.png"; + btnRinght.IsSelected = true; + btnRinght.ButtonClickEvent += (sender, e) => + { + btnRinght.IsSelected = !btnRinght.IsSelected; + //灞曞紑鎶樺彔 + frameBack.Height = frameBack.Height > 10 ? 0 : Application.GetRealHeight(714); + }; + //搴曠嚎 + rowLimit.AddBottomLine(); + + listView.AddChidren(frameBack); + //娣诲姞涓嬮檺浣嶆帶浠� + this.AddDownLimitControl(frameBack); + //娣诲姞寮�闄愪綅鎺т欢 + this.AddUpLimitControl(frameBack); + } + + /// <summary> + /// 娣诲姞涓嬮檺浣嶆帶浠� + /// </summary> + /// <param name="frameBack"></param> + private void AddDownLimitControl(FrameLayout frameBack) + { + var frameIcon = new FrameLayout(); + frameIcon.X = Application.GetRealWidth(228); + frameIcon.Y = Application.GetRealHeight(121); + frameIcon.Width = this.GetPictrueRealSize(265); + frameIcon.Height= this.GetPictrueRealSize(495); + frameIcon.BackgroundImagePath = "Item/DeviceLimitGround.png"; + frameBack.AddChidren(frameIcon); + + var frameIconback = new FrameLayoutStatuControl(); + frameIconback.Height = this.GetPictrueRealSize(144); + frameIconback.Width = this.GetPictrueRealSize(144); + frameIconback.Radius = (uint)this.GetPictrueRealSize(144) / 2; + frameIconback.BackgroundColor = 0xffeff2fb; + frameIconback.Gravity = Gravity.CenterHorizontal; + frameIconback.Y = this.GetPictrueRealSize(35); + frameIcon.AddChidren(frameIconback); + var btnIcon = new NormalViewControl(this.GetPictrueRealSize(69), this.GetPictrueRealSize(35), false); + btnIcon.UnSelectedImagePath = "Item/DownTriangle.png"; + btnIcon.Gravity = Gravity.Center; + frameIconback.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly); + + var frameText = new FrameLayoutStatuControl(); + frameText.Y= this.GetPictrueRealSize(265); + frameText.Height = this.GetPictrueRealSize(120); + frameIcon.AddChidren(frameText); + + //纭畾 + var btnOk = new NormalViewControl(frameIcon.Width, this.GetPictrueRealSize(60), false); + btnOk.TextID = R.MyInternationalizationString.uConfirm1; + btnOk.TextAlignment = TextAlignment.Center; + btnOk.TextColor = UserCenterColor.Current.TextOrangeColor; + frameText.AddChidren(btnOk, ChidrenBindMode.BindEventOnly); + //搴曠嚎 + var btnLine1 = new NormalViewControl(this.GetPictrueRealSize(100), ControlCommonResourse.BottomLineHeight, false); + btnLine1.BackgroundColor = UserCenterColor.Current.TextOrangeColor; + btnLine1.Gravity = Gravity.CenterHorizontal; + btnLine1.Y = btnOk.Bottom - this.GetPictrueRealSize(8); + frameText.AddChidren(btnLine1); + + //涓嬮檺浣� + var btnDown = new NormalViewControl(frameIcon.Width, this.GetPictrueRealSize(60), false); + btnDown.TextID = R.MyInternationalizationString.uDownLimit; + btnDown.Y = btnOk.Bottom; + btnDown.TextAlignment = TextAlignment.Center; + btnDown.TextColor = UserCenterColor.Current.TextOrangeColor; + frameText.AddChidren(btnDown, ChidrenBindMode.BindEventOnly); + + //搴曠嚎 + var btnLine2 = new NormalViewControl(this.GetPictrueRealSize(124), ControlCommonResourse.BottomLineHeight, false); + btnLine2.BackgroundColor = UserCenterColor.Current.TextOrangeColor; + btnLine2.Gravity = Gravity.CenterHorizontal; + btnLine2.Y = btnDown.Bottom - this.GetPictrueRealSize(8); + frameText.AddChidren(btnLine2); + + //鍥炬爣鐐瑰嚮 + frameIconback.ButtonClickEvent += (sender, e) => + { + curtainDevice.CurtainUpDownStopControl(1); + }; + //閲嶅啓鎺т欢鐐瑰嚮鏁堟灉 + frameIconback.SelectStatuEvent += (select) => + { + if (select == true) + { + frameIconback.BackgroundColor = 0xfffef1ed; + } + else + { + frameIconback.BackgroundColor = 0xffeff2fb; + } + }; + + //闄愪綅纭畾 + frameText.ButtonClickEvent += (sender, e) => + { + //纭褰撳墠浣嶇疆涓轰笅闄愪綅? + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainDownLimitMsg); + this.ShowMassage(ShowMsgType.Confirm, msg, async () => + { + //鎵ц纭畾鍙婅鐩� + await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, -1, -1); + }); + }; + //閲嶅啓鎺т欢鐐瑰嚮鏁堟灉 + frameText.SelectStatuEvent += (select) => + { + if (select == true) + { + frameIconback.BackgroundColor = UserCenterColor.Current.White; + btnOk.TextColor = UserCenterColor.Current.White; + btnDown.TextColor = UserCenterColor.Current.White; + frameIcon.BackgroundImagePath = "Item/DeviceLimitGroundSelected.png"; + } + else + { + frameIconback.BackgroundColor = 0xffeff2fb; + btnOk.TextColor = UserCenterColor.Current.TextOrangeColor; + btnDown.TextColor = UserCenterColor.Current.TextOrangeColor; + frameIcon.BackgroundImagePath = "Item/DeviceLimitGround.png"; + } + }; + } + + /// <summary> + /// 娣诲姞涓婇檺浣嶆帶浠� + /// </summary> + /// <param name="frameBack"></param> + private void AddUpLimitControl(FrameLayout frameBack) + { + var frameIcon = new FrameLayout(); + frameIcon.X = Application.GetRealWidth(619); + frameIcon.Y = Application.GetRealHeight(121); + frameIcon.Width = this.GetPictrueRealSize(265); + frameIcon.Height = this.GetPictrueRealSize(495); + frameIcon.BackgroundImagePath = "Item/DeviceLimitGround.png"; + frameBack.AddChidren(frameIcon); + + var frameIconback = new FrameLayoutStatuControl(); + frameIconback.Height = this.GetPictrueRealSize(144); + frameIconback.Width = this.GetPictrueRealSize(144); + frameIconback.Radius = (uint)this.GetPictrueRealSize(144) / 2; + frameIconback.BackgroundColor = 0xffeff2fb; + frameIconback.Gravity = Gravity.CenterHorizontal; + frameIconback.Y = this.GetPictrueRealSize(35); + frameIcon.AddChidren(frameIconback); + var btnIcon = new NormalViewControl(this.GetPictrueRealSize(69), this.GetPictrueRealSize(35), false); + btnIcon.UnSelectedImagePath = "Item/UpTriangle.png"; + btnIcon.Gravity = Gravity.Center; + frameIconback.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly); + + var frameText = new FrameLayoutStatuControl(); + frameText.Y = this.GetPictrueRealSize(265); + frameText.Height = this.GetPictrueRealSize(120); + frameIcon.AddChidren(frameText); + + //纭畾 + var btnOk = new NormalViewControl(frameIcon.Width, this.GetPictrueRealSize(60), false); + btnOk.TextID = R.MyInternationalizationString.uConfirm1; + btnOk.TextAlignment = TextAlignment.Center; + btnOk.TextColor = UserCenterColor.Current.TextOrangeColor; + frameText.AddChidren(btnOk, ChidrenBindMode.BindEventOnly); + //搴曠嚎 + var btnLine1 = new NormalViewControl(this.GetPictrueRealSize(100), ControlCommonResourse.BottomLineHeight, false); + btnLine1.BackgroundColor = UserCenterColor.Current.TextOrangeColor; + btnLine1.Gravity = Gravity.CenterHorizontal; + btnLine1.Y = btnOk.Bottom - this.GetPictrueRealSize(8); + frameText.AddChidren(btnLine1); + + //涓婇檺浣� + var btnDown = new NormalViewControl(frameIcon.Width, this.GetPictrueRealSize(60), false); + btnDown.TextID = R.MyInternationalizationString.uUpLimit; + btnDown.Y = btnOk.Bottom; + btnDown.TextAlignment = TextAlignment.Center; + btnDown.TextColor = UserCenterColor.Current.TextOrangeColor; + frameText.AddChidren(btnDown, ChidrenBindMode.BindEventOnly); + + //搴曠嚎 + var btnLine2 = new NormalViewControl(this.GetPictrueRealSize(124), ControlCommonResourse.BottomLineHeight, false); + btnLine2.BackgroundColor = UserCenterColor.Current.TextOrangeColor; + btnLine2.Gravity = Gravity.CenterHorizontal; + btnLine2.Y = btnDown.Bottom - this.GetPictrueRealSize(8); + frameText.AddChidren(btnLine2); + + //鍥炬爣鐐瑰嚮 + frameIconback.ButtonClickEvent += (sender, e) => + { + curtainDevice.CurtainUpDownStopControl(0); + }; + //閲嶅啓鎺т欢鐐瑰嚮鏁堟灉 + frameIconback.SelectStatuEvent += (select) => + { + if (select == true) + { + frameIconback.BackgroundColor = 0xfffef1ed; + } + else + { + frameIconback.BackgroundColor = 0xffeff2fb; + } + }; + + //闄愪綅纭畾 + frameText.ButtonClickEvent += (sender, e) => + { + //纭褰撳墠浣嶇疆涓轰笂闄愪綅? + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainUpLimitMsg); + this.ShowMassage(ShowMsgType.Confirm, msg, async () => + { + //鎵ц纭畾鍙婅鐩� + await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit, -1, -1); + }); + }; + //閲嶅啓鎺т欢鐐瑰嚮鏁堟灉 + frameText.SelectStatuEvent += (select) => + { + if (select == true) + { + frameIconback.BackgroundColor = UserCenterColor.Current.White; + btnOk.TextColor = UserCenterColor.Current.White; + btnDown.TextColor = UserCenterColor.Current.White; + frameIcon.BackgroundImagePath = "Item/DeviceLimitGroundSelected.png"; + } + else + { + frameIconback.BackgroundColor = 0xffeff2fb; + btnOk.TextColor = UserCenterColor.Current.TextOrangeColor; + btnDown.TextColor = UserCenterColor.Current.TextOrangeColor; + frameIcon.BackgroundImagePath = "Item/DeviceLimitGround.png"; + } + }; + } + + #endregion + + #region 鈻� 閲嶇疆鐢垫満___________________________ + + /// <summary> + /// 娣诲姞閲嶇疆鐢垫満琛� + /// </summary> + private void AddElectricalMachineryRow() + { + var rowReset = new FrameRowControl(listView.rowSpace / 2); + listView.AddChidren(rowReset); + //閲嶇疆鐢垫満 + rowReset.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uResetElectricalMachinery), 600); + //搴曠嚎 + rowReset.AddBottomLine(); + rowReset.ButtonClickEvent += (sender, e) => + { + //閲嶇疆鐢垫満灏嗗垵濮嬪寲{0}鏂瑰悜涓庨檺浣嶈缃紝纭缁х画锛� + string msg = Language.StringByID(R.MyInternationalizationString.uResetElectricalMachineryMsg); + msg = msg.Replace("{0}", "\r\n"); + this.ShowMassage(ShowMsgType.Confirm, msg, () => + { + HdlThreadLogic.Current.RunThread(async () => + { + //閲嶇疆绐楀笜 + var result = await HdlDeviceCurtainLogic.Current.RestoreCurtain(curtainDevice); + if (result == false) + { + return; + } + //閲嶆柊鍒濆鍖栫晫闈� + this.InitMiddleFrame(); + }); + }); + }; + } + + #endregion + + #region 鈻� 鍒濆鍖栫獥甯樻暟鎹甠____________________ + + /// <summary> + /// 鍒濆鍖栫獥甯樻暟鎹� + /// </summary> + /// <returns></returns> + private bool InitCurtainDefultData() + { + //寮�鍚繘搴︽潯 + this.ShowProgressBar(); + + this.curtainData = new CurtainData(); + + bool receiptData = false; + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("CurtainDeviceAttribute", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (device) => + { + string checkKey = LocalDevice.Current.GetDeviceMainKeys(device); + if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258) + { + return; + } + foreach (var attriBute in device.DeviceStatusReport.AttriBute) + { + if (attriBute.AttributeId == 23) + { + //寮�鍚堝笜鏂瑰悜 + if (0 < (attriBute.AttriButeData & 0x01)) + { + //鍙嶅悜 + curtainData.Direction = true; + } + else + { + //姝e悜 + curtainData.Direction = false; + } + //鏁版嵁鎺ユ敹缁撴潫 + receiptData = true; + } + } + }); + //鍙戦�佽幏鍙栫獥甯橀檺浣嶉厤缃殑鍛戒护 + HdlDeviceCurtainLogic.Current.SetGetCurtainLimitSettionComand(curtainDevice); + + int timeCount = 30; + while (receiptData == false && timeCount >= 0) + { + System.Threading.Thread.Sleep(100); + timeCount--; + } + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + + if (timeCount <= 0) + { + //鑾峰彇绐楀笜鏂瑰悜涓庨檺浣嶈缃け璐� + string msg = Language.StringByID(R.MyInternationalizationString.uGetCurtainDirectionAndLimitSettionFail); + //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); + this.ShowMassage(ShowMsgType.Tip, msg); + return false; + } + //绉婚櫎鐩戝惉 + HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute"); + + return true; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute"); + + base.CloseFormBefore(); + } + + #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 绐楀笜鏁版嵁 + /// </summary> + private class CurtainData + { + /// <summary> + /// false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜 + /// </summary> + public bool Direction = false; + } + + #endregion + } +} -- Gitblit v1.8.0