New file |
| | |
| | | using 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">文本的Y轴</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">文本的Y轴</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
|
| | | }
|
| | | }
|