using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.UserCenter.Safety { /// /// 开关类的安防报警设置界面 /// public class SwitchAlarmSettionForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 画面关闭事件 /// public Action> ActionFormClose = null; /// /// 动作信息 0关闭/ 1打开 /// private Dictionary dicTaskinfo = new Dictionary(); #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// /// public void ShowForm(CommonDevice device, List i_listTaskInfo) { if (i_listTaskInfo != null) { foreach (var data in i_listTaskInfo) { //以防万一,剔除不合法数据 if (data.TaskType == 1) { dicTaskinfo[data.Data1] = data; } } } //设置头部信息 base.SetTitleText(Common.LocalDevice.Current.GetDeviceEpointName(device)); //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); var frameTemp = new FrameLayout(); frameTemp.Height = Application.GetRealHeight(6); frameTemp.BackgroundColor = UserCenterColor.Current.White; bodyFrameLayout.AddChidren(frameTemp); var listView = new VerticalListControl(29); listView.Y = frameTemp.Bottom; listView.BackgroundColor = UserCenterColor.Current.White; listView.Height = Application.GetRealHeight(341); bodyFrameLayout.AddChidren(listView); //开 var btnOpenRow = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(btnOpenRow); //图标 var btnOpenIcon = btnOpenRow.AddLeftIcon(81); btnOpenIcon.UnSelectedImagePath = "Item/OpenIcon.png"; //文字 var btnOpenView = btnOpenRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleOpen), 400); btnOpenView.TextSize = 15; //状态 var btnOpenStatu = btnOpenRow.AddMostRightEmptyIcon(58, 58); if (dicTaskinfo.ContainsKey(1) == false) { btnOpenStatu.Visible = false; } btnOpenStatu.UnSelectedImagePath = "Item/ItemSelected.png"; //底线 btnOpenRow.AddBottomLine(); //关 var btnCloseRow = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(btnCloseRow); //图标 var btnCloseIcon = btnCloseRow.AddLeftIcon(81); btnCloseIcon.UnSelectedImagePath = "Item/CloseIcon.png"; //文字 var btnCloseView = btnCloseRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleClose), 400); btnCloseView.TextSize = 15; //状态 var btnCloseStatu = btnCloseRow.AddMostRightEmptyIcon(58, 58); if (dicTaskinfo.ContainsKey(0) == false) { btnCloseStatu.Visible = false; } btnCloseStatu.UnSelectedImagePath = "Item/ItemSelected.png"; //开 btnOpenRow.ButtonClickEvent += (sender, e) => { if (btnOpenStatu.Visible == true) { //取消 dicTaskinfo.Remove(1); btnOpenStatu.Visible = false; } else { //添加 btnOpenStatu.Visible = true; btnCloseStatu.Visible = false; //移除关闭 dicTaskinfo.Remove(0); dicTaskinfo[1] = new Safeguard.TaskListInfo(); dicTaskinfo[1].TaskType = 1; dicTaskinfo[1].Data1 = 1; } }; //关 btnCloseRow.ButtonClickEvent += (sender, e) => { if (btnCloseStatu.Visible == true) { //取消 dicTaskinfo.Remove(0); btnCloseStatu.Visible = false; } else { //添加 btnOpenStatu.Visible = false; btnCloseStatu.Visible = true; //移除打开 dicTaskinfo.Remove(1); dicTaskinfo[0] = new Safeguard.TaskListInfo(); dicTaskinfo[0].TaskType = 1; dicTaskinfo[0].Data1 = 0; } }; //完成 var btnFinish = new BottomClickButton(); btnFinish.TextID = R.MyInternationalizationString.uFinish; bodyFrameLayout.AddChidren(btnFinish); btnFinish.ButtonClickEvent += (sender, e) => { if (this.ActionFormClose != null) { var listData = new List(); foreach (var data in dicTaskinfo.Values) { listData.Add(data); } dicTaskinfo = null; //获取状态的显示文本 string statuText = HdlSafeguardLogic.Current.GetLightAlarmStatuText(listData); this.ActionFormClose(statuText, listData); } this.CloseForm(); }; } #endregion #region ■ 界面关闭___________________________ /// /// 界面关闭 /// public override void CloseForm() { ActionFormClose = null; base.CloseForm(); } #endregion } }