New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Safety
|
| | | {
|
| | | /// <summary>
|
| | | /// 延时设置的主界面★
|
| | | /// </summary>
|
| | | public class GarrisonAreaDelayedSettionForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 防区的延迟时间
|
| | | /// </summary>
|
| | | private Safeguard.CatDelayTimeResponseData timeResponseData = null;
|
| | | /// <summary>
|
| | | /// 进入延迟的时间控件
|
| | | /// </summary>
|
| | | private NormalViewControl inDelayTimeControl = null;
|
| | | /// <summary>
|
| | | /// 外出延迟的时间控件
|
| | | /// </summary>
|
| | | private NormalViewControl outDelayTimeControl = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDelayedSettion));
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | //背景
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Height = Application.GetRealHeight(423);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(frameBack);
|
| | |
|
| | | //该功能只对出入防区有效
|
| | | var btnTitle = new NormalViewControl(864, 50, true);
|
| | | btnTitle.X = ControlCommonResourse.XXLeft;
|
| | | btnTitle.Y = Application.GetRealHeight(38);
|
| | | btnTitle.TextSize = 12;
|
| | | btnTitle.TextColor = UserCenterColor.Current.TextGrayColor2;
|
| | | btnTitle.TextID = R.MyInternationalizationString.uThisFunctionOnlyInAndOutSectors;
|
| | | frameBack.AddChidren(btnTitle);
|
| | |
|
| | | var frameTable = new FrameListControl(29);
|
| | | frameTable.Y = btnTitle.Bottom + Application.GetRealHeight(38);
|
| | | frameTable.Height = frameBack.Height - btnTitle.Bottom - Application.GetRealHeight(38);
|
| | | bodyFrameLayout.AddChidren(frameTable);
|
| | |
|
| | | //添加所有的菜单
|
| | | this.AddAllMenuRow(frameTable);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 添加菜单___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加所有的菜单
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | private async void AddAllMenuRow(FrameListControl listView)
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | //获取防区的延迟时间(仅限出入防区),出错时返回null
|
| | | this.timeResponseData = await HdlSafeguardLogic.Current.GetGarrisonDelayTime();
|
| | | if (timeResponseData == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return;
|
| | | }
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //初始化【进入延时】行
|
| | | this.InitInDelayedRow(listView);
|
| | |
|
| | | //初始化【外出延时】行
|
| | | this.InitOutDelayedRow(listView);
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 进入延时___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化【进入延时】行
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | private void InitInDelayedRow(FrameListControl listView)
|
| | | {
|
| | | var row = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(row);
|
| | | row.Y = 0 - listView.rowSpace;
|
| | |
|
| | | //进入延时
|
| | | row.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uInDelayed), 500);
|
| | | //添加右箭头
|
| | | row.AddRightArrow();
|
| | | //底线
|
| | | row.AddBottomLine();
|
| | | //时间
|
| | | string second = Language.StringByID(R.MyInternationalizationString.Second);
|
| | | this.inDelayTimeControl = row.AddMostRightView(this.GetTimeText(this.timeResponseData.EntranceDelayTime), 200);
|
| | | this.inDelayTimeControl.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | |
|
| | | row.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //显示延时时间
|
| | | this.ShowDelayListTime(1);
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 外出延时___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化【外出延时】行
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | private void InitOutDelayedRow(FrameListControl listView)
|
| | | {
|
| | | var row = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(row);
|
| | |
|
| | | //外出延时
|
| | | row.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uOutDelayed), 500);
|
| | | //添加右箭头
|
| | | row.AddRightArrow();
|
| | | //时间
|
| | | string second = Language.StringByID(R.MyInternationalizationString.Second);
|
| | | this.outDelayTimeControl = row.AddMostRightView(this.GetTimeText(this.timeResponseData.GoOutDelayTime), 200);
|
| | | this.outDelayTimeControl.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | |
|
| | | row.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //显示延时时间
|
| | | this.ShowDelayListTime(2);
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 保存时间___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 保存时间
|
| | | /// </summary>
|
| | | /// <param name="inDelayTime">进入延迟时间</param>
|
| | | /// <param name="OutDelayTime">外出延迟时间</param>
|
| | | private async void SaveTime(int inDelayTime, int OutDelayTime)
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | var result = await HdlSafeguardLogic.Current.SetGarrisonDelayTime(inDelayTime, OutDelayTime);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | if (result == true)
|
| | | {
|
| | | //修改缓存
|
| | | this.timeResponseData.EntranceDelayTime = inDelayTime;
|
| | | this.timeResponseData.GoOutDelayTime = OutDelayTime;
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (this.inDelayTimeControl != null)
|
| | | {
|
| | | //显示时间翻译文本
|
| | | this.inDelayTimeControl.Text = this.GetTimeText(inDelayTime);
|
| | | }
|
| | | if (this.outDelayTimeControl != null)
|
| | | {
|
| | | //显示时间翻译文本
|
| | | this.outDelayTimeControl.Text = this.GetTimeText(OutDelayTime);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 显示延时时间_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 显示延时时间列表
|
| | | /// </summary>
|
| | | /// <param name="div">1:进入延迟 2:外出延迟</param>
|
| | | private void ShowDelayListTime(int div)
|
| | | {
|
| | | //分
|
| | | string strMinute = Language.StringByID(R.MyInternationalizationString.uMinute);
|
| | | //秒
|
| | | string strSecond = Language.StringByID(R.MyInternationalizationString.uSecond);
|
| | | var listfirst = new List<string>();
|
| | | var listSecond = new List<List<string>>();
|
| | | for (int i = 0; i <= 29; i++)
|
| | | {
|
| | | listfirst.Add(i.ToString().PadLeft(2, '0') + strMinute);
|
| | | var listTemp = new List<string>();
|
| | | for (int j = 0; j <= 59; j++)
|
| | | {
|
| | | if (i == 0 && j == 0)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | listTemp.Add(j.ToString().PadLeft(2, '0') + strSecond);
|
| | | }
|
| | | listSecond.Add(listTemp);
|
| | | }
|
| | | //加一个30分钟吧
|
| | | listfirst.Add("30" + strMinute);
|
| | | var listTemp2 = new List<string>() { "00" + strSecond };
|
| | | listSecond.Add(listTemp2);
|
| | |
|
| | | //进入延迟
|
| | | int delayTime = this.timeResponseData.EntranceDelayTime;
|
| | | string title = Language.StringByID(R.MyInternationalizationString.uInDelayed);
|
| | | if (div == 2)
|
| | | {
|
| | | //外出延迟
|
| | | delayTime = this.timeResponseData.GoOutDelayTime;
|
| | | title = Language.StringByID(R.MyInternationalizationString.uOutDelayed);
|
| | | }
|
| | |
|
| | | string value = (delayTime / 60).ToString().PadLeft(2, '0') + strMinute;
|
| | | int index1 = listfirst.IndexOf(value);
|
| | | if (index1 == -1)
|
| | | {
|
| | | index1 = 0;
|
| | | }
|
| | | value = (delayTime % 60).ToString().PadLeft(2, '0') + strSecond;
|
| | | int index2 = listSecond[index1].IndexOf(value);
|
| | | if (index2 == -1)
|
| | | {
|
| | | index2 = 0;
|
| | | }
|
| | |
|
| | | PickerView.ShowSecondary(listfirst, listSecond, (value1, value2) =>
|
| | | {
|
| | | int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2));
|
| | | int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
|
| | | int delaySecond = minute * 60 + second;
|
| | | //保存时间
|
| | | if (div == 1)
|
| | | {
|
| | | //进入延迟
|
| | | this.SaveTime(delaySecond, this.timeResponseData.GoOutDelayTime);
|
| | | }
|
| | | else
|
| | | {
|
| | | //外出延迟
|
| | | this.SaveTime(this.timeResponseData.EntranceDelayTime, delaySecond);
|
| | | }
|
| | | },
|
| | | index1, index2, title,
|
| | | Language.StringByID(R.MyInternationalizationString.uFinish),
|
| | | Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取时间的翻译文本
|
| | | /// </summary>
|
| | | /// <param name="timeSecond">秒</param>
|
| | | /// <returns></returns>
|
| | | private string GetTimeText(int timeSecond)
|
| | | {
|
| | | string textValue = string.Empty;
|
| | | //分
|
| | | int checkValue = timeSecond / 60;
|
| | | if (checkValue > 0)
|
| | | {
|
| | | string minu = Language.StringByID(R.MyInternationalizationString.uMinute);
|
| | | textValue = checkValue + minu;
|
| | | }
|
| | | //秒
|
| | | checkValue = timeSecond % 60;
|
| | | if (checkValue > 0)
|
| | | {
|
| | | string second = Language.StringByID(R.MyInternationalizationString.uSecond);
|
| | | textValue += checkValue + second;
|
| | | }
|
| | | return textValue;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|