using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.UserCenter.Safety { /// /// 灯光类的安防报警设置界面 /// public class AlarmTargetStatuSelectLightForm : DialogCommonForm { #region ■ 变量声明___________________________ /// /// 结束选择的事件(key:全部状态的翻译文本) /// public Action> FinishSelectEvent = null; /// /// 动作信息 1 开关/ 3亮度调节 /// private Dictionary dicTaskinfo = new Dictionary(); /// /// 进度条最大值 /// private int MaxValue = 254; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// /// public void ShowForm(CommonDevice device, List i_listTaskInfo) { if (i_listTaskInfo != null) { foreach (var data in i_listTaskInfo) { //以防万一,剔除不合法数据 if (data.TaskType == 1 || data.TaskType == 3) { dicTaskinfo[data.TaskType] = data; } } } //初始化中部信息 this.InitMiddleFrame(device); } /// /// 初始化中部信息 /// private void InitMiddleFrame(CommonDevice device) { //弧度的圆的一半的高度(固定) int halfRoundHeigth = Application.GetRealHeight(116) / 2; //搞一个透明的框 var frameTransparent = new FrameLayout(); frameTransparent.Y = Application.GetRealHeight(1169); frameTransparent.Height = Application.GetRealHeight(900);//高度就是要它超过,随便搞的 frameTransparent.BackgroundColor = UserCenterColor.Current.Transparent; bodyFrameLayout.AddChidren(frameTransparent); //瞎搞的一个白框,用来挡住头部半弧度 var frameBack = new FrameLayout(); frameBack.Y = halfRoundHeigth; frameBack.BackgroundColor = UserCenterColor.Current.White; frameBack.Height = Application.GetRealHeight(300); frameTransparent.AddChidren(frameBack); //弧度的圆 var rowRound = new FrameLayout(); rowRound.Width = bodyFrameLayout.Width; rowRound.Height = halfRoundHeigth * 2; rowRound.BackgroundColor = UserCenterColor.Current.White; rowRound.Radius = (uint)halfRoundHeigth; frameTransparent.AddChidren(rowRound); //头部信息 var btnTitle = new NormalViewControl(frameTransparent.Width, Application.GetRealHeight(70), false); btnTitle.Y = Application.GetRealHeight(28); btnTitle.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device); btnTitle.TextColor = UserCenterColor.Current.TextColor4; btnTitle.TextSize = 16; btnTitle.TextAlignment = TextAlignment.Center; rowRound.AddChidren(btnTitle); //取消 var btnCancel = new NormalViewControl(200, 60, true); btnCancel.X = Application.GetRealWidth(81); btnCancel.Y = Application.GetRealHeight(38); btnCancel.TextColor = UserCenterColor.Current.TextGrayColor1; btnCancel.TextID = R.MyInternationalizationString.uCancel; rowRound.AddChidren(btnCancel); btnCancel.ButtonClickEvent += (sender, e) => { this.CloseForm(); }; //完成 var btnFinish = new NormalViewControl(200, 60, true); btnFinish.X = Application.GetRealWidth(800); btnFinish.Y = Application.GetRealHeight(38); btnFinish.TextAlignment = TextAlignment.CenterRight; btnFinish.TextColor = 0xfffb744a; btnFinish.TextID = R.MyInternationalizationString.uFinish; rowRound.AddChidren(btnFinish); //线 var btnLine1 = new NormalViewControl(frameTransparent.Width, HdlControlResourse.BottomLineHeight, false); btnLine1.Y = Application.GetRealHeight(138); btnLine1.BackgroundColor = UserCenterColor.Current.ButtomLine; frameTransparent.AddChidren(btnLine1); //明细列表的桌布,白色背景 var detailBackFrame = new FrameLayout(); detailBackFrame.Y = btnLine1.Bottom; detailBackFrame.Height = Application.GetRealHeight(700);//随便定的 detailBackFrame.BackgroundColor = UserCenterColor.Current.White; frameTransparent.AddChidren(detailBackFrame); //百分比 var btnPersent = new NormalViewControl(150, 50, true); btnPersent.Y = Application.GetRealHeight(196); btnPersent.Gravity = Gravity.CenterHorizontal; btnPersent.TextAlignment = TextAlignment.Center; btnPersent.TextColor = UserCenterColor.Current.TextGrayColor2; btnPersent.TextSize = 12; detailBackFrame.AddChidren(btnPersent); if (dicTaskinfo.ContainsKey(3) == true) { btnPersent.Text = ((int)(dicTaskinfo[3].Data1 * 1.0 / MaxValue * 100)) + "%"; } //进度条 var seekBar = new SeekBarControl(919); seekBar.Y = Application.GetRealHeight(268); seekBar.ProgressBarColor = 0xfffdb500; seekBar.MaxValue = this.MaxValue; seekBar.Enable = false; if (dicTaskinfo.ContainsKey(3) == true) { //3:亮度调节 seekBar.Progress = dicTaskinfo[3].Data1; } detailBackFrame.AddChidren(seekBar); seekBar.ProgressChangedEvent += (div, value) => { btnPersent.Text = ((int)(value * 1.0 / MaxValue * 100)) + "%"; }; //线 var btnLine2 = new NormalViewControl(Application.GetRealWidth(919), HdlControlResourse.BottomLineHeight, false); btnLine2.Y = Application.GetRealHeight(417); btnLine2.Gravity = Gravity.CenterHorizontal; btnLine2.BackgroundColor = UserCenterColor.Current.ButtomLine; detailBackFrame.AddChidren(btnLine2); //开 var rowOpen = new FrameRowControl(); rowOpen.Y = Application.GetRealHeight(69); rowOpen.LeftOffset = Application.GetRealWidth(81) - HdlControlResourse.XXLeft; rowOpen.RightOffset = HdlControlResourse.XXLeft - Application.GetRealWidth(81); detailBackFrame.AddChidren(rowOpen); var btnOpen = rowOpen.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleOpen), 400); btnOpen.TextColor = UserCenterColor.Current.TextGrayColor3; var btnOpenSelect = rowOpen.AddMostRightEmptyIcon(58, 58); btnOpenSelect.UnSelectedImagePath = "Item/ItemSelected.png"; btnOpenSelect.Visible = false; //关 var rowClose = new FrameRowControl(); rowClose.Y = btnLine2.Bottom + Application.GetRealHeight(12); rowClose.LeftOffset = Application.GetRealWidth(81) - HdlControlResourse.XXLeft; rowClose.RightOffset = HdlControlResourse.XXLeft - Application.GetRealWidth(81); detailBackFrame.AddChidren(rowClose); var btnClose = rowClose.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleClose), 400); btnClose.TextColor = UserCenterColor.Current.TextGrayColor3; var btnCloseSelect = rowClose.AddMostRightEmptyIcon(58, 58); btnCloseSelect.UnSelectedImagePath = "Item/ItemSelected.png"; btnCloseSelect.Visible = false; //点击开 rowOpen.ButtonClickEvent += (sender, e) => { if (btnOpenSelect.Visible == true) { //取消,开 不可用 btnOpenSelect.Visible = false; btnOpen.TextColor = UserCenterColor.Current.TextGrayColor3; seekBar.Enable = false; dicTaskinfo.Remove(1); } else { //选择图标切换 btnOpenSelect.Visible = true; btnCloseSelect.Visible = false; //开 可用 btnOpen.TextColor = UserCenterColor.Current.TextColor1; seekBar.Enable = true; if (seekBar.Progress == 0) { seekBar.Progress = MaxValue; btnPersent.Text = "100%"; } //关 不可用 btnClose.TextColor = UserCenterColor.Current.TextGrayColor3; dicTaskinfo[1] = new Safeguard.TaskListInfo(); dicTaskinfo[1].TaskType = 1; dicTaskinfo[1].Data1 = 1; } }; //点击关 rowClose.ButtonClickEvent += (sender, e) => { if (btnCloseSelect.Visible == true) { //取消,关 不可用 btnCloseSelect.Visible = false; btnClose.TextColor = UserCenterColor.Current.TextGrayColor3; dicTaskinfo.Remove(1); } else { //选择图标切换 btnCloseSelect.Visible = true; btnOpenSelect.Visible = false; //关 可用 btnClose.TextColor = UserCenterColor.Current.TextColor1; //开 不可用 btnOpen.TextColor = UserCenterColor.Current.TextGrayColor3; seekBar.Enable = false; dicTaskinfo[1] = new Safeguard.TaskListInfo(); dicTaskinfo[1].TaskType = 1; dicTaskinfo[1].Data1 = 0; } }; //设置开的默认值 if (dicTaskinfo.ContainsKey(1) == true && dicTaskinfo[1].Data1 == 1) { rowOpen.ButtonClickEvent?.Invoke(null, null); } //设置关的默认值 if (dicTaskinfo.ContainsKey(1) == true && dicTaskinfo[1].Data1 == 0) { rowClose.ButtonClickEvent?.Invoke(null, null); } //完成事件 btnFinish.ButtonClickEvent += (sender, e) => { if (btnOpenSelect.Visible == false || seekBar.Progress == 0) { //移除百分比 dicTaskinfo.Remove(3); } else { //百分比调节 dicTaskinfo[3] = new Safeguard.TaskListInfo(); dicTaskinfo[3].TaskType = 3; dicTaskinfo[3].Data1 = seekBar.Progress; } var listData = new List(); foreach (var data in dicTaskinfo.Values) { listData.Add(data); } dicTaskinfo = null; //获取状态的显示文本 string statuText = HdlSafeguardLogic.Current.GetAdjustTargetStatuText(listData); this.FinishSelectEvent?.Invoke(statuText, listData); this.CloseForm(); }; } #endregion #region ■ 界面关闭___________________________ /// /// 界面关闭 /// public override void CloseFormBefore() { this.FinishSelectEvent = null; base.CloseFormBefore(); } #endregion } }