From 081ea8d273048fd03756718ac6fb48a3c09218e9 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期二, 29 十月 2019 13:10:00 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC --- ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs | 729 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 729 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs new file mode 100755 index 0000000..65f1e0a --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs @@ -0,0 +1,729 @@ +锘縰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 AutoOpenDirectionAndLimitSettionForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + ///绐楀笜鐨勫洖璺� + /// </summary> + private Rollershade curtainDevice = null; + /// <summary> + /// 绐楀笜鏁版嵁 + /// </summary> + private CurtainData curtainData = null; + /// <summary> + /// 鍏佽鎺ユ敹涓婇檺浣�(0:涓嶅厑璁� 1:鍏佽) + /// </summary> + private string receiveUplimit = "0"; + /// <summary> + /// 鍏佽鎺ユ敹涓嬮檺浣�(0:涓嶅厑璁� 1:鍏佽) + /// </summary> + private string receiveDownLimit = "0"; + /// <summary> + /// 鏄惁澶囦唤绐楀笜鏁版嵁 + /// </summary> + private bool backupCurtainData = false; + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + /// <summary> + /// 寮�闄愪綅鐨勮繘搴︽潯 + /// </summary> + private HorizontalSeekBar openSeekBar = null; + /// <summary> + /// 鍚堥檺浣嶇殑杩涘害鏉� + /// </summary> + private HorizontalSeekBar closeSeekBar = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_listdevice">绐楀笜鐨勫洖璺�</param> + public void ShowForm(Rollershade i_CurtainDevice) + { + UserView.HomePage.Instance.ScrollEnabled = false; + + 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(); + }; + //闄愪綅鏁版嵁鎺ユ敹 + this.ReceiveLimitData(); + }); + } + + #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 BottomDialogSelectForm(); + 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(679); + + 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/Next.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(679); + }; + //搴曠嚎 + rowLimit.AddBottomLine(); + + listView.AddChidren(frameBack); + //娣诲姞寮�闄愪綅杩涘害鏉� + this.AddOpenLimitProgress(frameBack); + //娣诲姞鍚堥檺浣嶈繘搴︽潯 + this.AddCloseLimitProgress(frameBack); + } + + /// <summary> + /// 娣诲姞寮�闄愪綅杩涘害鏉� + /// </summary> + /// <param name="frameBack"></param> + private void AddOpenLimitProgress(FrameLayout frameBack) + { + //寮�闄愪綅 + var btnProgressView = new NormalViewControl(200, 50, true); + btnProgressView.X = ControlCommonResourse.XXLeft; + btnProgressView.Y = Application.GetRealHeight(60); + btnProgressView.TextSize = 12; + btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1; + btnProgressView.TextID = R.MyInternationalizationString.uOpenLimit; + frameBack.AddChidren(btnProgressView); + + int progressValue = (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100); + var btnProgress1 = new NormalViewControl(200, 50, true); + btnProgress1.X = Application.GetRealWidth(200); + btnProgress1.Y = btnProgressView.Y; + btnProgress1.TextSize = 12; + btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1; + btnProgress1.Text = progressValue + "%"; + frameBack.AddChidren(btnProgress1); + //杩涘害鏉� + this.openSeekBar = new HorizontalSeekBar(); + openSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46); + openSeekBar.Gravity = Gravity.CenterHorizontal; + openSeekBar.Width = Application.GetRealWidth(962); + openSeekBar.Height = Application.GetRealHeight(84); + openSeekBar.Max = 100; + openSeekBar.BackgroundColor = 0xfff5f5f5; + openSeekBar.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor; + openSeekBar.ProgressColor = 0xff288bfd; + openSeekBar.Progress = progressValue; + frameBack.AddChidren(openSeekBar); + + var btnTemp1 = new NormalViewControl(200, 50, true); + btnTemp1.X = ControlCommonResourse.XXLeft; + btnTemp1.Y = btnProgressView.Bottom + Application.GetRealHeight(115); + btnTemp1.TextSize = 12; + btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3; + btnTemp1.Text = "0%"; + frameBack.AddChidren(btnTemp1); + var btnTemp2 = new NormalViewControl(200, 50, true); + btnTemp2.X = frameBack.Width - Application.GetRealWidth(200 + 50); + btnTemp2.Y = btnTemp1.Y; + btnTemp2.TextAlignment = TextAlignment.CenterRight; + btnTemp2.TextSize = 12; + btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3; + btnTemp2.Text = "100%"; + frameBack.AddChidren(btnTemp2); + //绾� + var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false); + btnLine.X = ControlCommonResourse.XXLeft; + btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(69); + btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; + frameBack.AddChidren(btnLine); + + int oldValue = progressValue; + int waitTime = 4;//500姣涓哄崟浣� + bool startWait = false; + bool checking = false; + openSeekBar.ProgressChanged += (sender, value) => + { + //鍊肩户缁敼鍙�,鍒欑瓑寰呮椂闂磋繕鍘� + waitTime = 4; + //寮�闄愪綅涓嶈兘澶т簬鍚堥檺浣� + if (value > closeSeekBar.Progress) + { + openSeekBar.Progress = closeSeekBar.Progress; + return; + } + if (checking == false) + { + startWait = true; + } + + btnProgress1.Text = value + "%"; + //鏁版嵁鍙樻洿,鐧惧垎姣� + curtainData.OpenLimitPersent = value; + }; + HdlThreadLogic.Current.RunThread(async () => + { + while (openSeekBar.Parent != null) + { + if (startWait == false) + { + await Task.Delay(200); + continue; + } + //寮�鍚�兼敼鍙樼瓑寰� + await Task.Delay(500); + waitTime--; + if (waitTime <= 0) + { + //濡傛灉2绉掑唴鍊间笉鍐嶆敼鍙�,鍒欒繘琛屽垽鏂� + startWait = false; + checking = true; + + var value = openSeekBar.Progress; + if (oldValue == value) + { + //鐩稿悓鏁板�� + checking = false; + continue; + } + oldValue = value; + if (curtainData.DeleteOpenLimit == true) + { + //閲嶇疆寮�闄愪綅鐐� + var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit); + if (result == false) + { + checking = false; + continue; + } + curtainData.DeleteOpenLimit = false; + } + receiveUplimit = "1"; + //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� + curtainDevice.WcdGoToTiltValue(value); + checking = false; + } + } + }); + } + + /// <summary> + /// 娣诲姞鍚堥檺浣嶈繘搴︽潯 + /// </summary> + /// <param name="frameBack"></param> + private void AddCloseLimitProgress(FrameLayout frameBack) + { + //鍚堥檺浣� + var btnProgressView = new NormalViewControl(200, 50, true); + btnProgressView.X = ControlCommonResourse.XXLeft; + btnProgressView.Y = Application.GetRealHeight(397); + btnProgressView.TextSize = 12; + btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1; + btnProgressView.TextID = R.MyInternationalizationString.uCloseLimit; + frameBack.AddChidren(btnProgressView); + + int progressValue = (int)(curtainData.CloseLimitValue / (curtainData.CurtainLength * 1.0) * 100); + var btnProgress1 = new NormalViewControl(200, 50, true); + btnProgress1.X = Application.GetRealWidth(200); + btnProgress1.Y = btnProgressView.Y; + btnProgress1.TextSize = 12; + btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1; + btnProgress1.Text = progressValue + "%"; + frameBack.AddChidren(btnProgress1); + //杩涘害鏉� + this.closeSeekBar = new HorizontalSeekBar(); + closeSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46); + closeSeekBar.Gravity = Gravity.CenterHorizontal; + closeSeekBar.Width = Application.GetRealWidth(962); + closeSeekBar.Height = Application.GetRealHeight(84); + closeSeekBar.Max = 100; + closeSeekBar.BackgroundColor = 0xfff5f5f5; + closeSeekBar.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor; + closeSeekBar.ProgressColor = 0xff288bfd; + closeSeekBar.Progress = progressValue; + frameBack.AddChidren(closeSeekBar); + + var btnTemp1 = new NormalViewControl(200, 50, true); + btnTemp1.X = ControlCommonResourse.XXLeft; + btnTemp1.Y = btnProgressView.Bottom + Application.GetRealHeight(115); + btnTemp1.TextSize = 12; + btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3; + btnTemp1.Text = "0%"; + frameBack.AddChidren(btnTemp1); + var btnTemp2 = new NormalViewControl(200, 50, true); + btnTemp2.X = frameBack.Width - Application.GetRealWidth(200 + 50); + btnTemp2.Y = btnTemp1.Y; + btnTemp2.TextAlignment = TextAlignment.CenterRight; + btnTemp2.TextSize = 12; + btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3; + btnTemp2.Text = "100%"; + frameBack.AddChidren(btnTemp2); + //绾� + var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false); + btnLine.X = ControlCommonResourse.XXLeft; + btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(69); + btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; + frameBack.AddChidren(btnLine); + + int oldValue = progressValue; + int waitTime = 4;//500姣涓哄崟浣� + bool startWait = false; + bool checking = false; + closeSeekBar.ProgressChanged += (sender, value) => + { + //鍊肩户缁敼鍙�,鍒欑瓑寰呮椂闂磋繕鍘� + waitTime = 4; + //鍚堥檺浣嶄笉鑳藉皬浜庡悎闄愪綅 + if (value < openSeekBar.Progress) + { + closeSeekBar.Progress = openSeekBar.Progress; + return; + } + if (checking == false) + { + startWait = true; + } + + btnProgress1.Text = value + "%"; + //鏁版嵁鍙樻洿,鐧惧垎姣� + curtainData.CloseLimitPersent = value; + }; + HdlThreadLogic.Current.RunThread(async () => + { + while (closeSeekBar.Parent != null) + { + if (startWait == false) + { + await Task.Delay(200); + continue; + } + //寮�鍚�兼敼鍙樼瓑寰� + await Task.Delay(500); + waitTime--; + if (waitTime <= 0) + { + //濡傛灉2绉掑唴鍊间笉鍐嶆敼鍙�,鍒欒繘琛屽垽鏂� + startWait = false; + checking = true; + + var value = closeSeekBar.Progress; + if (oldValue == value) + { + //鐩稿悓鏁板�� + checking = false; + continue; + } + oldValue = value; + if (curtainData.DeleteCloseLimit == true) + { + //閲嶇疆鍚堥檺浣嶇偣 + var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit); + if (result == false) + { + checking = false; + continue; + } + curtainData.DeleteCloseLimit = false; + } + receiveDownLimit = "1"; + //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� + curtainDevice.WcdGoToTiltValue(value); + checking = false; + } + } + }); + } + + #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.backupCurtainData = true; + //閲嶆柊鍒濆鍖栫晫闈� + this.InitMiddleFrame(); + }); + }); + }; + } + + #endregion + + #region 鈻� 鍒濆鍖栫獥甯樻暟鎹甠____________________ + + /// <summary> + /// 鍒濆鍖栫獥甯樻暟鎹� + /// </summary> + /// <returns></returns> + private bool InitCurtainDefultData() + { + //寮�鍚繘搴︽潯 + this.ShowProgressBar(); + + this.curtainData = new CurtainData(); + this.receiveUplimit = "0"; + this.receiveDownLimit = "0"; + + bool receiptData = false; + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); + HdlDeviceAttributeLogic.Current.AddAttributeEvent("CurtainDeviceAttribute", "DeviceStatusReport", (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; + } + } + else if (attriBute.AttributeId == 1) + { + //绐楀笜鎬婚暱 + curtainData.CurtainLength = attriBute.AttriButeData; + } + else if (attriBute.AttributeId == 16) + { + //寮�闄愪綅 + curtainData.OpenLimitValue = attriBute.AttriButeData; + } + else if (attriBute.AttributeId == 17) + { + //鍚堥檺浣� + curtainData.CloseLimitValue = attriBute.AttriButeData; + //鏁版嵁鎺ユ敹缁撴潫 + 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; + } + //绉婚櫎鐩戝惉 + HdlDeviceAttributeLogic.Current.RemoveEvent("CurtainDeviceAttribute"); + + //澶囦唤绐楀笜鏁版嵁 + if (this.backupCurtainData == true) + { + this.backupCurtainData = false; + HdlThreadLogic.Current.RunThread(async () => + { + //鏂瑰悜澶囦唤 + await HdlDeviceCurtainLogic.Current.BackupCurtainDirection(curtainDevice, curtainData.Direction); + //闄愪綅澶囦唤 + int uplimit= (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100); + int downlimit = (int)(curtainData.CloseLimitValue / (curtainData.CurtainLength * 1.0) * 100); + await HdlDeviceCurtainLogic.Current.BackupCurtainLimitPoint(curtainDevice, uplimit, downlimit); + }); + } + + return true; + } + + #endregion + + #region 鈻� 闄愪綅鏁版嵁鎺ユ敹_______________________ + + /// <summary> + /// 闄愪綅鏁版嵁鎺ユ敹 + /// </summary> + private void ReceiveLimitData() + { + if (HdlDeviceAttributeLogic.Current.IsEsixt("ReceiveLimitData") == true) + { + HdlDeviceAttributeLogic.Current.RemoveEvent("ReceiveLimitData"); + } + string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); + HdlDeviceAttributeLogic.Current.AddAttributeEvent("ReceiveLimitData", "DeviceStatusReport", (device) => + { + string checkKey = LocalDevice.Current.GetDeviceMainKeys(device); + if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258) + { + return; + } + lock (receiveUplimit) + { + if (receiveUplimit == "0" && receiveDownLimit == "0") + { + return; + } + foreach (var attriBute in device.DeviceStatusReport.AttriBute) + { + //绐楀笜鐧惧垎姣旀帹閫� + if (attriBute.AttributeId == 8) + { + //涓婇檺浣� + if (receiveUplimit == "1") + { + receiveUplimit = "0"; + openSeekBar.Progress = curtainData.OpenLimitPersent; + //纭褰撳墠浣嶇疆{0}涓哄紑闄愪綅? + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg); + msg = msg.Replace("{0}", curtainData.OpenLimitPersent + "%"); + this.ShowMassage(ShowMsgType.Confirm, msg, async () => + { + //鎵ц纭鍙婅鐩栦笂闄愪綅鐐� + await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit, + curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); + }); + } + //鍚堥檺浣� + else if (receiveDownLimit == "1") + { + receiveDownLimit = "0"; + closeSeekBar.Progress = curtainData.CloseLimitPersent; + //纭褰撳墠浣嶇疆{0}涓哄悎闄愪綅? + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg); + msg = msg.Replace("{0}", curtainData.CloseLimitPersent + "%"); + this.ShowMassage(ShowMsgType.Confirm, msg, async () => + { + //鎵ц纭鍙婅鐩栧悎闄愪綅鐐� + await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, + curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); + }); + } + } + } + } + }); + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseForm() + { + HdlDeviceAttributeLogic.Current.RemoveEvent("CurtainDeviceAttribute"); + HdlDeviceAttributeLogic.Current.RemoveEvent("ReceiveLimitData"); + + UserView.HomePage.Instance.ScrollEnabled = true; + + base.CloseForm(); + } + + #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 绐楀笜鏁版嵁 + /// </summary> + private class CurtainData + { + /// <summary> + /// false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜 + /// </summary> + public bool Direction = false; + /// <summary> + /// 鏄惁閲嶇疆寮�闄愪綅鐐� + /// </summary> + public bool DeleteOpenLimit = true; + /// <summary> + /// 鏄惁閲嶇疆鍚堥檺浣嶇偣 + /// </summary> + public bool DeleteCloseLimit = true; + /// <summary> + /// 寮�闄愪綅鐨勫�� + /// </summary> + public int OpenLimitValue = -1; + /// <summary> + /// 寮�闄愪綅鐨勭櫨鍒嗘瘮 + /// </summary> + public int OpenLimitPersent = -1; + /// <summary> + /// 鍚堥檺浣嶇殑鍊� + /// </summary> + public int CloseLimitValue = -1; + /// <summary> + /// 鍚堥檺浣嶇殑鐧惧垎姣� + /// </summary> + public int CloseLimitPersent = -1; + /// <summary> + /// 绐楀笜鎬婚暱 + /// </summary> + public int CurtainLength = -1; + } + + #endregion + } +} -- Gitblit v1.8.0