From 5986f63b75bd81c6cef262c670e9251c038cbf5d Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期二, 17 十二月 2019 17:21:07 +0800 Subject: [PATCH] 合并一个版本 --- ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs | 424 +++++++++++++++++++++++++++++++--------------------- 1 files changed, 253 insertions(+), 171 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs index 10cf90f..4981897 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs @@ -23,13 +23,17 @@ /// </summary> private CurtainData curtainData = null; /// <summary> - /// 鍏佽鎺ユ敹涓婇檺浣�(0:涓嶅厑璁� 1:鍏佽) + /// 鎺ユ敹寮�闄愪綅 false:娌℃湁鎺ユ敹鍒� true:宸茬粡鎺ユ敹鍒� /// </summary> - private string receiveUplimit = "0"; + private bool receiveOpenlimit = false; /// <summary> - /// 鍏佽鎺ユ敹涓嬮檺浣�(0:涓嶅厑璁� 1:鍏佽) + /// 鎺ユ敹鍚堥檺浣� false:娌℃湁鎺ユ敹鍒� true:宸茬粡鎺ユ敹鍒� /// </summary> - private string receiveDownLimit = "0"; + private bool receiveCloseLimit = false; + /// <summary> + /// 鍙戦�佸尯鍒� 1:寮�闄愪綅 2:鍚堥檺浣� + /// </summary> + private int sendDiv = 0; /// <summary> /// 鏄惁澶囦唤绐楀笜鏁版嵁 /// </summary> @@ -41,11 +45,11 @@ /// <summary> /// 寮�闄愪綅鐨勮繘搴︽潯 /// </summary> - private HorizontalSeekBar openSeekBar = null; + private SeekBarControl openSeekBar = null; /// <summary> /// 鍚堥檺浣嶇殑杩涘害鏉� /// </summary> - private HorizontalSeekBar closeSeekBar = null; + private SeekBarControl closeSeekBar = null; #endregion @@ -101,15 +105,7 @@ this.AddLimitRow(); //娣诲姞閲嶇疆鐢垫満琛� this.AddElectricalMachineryRow(); - //淇濆瓨 - var btnSave = new BottomClickButton(); - btnSave.TextID = R.MyInternationalizationString.uSave; - bodyFrameLayout.AddChidren(btnSave); - btnSave.ButtonClickEvent += (sender, e) => - { - //杩欎釜淇濆瓨娌″暐鎰忎箟 - this.CloseForm(); - }; + //闄愪綅鏁版嵁鎺ユ敹 this.ReceiveLimitData(); }); @@ -170,7 +166,7 @@ private void AddLimitRow() { var frameBack = new FrameLayout(); - frameBack.Height = Application.GetRealHeight(679); + frameBack.Height = Application.GetRealHeight(956); var rowLimit = new FrameRowControl(listView.rowSpace / 2); rowLimit.UseClickStatu = false; @@ -188,7 +184,7 @@ { btnRinght.IsSelected = !btnRinght.IsSelected; //灞曞紑鎶樺彔 - frameBack.Height = frameBack.Height > 10 ? 0 : Application.GetRealHeight(679); + frameBack.Height = frameBack.Height > 10 ? 0 : Application.GetRealHeight(956); }; //搴曠嚎 rowLimit.AddBottomLine(); @@ -200,6 +196,10 @@ this.AddCloseLimitProgress(frameBack); } + #endregion + + #region 鈻� 寮�闄愪綅琛宊__________________________ + /// <summary> /// 娣诲姞寮�闄愪綅杩涘害鏉� /// </summary> @@ -209,7 +209,7 @@ //寮�闄愪綅 var btnProgressView = new NormalViewControl(200, 50, true); btnProgressView.X = ControlCommonResourse.XXLeft; - btnProgressView.Y = Application.GetRealHeight(60); + btnProgressView.Y = Application.GetRealHeight(78); btnProgressView.TextSize = 12; btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1; btnProgressView.TextID = R.MyInternationalizationString.uOpenLimit; @@ -224,15 +224,9 @@ btnProgress1.Text = progressValue + "%"; frameBack.AddChidren(btnProgress1); //杩涘害鏉� - this.openSeekBar = new HorizontalSeekBar(); + this.openSeekBar = new SeekBarControl(965); 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.ProgressBarColor = 0xff288bfd; openSeekBar.Progress = progressValue; frameBack.AddChidren(openSeekBar); @@ -254,78 +248,134 @@ //绾� var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false); btnLine.X = ControlCommonResourse.XXLeft; - btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(69); + btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(156); 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) => + //鍑忓彿 + var btnMinus = new IconViewControl(104); + btnMinus.UseClickStatu = true; + btnMinus.X = Application.GetRealWidth(847); + btnMinus.Y = Application.GetRealHeight(46); + btnMinus.UnSelectedImagePath = "Item/MinusSign2.png"; + btnMinus.SelectedImagePath = "Item/MinusSign2Selected.png"; + frameBack.AddChidren(btnMinus); + btnMinus.ButtonClickEvent += (sender, e) => { - //鍊肩户缁敼鍙�,鍒欑瓑寰呮椂闂磋繕鍘� - waitTime = 4; + if (openSeekBar.Progress <= 0) + { + return; + } + openSeekBar.Progress -= 1; + openSeekBar.ProgressChangedEvent(1, openSeekBar.Progress); + }; + + //鍔犲彿 + var btnPlus = new IconViewControl(104); + btnPlus.UseClickStatu = true; + btnPlus.X = btnMinus.Right; + btnPlus.Y = btnMinus.Y; + btnPlus.UnSelectedImagePath = "Item/PlusSign2.png"; + btnPlus.SelectedImagePath = "Item/PlusSign2Selected.png"; + frameBack.AddChidren(btnPlus); + btnPlus.ButtonClickEvent += (sender, e) => + { + if (openSeekBar.Progress >= 100) + { + return; + } + openSeekBar.Progress += 1; + openSeekBar.ProgressChangedEvent(1, openSeekBar.Progress); + }; + + //淇濆瓨 + var btnSave = new NormalViewControl(150, 60, true); + btnSave.X = Application.GetRealWidth(906); + btnSave.Y = btnTemp1.Bottom + Application.GetRealHeight(68); + btnSave.TextAlignment = TextAlignment.Center; + btnSave.TextID = R.MyInternationalizationString.uSave; + btnSave.TextColor = UserCenterColor.Current.TextOrangeColor; + frameBack.AddChidren(btnSave); + btnSave.ButtonClickEvent += (sender, e) => + { + if (this.receiveOpenlimit == true) + { + //纭寮�闄愪綅鐐� + this.SaveOpenLimit(); + } + }; + + int oldProValue = curtainData.OpenLimitPersent; + openSeekBar.ProgressChangedEvent += (div, value) => + { //寮�闄愪綅涓嶈兘澶т簬鍚堥檺浣� if (value > closeSeekBar.Progress) { openSeekBar.Progress = closeSeekBar.Progress; return; } - if (checking == false) - { - startWait = true; - } - btnProgress1.Text = value + "%"; //鏁版嵁鍙樻洿,鐧惧垎姣� curtainData.OpenLimitPersent = value; }; + HdlThreadLogic.Current.RunThread(async () => { + //澶勭悊涓� + bool checking = false; while (openSeekBar.Parent != null) { - if (startWait == false) + int nowValue = curtainData.OpenLimitPersent; + if (oldProValue == nowValue || checking == true) { - await Task.Delay(200); + //鍊间笉绛夋墠澶勭悊 + await Task.Delay(500); continue; } - //寮�鍚�兼敼鍙樼瓑寰� - await Task.Delay(500); - waitTime--; - if (waitTime <= 0) + oldProValue = nowValue; + checking = true; + if (curtainData.DeleteOpenLimit == true) { - //濡傛灉2绉掑唴鍊间笉鍐嶆敼鍙�,鍒欒繘琛屽垽鏂� - startWait = false; - checking = true; - - var value = curtainData.OpenLimitPersent; - if (oldValue == value) + //閲嶇疆寮�闄愪綅鐐� + var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit); + if (result == false) { - //鐩稿悓鏁板�� 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; + curtainData.DeleteOpenLimit = false; } + //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� + this.sendDiv = 1; + curtainDevice.WcdGoToTiltValue(nowValue); + checking = false; } }); } + + /// <summary> + /// 纭寮�闄愪綅鐐� + /// </summary> + private void SaveOpenLimit() + { + //纭褰撳墠浣嶇疆涓哄紑闄愪綅? + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg); + this.ShowMassage(ShowMsgType.Confirm, msg, async () => + { + //鎵ц纭鍙婅鐩栦笂闄愪綅鐐� + var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit, + curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); + if (result == true) + { + curtainData.DeleteOpenLimit = true; + this.receiveOpenlimit = false; + } + }); + } + + #endregion + + #region 鈻� 鍚堥檺浣嶈___________________________ /// <summary> /// 娣诲姞鍚堥檺浣嶈繘搴︽潯 @@ -336,7 +386,7 @@ //鍚堥檺浣� var btnProgressView = new NormalViewControl(200, 50, true); btnProgressView.X = ControlCommonResourse.XXLeft; - btnProgressView.Y = Application.GetRealHeight(397); + btnProgressView.Y = Application.GetRealHeight(536); btnProgressView.TextSize = 12; btnProgressView.TextColor = UserCenterColor.Current.TextGrayColor1; btnProgressView.TextID = R.MyInternationalizationString.uCloseLimit; @@ -351,15 +401,9 @@ btnProgress1.Text = progressValue + "%"; frameBack.AddChidren(btnProgress1); //杩涘害鏉� - this.closeSeekBar = new HorizontalSeekBar(); + this.closeSeekBar = new SeekBarControl(965); 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.ProgressBarColor = 0xff288bfd; closeSeekBar.Progress = progressValue; frameBack.AddChidren(closeSeekBar); @@ -381,75 +425,126 @@ //绾� var btnLine = new NormalViewControl(frameBack.Width - ControlCommonResourse.XXLeft * 2, ControlCommonResourse.BottomLineHeight, false); btnLine.X = ControlCommonResourse.XXLeft; - btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(69); + btnLine.Y = btnTemp2.Bottom + Application.GetRealHeight(156); 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) => + //鍑忓彿 + var btnMinus = new IconViewControl(104); + btnMinus.UseClickStatu = true; + btnMinus.X = Application.GetRealWidth(847); + btnMinus.Y = Application.GetRealHeight(504); + btnMinus.UnSelectedImagePath = "Item/MinusSign2.png"; + btnMinus.SelectedImagePath = "Item/MinusSign2Selected.png"; + frameBack.AddChidren(btnMinus); + btnMinus.ButtonClickEvent += (sender, e) => { - //鍊肩户缁敼鍙�,鍒欑瓑寰呮椂闂磋繕鍘� - waitTime = 4; - //鍚堥檺浣嶄笉鑳藉皬浜庡悎闄愪綅 - if (value < openSeekBar.Progress) + if (closeSeekBar.Progress <= 0) { + return; + } + closeSeekBar.Progress -= 1; + closeSeekBar.ProgressChangedEvent(1, closeSeekBar.Progress); + }; + + //鍔犲彿 + var btnPlus = new IconViewControl(104); + btnPlus.UseClickStatu = true; + btnPlus.X = btnMinus.Right; + btnPlus.Y = btnMinus.Y; + btnPlus.UnSelectedImagePath = "Item/PlusSign2.png"; + btnPlus.SelectedImagePath = "Item/PlusSign2Selected.png"; + frameBack.AddChidren(btnPlus); + btnPlus.ButtonClickEvent += (sender, e) => + { + if (closeSeekBar.Progress >=100) + { + return; + } + closeSeekBar.Progress += 1; + closeSeekBar.ProgressChangedEvent(1, closeSeekBar.Progress); + }; + + //淇濆瓨 + var btnSave = new NormalViewControl(150, 60, true); + btnSave.X = Application.GetRealWidth(906); + btnSave.Y = btnTemp1.Bottom + Application.GetRealHeight(68); + btnSave.TextAlignment = TextAlignment.Center; + btnSave.TextID = R.MyInternationalizationString.uSave; + btnSave.TextColor = UserCenterColor.Current.TextOrangeColor; + frameBack.AddChidren(btnSave); + btnSave.ButtonClickEvent += (sender, e) => + { + if (this.receiveCloseLimit == true) + { + //淇濆瓨鍚堥檺浣嶇偣 + this.SaveCloseLimit(); + } + }; + + int oldProValue = curtainData.CloseLimitPersent; + closeSeekBar.ProgressChangedEvent += (div, value) => + { + if (value < curtainData.OpenLimitPersent) + { + //鍚堥檺浣嶄笉鑳藉皬浜庡悎闄愪綅 closeSeekBar.Progress = openSeekBar.Progress; return; } - if (checking == false) - { - startWait = true; - } - btnProgress1.Text = value + "%"; //鏁版嵁鍙樻洿,鐧惧垎姣� curtainData.CloseLimitPersent = value; }; + HdlThreadLogic.Current.RunThread(async () => { + //澶勭悊涓� + bool checking = false; while (closeSeekBar.Parent != null) { - if (startWait == false) + int nowValue = curtainData.CloseLimitPersent; + if (oldProValue == nowValue || checking == true) { - await Task.Delay(200); + //鍊间笉绛夋墠澶勭悊 + await Task.Delay(500); continue; } - //寮�鍚�兼敼鍙樼瓑寰� - await Task.Delay(500); - waitTime--; - if (waitTime <= 0) + checking = true; + oldProValue = nowValue; + if (curtainData.DeleteCloseLimit == true) { - //濡傛灉2绉掑唴鍊间笉鍐嶆敼鍙�,鍒欒繘琛屽垽鏂� - startWait = false; - checking = true; - - var value = curtainData.CloseLimitPersent; - if (oldValue == value) + //閲嶇疆鍚堥檺浣嶇偣 + var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit); + if (result == false) { - //鐩稿悓鏁板�� - 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; + curtainData.DeleteCloseLimit = false; } + //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣� + this.sendDiv = 2; + curtainDevice.WcdGoToTiltValue(nowValue); + checking = false; + } + }); + } + + /// <summary> + /// 淇濆瓨鍚堥檺浣嶇偣 + /// </summary> + private void SaveCloseLimit() + { + //纭褰撳墠浣嶇疆涓哄悎闄愪綅? + string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg); + this.ShowMassage(ShowMsgType.Confirm, msg, async () => + { + //鎵ц纭鍙婅鐩栧悎闄愪綅鐐� + var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, + curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); + if (result == true) + { + curtainData.DeleteCloseLimit = true; + this.receiveCloseLimit = false; } }); } @@ -476,14 +571,35 @@ msg = msg.Replace("{0}", "\r\n"); this.ShowMassage(ShowMsgType.Confirm, msg, () => { + //寮�鍚繘搴︽潯 + ProgressFormBar.Current.Start(); + //姝e湪閲嶇疆鐢垫満 + ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uElectricalMachineryResetting)); + //閲嶇疆绐楀笜 HdlThreadLogic.Current.RunThread(async () => { - //閲嶇疆绐楀笜 var result = await HdlDeviceCurtainLogic.Current.RestoreCurtain(curtainDevice); if (result == false) { + //鍏抽棴杩涘害鏉� + ProgressFormBar.Current.Close(); return; } + + //姣�10鐨勯暱搴﹀ぇ姒傛槸2绉�,澶氶鐣�1娆″嚭鏉� + int waitCount = ((curtainData.CurtainLength / 10) + 1) * 3; + + int timeCount = 0; + while (timeCount <= waitCount) + { + //杩涘害鏉″�� + ProgressFormBar.Current.SetValue(timeCount, waitCount); + timeCount++; + System.Threading.Thread.Sleep(1000); + } + //鍏抽棴杩涘害鏉� + ProgressFormBar.Current.Close(); + //鑾峰彇鏁版嵁鍚�,澶囦唤绐楀笜鏁版嵁 this.backupCurtainData = true; //閲嶆柊鍒濆鍖栫晫闈� @@ -507,8 +623,9 @@ this.ShowProgressBar(); this.curtainData = new CurtainData(); - this.receiveUplimit = "0"; - this.receiveDownLimit = "0"; + this.receiveOpenlimit = false; + this.receiveCloseLimit = false; + this.sendDiv = 0; bool receiptData = false; string mainkeys = LocalDevice.Current.GetDeviceMainKeys(curtainDevice); @@ -617,55 +734,20 @@ { return; } - lock (receiveUplimit) + foreach (var attriBute in device.DeviceStatusReport.AttriBute) { - if (receiveUplimit == "0" && receiveDownLimit == "0") + //绐楀笜鐧惧垎姣旀帹閫� + if (attriBute.AttributeId == 8) { - return; - } - foreach (var attriBute in device.DeviceStatusReport.AttriBute) - { - //绐楀笜鐧惧垎姣旀帹閫� - if (attriBute.AttributeId == 8) + //寮�闄愪綅 + if (sendDiv == 1) { - //涓婇檺浣� - 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 () => - { - //鎵ц纭鍙婅鐩栦笂闄愪綅鐐� - var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit, - curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); - if (result == true) - { - curtainData.DeleteOpenLimit = true; - } - }); - } - //鍚堥檺浣� - 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 () => - { - //鎵ц纭鍙婅鐩栧悎闄愪綅鐐� - var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, - curtainData.OpenLimitPersent, curtainData.CloseLimitPersent); - if (result == true) - { - curtainData.DeleteCloseLimit = true; - } - }); - } + receiveOpenlimit = true; + } + //鍚堥檺浣� + else if (sendDiv == 2) + { + receiveCloseLimit = true; } } } -- Gitblit v1.8.0