From d6b4e510f1430d19bc48da6894cf707bbe3c226d Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期二, 29 十月 2019 14:25:15 +0800 Subject: [PATCH] 2019.10.29-2 --- ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorLightPerceptionRegulationForm.cs | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 252 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorLightPerceptionRegulationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorLightPerceptionRegulationForm.cs new file mode 100755 index 0000000..471964c --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorLightPerceptionRegulationForm.cs @@ -0,0 +1,252 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.DevicePirSensor +{ + /// <summary> + /// PIR浼犳劅鍣ㄥ厜鎰熻皟鑺傜晫闈⑩槄 + /// </summary> + public class PirSensorLightPerceptionRegulationForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 浼犳劅鍣ㄨ澶� + /// </summary> + private IASZone deviceIASZone = null; + /// <summary> + /// 婊戝姩鐨勮繘搴︽潯 + /// </summary> + private HorizontalSeekBar SeekBar = null; + /// <summary> + /// 鐏厜鐨勯厤缃� + /// </summary> + private IASZone.ConfigureParamates Lightconfigure = null; + /// <summary> + /// 褰撳墠閫夋嫨鐨勫厜鎰熺瓑绾� + /// </summary> + private int selectLightLevel = -1; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_iasZone">浼犳劅鍣ㄨ澶�</param> + /// <param name="i_Lightconfigure">鐏厜鐨勯厤缃�</param> + public void ShowForm(IASZone i_iasZone, IASZone.ConfigureParamates i_Lightconfigure) + { + UserView.HomePage.Instance.ScrollEnabled = false; + + deviceIASZone = i_iasZone; + Lightconfigure = i_Lightconfigure; + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uLightPerceptionRegulation)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + + //瀹屾垚 + //var btnfinish = new TopLayoutFinshView(); + //topFrameLayout.AddChidren(btnfinish); + //btnfinish.MouseUpEventHandler += (sender, e) => + //{ + // if (this.selectLightLevel == -1) + // { + // //浠�涔堥兘娌℃湁閫夋嫨杩� + // this.CloseForm(); + // return; + // } + // //淇濆瓨浼犳劅鍣ㄧ殑鐏厜鐨勯厤缃俊鎭� + // this.SaveLightSettionData(); + //}; + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //宸﹀彸闂磋窛 + int space = Application.GetRealWidth(60); + int YY = Application.GetRealHeight(220); + + //鍏ㄥぉ + var btnFullDay = new NormalViewControl(200, true); + btnFullDay.X = space; + btnFullDay.Y = YY; + btnFullDay.TextID = R.MyInternationalizationString.uFullDay; + btnFullDay.TextAlignment = TextAlignment.CenterLeft; + bodyFrameLayout.AddChidren(btnFullDay); + + //涓瓑 + var btnMiddle = new NormalViewControl(200, true); + btnMiddle.Gravity = Gravity.CenterHorizontal; + btnMiddle.Y = YY; + btnMiddle.TextID = R.MyInternationalizationString.uMedium; + btnMiddle.TextAlignment = TextAlignment.Center; + bodyFrameLayout.AddChidren(btnMiddle); + + //杈冩殫 + var btnMoreDark = new NormalViewControl(200, true); + btnMoreDark.Y = YY; + btnMoreDark.TextID = R.MyInternationalizationString.uMoreDark; + btnMoreDark.TextAlignment = TextAlignment.CenterRight; + bodyFrameLayout.AddChidren(btnMoreDark); + btnMoreDark.X = bodyFrameLayout.Width - space - btnMoreDark.Width; + + //鍒诲害鍥剧墖 + var btnScale = new PicViewControl(919, 97); + btnScale.Y = btnMoreDark.Bottom + Application.GetRealHeight(20); + btnScale.Gravity = Gravity.CenterHorizontal; + btnScale.UnSelectedImagePath = "Item/PirSensorLightScale.png"; + bodyFrameLayout.AddChidren(btnScale); + + //鍒濆鍖栧厜鎰熺瓑绾х殑婊戝姩杩涘害鏉� + this.InitLightLevelControl(space, YY); + } + + #endregion + + #region 鈻� 璁剧疆鍏夋劅绛夌骇_______________________ + + /// <summary> + /// 鍒濆鍖栧厜鎰熺瓑绾х殑婊戝姩杩涘害鏉� + /// </summary> + /// <param name="space">宸﹀彸闂磋窛澶у皬</param> + /// <param name="TextYY">鏂囨湰鐨刌杞�</param> + private async void InitLightLevelControl(int space, int TextYY) + { + //鎵撳紑杩涘害鏉� + this.ShowProgressBar(); + + //鑾峰彇PIR浼犳劅鍣ㄧ殑銆愬厜鎰熺瓑绾ф�诲埢搴︺�� + var level = await HdlPirSensorLogic.Current.GetPirLightAbilitySize(this.deviceIASZone); + if (level == -1) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(ShowReLoadMode.YES); + return; + } + Application.RunOnMainThread(() => + { + if (this.Parent != null) + { + //鍒濆鍖栨粦鍔ㄨ繘搴︽潯 + this.InitSeekBarControl(level, space, TextYY); + } + }); + + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + } + + /// <summary> + /// 鍒濆鍖栨粦鍔ㄨ繘搴︽潯 + /// </summary> + /// <param name="level">鍏夋劅绛夌骇鎬诲埢搴�</param> + /// <param name="space">宸﹀彸闂磋窛澶у皬</param> + /// <param name="TextYY">鏂囨湰鐨刌杞�</param> + private void InitSeekBarControl(int level, int space, int TextYY) + { + //杩欎釜鏄埢搴︾Щ鍔ㄤ竴娆$殑鑼冨洿 + int avgWidth = (Application.CurrentWidth - space * 2) / level; + //鍒诲害鎸夐挳 + var btnScale = new IconViewControl(55); + btnScale.X = space + avgWidth * (level - Lightconfigure.levelSize) + Application.GetRealWidth(10); + btnScale.Y = Application.GetRealHeight(220) + TextYY; + btnScale.UnSelectedImagePath = "Item/PirSensorLightScaleButton.png"; + bodyFrameLayout.AddChidren(btnScale); + //杩欎笢瑗挎湁璇樊 + btnScale.X += Application.GetRealWidth(4) * (level - Lightconfigure.levelSize); + + //鍏夋劅绛夌骇鎬诲埢搴� + int lightLevelCount = level; + //杩涘害鏉� + SeekBar = new HorizontalSeekBar(); + SeekBar.X = space; + SeekBar.Y = Application.GetRealHeight(200) + TextYY; + SeekBar.Width = bodyFrameLayout.Width - space * 2; + SeekBar.Height = Application.GetRealHeight(110); + SeekBar.Max = level - 1; + SeekBar.Gravity = Gravity.CenterHorizontal; + SeekBar.BackgroundColor = UserCenterColor.Current.Transparent; + SeekBar.BorderColor = UserCenterColor.Current.Transparent; + SeekBar.ThumbColor = UserCenterColor.Current.Transparent; + SeekBar.ProgressColor = UserCenterColor.Current.Transparent; + bodyFrameLayout.AddChidren(SeekBar); + SeekBar.Progress = level - Lightconfigure.levelSize; + + SeekBar.ProgressChanged += (sender, value) => + { + //鍥犱负瀹冪殑绛夌骇鍒诲害浠庡乏寰�鍙虫槸浠庡ぇ鍒板皬鐨� + this.selectLightLevel = lightLevelCount - value; + //鍥炬爣绉诲姩 + btnScale.X = space + avgWidth * value + Application.GetRealWidth(10); + //杩欎笢瑗挎湁璇樊 + btnScale.X += Application.GetRealWidth(4) * value; + }; + } + + #endregion + + #region 鈻� 淇濆瓨閰嶇疆___________________________ + + /// <summary> + /// 淇濆瓨浼犳劅鍣ㄧ殑鐏厜鐨勯厤缃俊鎭� + /// </summary> + /// <returns></returns> + private async void SaveLightSettionData() + { + //寮�鍚繘搴︽潯 + this.ShowProgressBar(); + + //鍏堣褰曠紦瀛� + int levelSize = this.Lightconfigure.levelSize; + + //璁剧疆鏂板�� + this.Lightconfigure.levelSize = this.selectLightLevel; + + var result = await HdlPirSensorLogic.Current.SetPirSensorLightSettion(this.deviceIASZone, this.Lightconfigure); + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + + if (result == true) + { + Application.RunOnMainThread(() => + { + this.CloseForm(); + }); + } + else + { + //杩樺師缂撳瓨 + this.Lightconfigure.levelSize = levelSize; + } + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseForm() + { + UserView.HomePage.Instance.ScrollEnabled = true; + + base.CloseForm(); + } + + #endregion + } +} -- Gitblit v1.8.0