New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter.Safety |
| | | { |
| | | /// <summary> |
| | | /// 晾衣架类的安防报警设置界面 |
| | | /// </summary> |
| | | public class AlarmTargetStatuSelectHangerForm : DialogCommonForm |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 结束选择的事件(key:全部状态的翻译文本) |
| | | /// </summary> |
| | | public Action<string, List<Safeguard.TaskListInfo>> FinishSelectEvent = null; |
| | | /// <summary> |
| | | /// 动作信息 |
| | | /// </summary> |
| | | private List<Safeguard.TaskListInfo> listTaskinfo = new List<Safeguard.TaskListInfo>(); |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建) |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="i_listTaskInfo"></param> |
| | | public void ShowForm(CommonDevice device, List<Safeguard.TaskListInfo> i_listTaskInfo) |
| | | { |
| | | if (i_listTaskInfo != null) |
| | | { |
| | | foreach (var data in i_listTaskInfo) |
| | | { |
| | | //以防万一,剔除不合法数据 |
| | | if (data.TaskType == 1 || data.TaskType == 6) |
| | | { |
| | | listTaskinfo.Add(data); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //初始化中部信息 |
| | | this.InitMiddleFrame(device); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部信息 |
| | | /// </summary> |
| | | private void InitMiddleFrame(CommonDevice device) |
| | | { |
| | | //头部背景 |
| | | var frameTopBack = new FrameLayout(); |
| | | frameTopBack.Y = Application.GetRealHeight(1207); |
| | | frameTopBack.Height = Application.GetRealHeight(138); |
| | | frameTopBack.BackgroundColor = UserCenterColor.Current.White; |
| | | frameTopBack.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); |
| | | bodyFrameLayout.AddChidren(frameTopBack); |
| | | |
| | | //明细背景 |
| | | var frameDetailBack = new FrameLayout(); |
| | | frameDetailBack.Y = frameTopBack.Bottom; |
| | | frameDetailBack.Height = bodyFrameLayout.Height - frameTopBack.Bottom; |
| | | frameDetailBack.BackgroundColor = UserCenterColor.Current.White; |
| | | bodyFrameLayout.AddChidren(frameDetailBack); |
| | | |
| | | //线 |
| | | var btnLine = new NormalViewControl(bodyFrameLayout.Width, ControlCommonResourse.BottomLineHeight, false); |
| | | btnLine.Y = frameTopBack.Bottom; |
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; |
| | | bodyFrameLayout.AddChidren(btnLine); |
| | | |
| | | var listHeight = new List<string>(); |
| | | listHeight.Add(Language.StringByID(R.MyInternationalizationString.uNotAction));//无动作 |
| | | //这里用的是1端点 |
| | | listHeight.Add(Language.StringByID(R.MyInternationalizationString.uTheHighestPoint));//最高处 |
| | | listHeight.Add(Language.StringByID(R.MyInternationalizationString.uTheLowestPoint));//最低处 |
| | | |
| | | var listDry = new List<string>(); |
| | | listDry.Add(Language.StringByID(R.MyInternationalizationString.uNotAction));//无动作 |
| | | //这里用的是3端点 |
| | | listDry.Add(Language.StringByID(R.MyInternationalizationString.uOpenAirdry));//打开风干 |
| | | listDry.Add(Language.StringByID(R.MyInternationalizationString.uCloseAirdry));//关闭风干 |
| | | //这里用的是4端点 |
| | | listDry.Add(Language.StringByID(R.MyInternationalizationString.uOpenDry));//打开烘干 |
| | | listDry.Add(Language.StringByID(R.MyInternationalizationString.uCloseDry));//关闭烘干 |
| | | |
| | | var pikView1 = new UIPickerView(); |
| | | pikView1.Y = Application.GetRealHeight(100); |
| | | pikView1.Width = bodyFrameLayout.Width / 2; |
| | | pikView1.Height = Application.GetRealHeight(280); |
| | | pikView1.TextSize = 14; |
| | | pikView1.setNPicker(listHeight, listDry, null); |
| | | frameDetailBack.AddChidren(pikView1); |
| | | var listDisinfect = new List<string>(); |
| | | listDisinfect.Add(Language.StringByID(R.MyInternationalizationString.uNotAction));//无动作 |
| | | //这里用的是5端点 |
| | | listDisinfect.Add(Language.StringByID(R.MyInternationalizationString.uOpenDisinfect));//打开消毒 |
| | | listDisinfect.Add(Language.StringByID(R.MyInternationalizationString.uCloseDisinfect));//关闭消毒 |
| | | |
| | | var listLight = new List<string>(); |
| | | //这里用的是2端点 |
| | | listLight.Add(Language.StringByID(R.MyInternationalizationString.uNotAction));//无动作 |
| | | listLight.Add(Language.StringByID(R.MyInternationalizationString.uOpenLighting));//打开照明 |
| | | listLight.Add(Language.StringByID(R.MyInternationalizationString.uCloseLighting));//关闭照明 |
| | | |
| | | var pikView2 = new UIPickerView(); |
| | | pikView2.Y = Application.GetRealHeight(100); |
| | | pikView2.X = pikView1.Right; |
| | | pikView2.TextSize = 14; |
| | | pikView2.Height = Application.GetRealHeight(280); |
| | | pikView2.Width = bodyFrameLayout.Width / 2; |
| | | pikView2.setNPicker(listDisinfect, listLight, null); |
| | | frameDetailBack.AddChidren(pikView2); |
| | | |
| | | //设置初始选择 |
| | | var listDefultSelect = new List<int> { 0, 0, 0, 0 }; |
| | | this.SetDefultSelect(pikView1, pikView2, ref listDefultSelect); |
| | | |
| | | pikView1.OnSelectChangeEvent = (value1, value2, value3) => |
| | | { |
| | | //更改索引 |
| | | listDefultSelect[0] = value1; |
| | | listDefultSelect[1] = value2; |
| | | }; |
| | | |
| | | pikView2.OnSelectChangeEvent = (value1, value2, value3) => |
| | | { |
| | | //更改索引 |
| | | listDefultSelect[2] = value1; |
| | | listDefultSelect[3] = value2; |
| | | }; |
| | | |
| | | //头部信息 |
| | | var btnTitle = new NormalViewControl(frameTopBack.Width, Application.GetRealHeight(65), false); |
| | | btnTitle.Y = Application.GetRealHeight(34); |
| | | btnTitle.Text = Common.LocalDevice.Current.GetDeviceEpointName(device); |
| | | btnTitle.TextColor = UserCenterColor.Current.TextColor4; |
| | | btnTitle.TextSize = 16; |
| | | btnTitle.TextAlignment = TextAlignment.Center; |
| | | frameTopBack.AddChidren(btnTitle); |
| | | |
| | | //取消 |
| | | var btnCancel = new NormalViewControl(Application.GetRealWidth(200), frameTopBack.Height, false); |
| | | btnCancel.X = Application.GetRealWidth(81); |
| | | btnCancel.TextColor = UserCenterColor.Current.TextGrayColor1; |
| | | btnCancel.TextID = R.MyInternationalizationString.uCancel; |
| | | frameTopBack.AddChidren(btnCancel); |
| | | btnCancel.ButtonClickEvent += (sender, e) => |
| | | { |
| | | this.CloseForm(); |
| | | }; |
| | | |
| | | //完成 |
| | | var btnFinish = new NormalViewControl(Application.GetRealWidth(200), frameTopBack.Height, false); |
| | | btnFinish.X = frameTopBack.Width - btnCancel.X - Application.GetRealWidth(200); |
| | | btnFinish.TextAlignment = TextAlignment.CenterRight; |
| | | btnFinish.TextColor = 0xfffb744a; |
| | | btnFinish.TextID = R.MyInternationalizationString.uFinish; |
| | | frameTopBack.AddChidren(btnFinish); |
| | | btnFinish.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //创建动作列表信息 |
| | | var listData = this.CreatTaskListInfo(listDefultSelect); |
| | | |
| | | //获取状态的显示文本 |
| | | string statuText = HdlSafeguardLogic.Current.GetAdjustTargetStatuText(listData); |
| | | this.FinishSelectEvent?.Invoke(statuText, listData); |
| | | |
| | | this.CloseForm(); |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 界面关闭___________________________ |
| | | |
| | | /// <summary> |
| | | /// 界面关闭 |
| | | /// </summary> |
| | | public override void CloseFormBefore() |
| | | { |
| | | this.FinishSelectEvent = null; |
| | | base.CloseFormBefore(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 创建动作列表信息 |
| | | /// </summary> |
| | | /// <param name="i_listSelect"></param> |
| | | /// <returns></returns> |
| | | private List<Safeguard.TaskListInfo> CreatTaskListInfo(List<int> i_listSelect) |
| | | { |
| | | var listData = new List<Safeguard.TaskListInfo>(); |
| | | //最高最低处 |
| | | if (i_listSelect[0] != 0) |
| | | { |
| | | var data = new Safeguard.TaskListInfo(); |
| | | data.Epoint = 1; |
| | | data.TaskType = 6; |
| | | data.Data1 = i_listSelect[0] == 1 ? 1 : 0; |
| | | listData.Add(data); |
| | | } |
| | | //风干 烘干 |
| | | if (i_listSelect[1] != 0) |
| | | { |
| | | var data = new Safeguard.TaskListInfo(); |
| | | data.TaskType = 1; |
| | | if (i_listSelect[1] == 1) |
| | | { |
| | | //风干开 |
| | | data.Epoint = 3; |
| | | data.Data1 = 1; |
| | | } |
| | | else if (i_listSelect[1] == 2) |
| | | { |
| | | //风干关 |
| | | data.Epoint = 3; |
| | | data.Data1 = 0; |
| | | } |
| | | else if (i_listSelect[1] == 3) |
| | | { |
| | | //烘干开 |
| | | data.Epoint = 4; |
| | | data.Data1 = 1; |
| | | } |
| | | else if (i_listSelect[1] == 4) |
| | | { |
| | | //烘干关 |
| | | data.Epoint = 4; |
| | | data.Data1 = 0; |
| | | } |
| | | listData.Add(data); |
| | | } |
| | | //消毒 |
| | | if (i_listSelect[2] != 0) |
| | | { |
| | | var data = new Safeguard.TaskListInfo(); |
| | | data.Epoint = 5; |
| | | data.TaskType = 1; |
| | | data.Data1 = i_listSelect[2] == 1 ? 1 : 0; |
| | | listData.Add(data); |
| | | } |
| | | //照明 |
| | | if (i_listSelect[3] != 0) |
| | | { |
| | | var data = new Safeguard.TaskListInfo(); |
| | | data.Epoint = 2; |
| | | data.TaskType = 1; |
| | | data.Data1 = i_listSelect[3] == 1 ? 1 : 0; |
| | | listData.Add(data); |
| | | } |
| | | return listData; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置初始选择 |
| | | /// </summary> |
| | | /// <param name="pikView1"></param> |
| | | /// <param name="pikView2"></param> |
| | | private void SetDefultSelect(UIPickerView pikView1, UIPickerView pikView2, ref List<int> listDefult) |
| | | { |
| | | foreach (var data in this.listTaskinfo) |
| | | { |
| | | //最高最低处 |
| | | if (data.Epoint == 1) |
| | | { |
| | | listDefult[0] = data.Data1 == 0 ? 1 : 2; |
| | | } |
| | | //风干 |
| | | else if (data.Epoint == 3) |
| | | { |
| | | listDefult[1] = data.Data1 == 1 ? 1 : 2; |
| | | } |
| | | //烘干 |
| | | else if (data.Epoint == 4) |
| | | { |
| | | listDefult[1] = data.Data1 == 1 ? 3 : 4; |
| | | } |
| | | //消毒 |
| | | else if (data.Epoint == 5) |
| | | { |
| | | listDefult[2] = data.Data1 == 1 ? 1 : 2; |
| | | } |
| | | //照明 |
| | | else if (data.Epoint == 2) |
| | | { |
| | | listDefult[3] = data.Data1 == 1 ? 1 : 2; |
| | | } |
| | | } |
| | | //设置默认选择 |
| | | pikView1.setCurrentItems(listDefult[0], listDefult[1], -1); |
| | | pikView2.setCurrentItems(listDefult[2], listDefult[3], -1); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |