From b5f1a194d354ba9b2587c59ae17cf38d0f7f9bac Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 13 十二月 2021 16:38:23 +0800 Subject: [PATCH] 二维码闪退问题 --- HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs | 515 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 411 insertions(+), 104 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs index 91f18dc..c3332b1 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs @@ -26,6 +26,16 @@ SecurityAlarm securityAlarm; Action refreshAction; + /// <summary> + /// 瀹夐槻杈撳嚭-涓存椂 + /// </summary> + List<SecurityOutput> tempOutput = new List<SecurityOutput>(); + /// <summary> + /// 瀹夐槻杈撳叆-涓存椂 + /// </summary> + List<SecurityInput> tempInput = new List<SecurityInput>(); + + public AddAlarmDeploymentPage(SecurityAlarm alarm, Action action) { bodyView = this; @@ -33,10 +43,8 @@ refreshAction = action; } - public void LoadPage() + public void LoadPage(string title = "") { - new TopViewDiv(bodyView, Language.StringByID(StringId.Setting)).LoadTopView(); - bodyView.BackgroundColor = CSS_Color.BackgroundColor; contentView = new VerticalScrolViewLayout() @@ -46,95 +54,204 @@ }; bodyView.AddChidren(contentView); - #region 甯冮槻淇℃伅 - var deploymentTitleRow = new FrameLayout() + if (string.IsNullOrEmpty(title)) { - Height = Application.GetRealHeight(44), + new TopViewDiv(bodyView, Language.StringByID(StringId.AddSecurity)).LoadTopView(); + #region 甯冮槻淇℃伅 + var deploymentTitleRow = new FrameLayout() + { + Height = Application.GetRealHeight(44), + BackgroundColor = CSS_Color.MainBackgroundColor, + }; + contentView.AddChidren(deploymentTitleRow); + + var btnDeploymentTitle = new Button() + { + X = Application.GetRealWidth(16), + TextColor = CSS_Color.MainColor, + TextAlignment = TextAlignment.CenterLeft, + TextSize = CSS_FontSize.SubheadingFontSize, + TextID = StringId.DeploymentInformation, + IsBold = true, + }; + deploymentTitleRow.AddChidren(btnDeploymentTitle); + + deploymentTitleRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); + + #region 甯冮槻鍚嶇О + var deploymentNameRow = new FrameLayout() + { + Height = Application.GetRealHeight(50), + BackgroundColor = CSS_Color.MainBackgroundColor, + }; + contentView.AddChidren(deploymentNameRow); + + var btnDeploymentNameTitle = new Button() + { + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(72), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + TextID = StringId.Name, + }; + deploymentNameRow.AddChidren(btnDeploymentNameTitle); + btnDeploymentNameTitle.Text += ":"; + + var btnDeploymentName = new Button() + { + X = Application.GetRealWidth(88), + Width = Application.GetRealWidth(230), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.TextualColor, + TextSize = CSS_FontSize.TextFontSize, + Text = securityAlarm.name + }; + deploymentNameRow.AddChidren(btnDeploymentName); + deploymentNameRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); + + LoadEvent_EditSecurityAlarmName(btnDeploymentName); + #endregion + + #region 瑙﹀彂寤舵椂 + var delayedRow = new FrameLayout() + { + Height = Application.GetRealHeight(50), + BackgroundColor = CSS_Color.MainBackgroundColor, + }; + contentView.AddChidren(delayedRow); + + var btnDelayedTitle = new Button() + { + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(72), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + TextID = StringId.TriggerDelay, + }; + delayedRow.AddChidren(btnDelayedTitle); + btnDelayedTitle.Text += ":"; + btnDelayedTitle.Width = btnDelayedTitle.GetTextWidth()+Application.GetRealWidth(10); + + var btnDelayedText = new Button() + { + X = btnDelayedTitle.Right, + Width = Application.GetRealWidth(330), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.TextualColor, + TextSize = CSS_FontSize.TextFontSize, + Text = securityAlarm.delay + "s" + }; + delayedRow.AddChidren(btnDelayedText); + btnDelayedText.MouseUpEventHandler = (sender, e) => + { + Action<string> action = (obj) => + { + securityAlarm.delay = obj; + btnDelayedText.Text = securityAlarm.delay + "s"; + }; + new PublicAssmebly().SetSceneDelayDialog(action, securityAlarm.delay); + }; + + var btnDelayedRight = new Button() + { + X = Application.GetRealWidth(343), + Gravity = Gravity.CenterVertical, + Width = Application.GetMinRealAverage(16), + Height = Application.GetMinRealAverage(16), + UnSelectedImagePath = "Public/RightIcon.png", + }; + delayedRow.AddChidren(btnDelayedRight); + + + delayedRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); + #endregion + + #endregion + + contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8), BackgroundColor = CSS_Color.BackgroundColor }); + } + else + { + new TopViewDiv(bodyView, title).LoadTopView(); + } + + //甯冮槻鍔熻兘 + iniDefenseView(); + + //鍛婅鐩爣 + iniAlarmView(); + + #region 鎵ц鎺ㄩ�� + ///涓婁笅闂撮殧12鍍忕礌 + contentView.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) }); + ///鎵ц鎺ㄩ�乮ew + FrameLayout pushView = new FrameLayout() + { + Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; - contentView.AddChidren(deploymentTitleRow); + contentView.AddChidren(pushView); - var btnDeploymentTitle = new Button() + + var btnPushTitle = new Button() { X = Application.GetRealWidth(16), - TextColor = CSS_Color.MainColor, + TextColor = CSS_Color.FirstLevelTitleColor, TextAlignment = TextAlignment.CenterLeft, - TextSize = CSS_FontSize.SubheadingFontSize, - TextID = StringId.DeploymentInformation, + TextSize = CSS_FontSize.TextFontSize, + TextID = StringId.push, IsBold = true, }; - deploymentTitleRow.AddChidren(btnDeploymentTitle); + pushView.AddChidren(btnPushTitle); - deploymentTitleRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); - - #region 甯冮槻鍚嶇О - var deploymentNameRow = new FrameLayout() + var btnSwitchPush = new Button() { - Height = Application.GetRealHeight(50), - BackgroundColor = CSS_Color.MainBackgroundColor, + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(36), + X = Application.GetRealWidth(323), + UnSelectedImagePath = "LogicIcon/off.png", + SelectedImagePath = "LogicIcon/on.png", + Gravity = Gravity.CenterVertical, + IsSelected = securityAlarm.noticeConfig.enable }; - contentView.AddChidren(deploymentNameRow); + pushView.AddChidren(btnSwitchPush); - var btnDeploymentNameTitle = new Button() + + ///鏄惁瑕佹帹閫佺偣鍑讳簨浠� + btnSwitchPush.MouseUpEventHandler += (sender, e) => { - X = Application.GetRealWidth(16), - Width = Application.GetRealWidth(72), - TextAlignment = TextAlignment.CenterLeft, - TextColor = CSS_Color.FirstLevelTitleColor, - TextSize = CSS_FontSize.TextFontSize, - TextID = StringId.Name, + //璐﹀彿鍒楄〃涓虹┖榛樿鎺ㄩ�佸綋鍓嶈处鍙� + if (securityAlarm.pushConfigs.Count == 0) + { + //鍒濆鍖栧璞� + var pushConfigs = new SecurityPushConfig(); + //榛樿娣诲姞鎺ㄩ�佸綋鍓嶈处鍙� + pushConfigs.pushTarget.Add(UserInfo.Current.ID); + securityAlarm.pushConfigs.Add(pushConfigs); + } + btnSwitchPush.IsSelected = !btnSwitchPush.IsSelected; + if (btnSwitchPush.IsSelected) + { + securityAlarm.noticeConfig.enable = true; + } + else + { + securityAlarm.noticeConfig.enable = false; + } }; - deploymentNameRow.AddChidren(btnDeploymentNameTitle); - btnDeploymentNameTitle.Text += ":"; - - var btnDeploymentName = new Button() - { - X = Application.GetRealWidth(88), - Width = Application.GetRealWidth(230), - TextAlignment = TextAlignment.CenterLeft, - TextColor = CSS_Color.TextualColor, - TextSize = CSS_FontSize.TextFontSize, - Text = securityAlarm.name - }; - deploymentNameRow.AddChidren(btnDeploymentName); - deploymentNameRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); - - LoadEvent_EditSecurityAlarmName(btnDeploymentName); + pushView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); #endregion - - /* - #region 瑙﹀彂寤舵椂 - var delayedRow = new FrameLayout() + #region 鍙戦�侀�氱煡 + ///鍙戦�侀�氱煡View + var pushMsgView = new FrameLayout() { Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; - contentView.AddChidren(delayedRow); - - var btnDelayedTitle = new Button() - { - X = Application.GetRealWidth(16), - Width = Application.GetRealWidth(72), - TextAlignment = TextAlignment.CenterLeft, - TextColor = CSS_Color.FirstLevelTitleColor, - TextSize = CSS_FontSize.TextFontSize, - TextID = StringId.TriggerDelay, - }; - delayedRow.AddChidren(btnDelayedTitle); - btnDelayedTitle.Text += ":"; - - var btnDelayedText = new Button() - { - X = Application.GetRealWidth(88), - Width = Application.GetRealWidth(230), - TextAlignment = TextAlignment.CenterLeft, - TextColor = CSS_Color.TextualColor, - TextSize = CSS_FontSize.TextFontSize, - Text = securityAlarm.name - }; - delayedRow.AddChidren(btnDelayedText); - - var btnDelayedRight = new Button() + contentView.AddChidren(pushMsgView); + var btnPushMsgRight = new Button() { X = Application.GetRealWidth(343), Gravity = Gravity.CenterVertical, @@ -142,22 +259,37 @@ Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/RightIcon.png", }; - delayedRow.AddChidren(btnDelayedRight); + pushMsgView.AddChidren(btnPushMsgRight); - //delayedRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); - #endregion - */ + + + var btnPushMsgTitle = new Button() + { + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(372), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + TextID = StringId.fasongtongzhi, + IsBold = true, + }; + pushMsgView.AddChidren(btnPushMsgTitle); + + btnPushMsgTitle.MouseUpEventHandler = (sender, e) => { + var inputPushText = new PushConfigPage(); + MainPage.BasePageView.AddChidren(inputPushText); + inputPushText.Show(securityAlarm); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + + ///涓婁笅闂撮殧62鍍忕礌 + contentView.AddChidren(new FrameLayout { Height = Application.GetRealHeight(40) }); + #endregion - contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8), BackgroundColor = CSS_Color.BackgroundColor }); - //甯冮槻鍔熻兘 - iniDefenseView(); -#if DEBUG - //鍛婅鐩爣 - iniAlarmView(); -#endif + #region 搴曢儴鍖哄煙 var bottomView = new FrameLayout() @@ -209,17 +341,22 @@ tip.Show(MainPage.BaseView); return; } - //if (securityAlarm.output.Count == 0) - //{ - // var tip = new Tip() - // { - // Text = "璇烽�夋嫨鍛婅鐩爣", - // CloseTime = 3, - // Direction = AMPopTipDirection.None - // }; - // tip.Show(MainPage.BaseView); - // return; - //} + if (securityAlarm.output.Count == 0) + { + var tipText = "璇烽�夋嫨鍛婅鐩爣"; + if(Language.CurrentLanguage !="Chinese") + { + tipText = "Please select the alarm target"; + } + var tip = new Tip() + { + Text = tipText, + CloseTime = 3, + Direction = AMPopTipDirection.None + }; + tip.Show(MainPage.BaseView); + return; + } var waitPage = new Loading(); waitPage.Start(); @@ -227,6 +364,7 @@ { try { + var code = securityAlarm.SaveInfo(); if (code == StateCode.SUCCESS) { @@ -276,6 +414,8 @@ BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(deploymentFunctionRow); + deploymentFunctionRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); + var btnFunctionTitle = new Button() { @@ -333,18 +473,17 @@ inputTargetView.RemoveAll(); if (securityAlarm.input.Count > 0) { + int count = 0; foreach (var target in securityAlarm.input) { if (target.GetFunction() != null) { inputTargetView.AddChidren(new InputRow(target.GetFunction().name, target.GetFunction().GetRoomListName(), target.StateText())); + inputTargetView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); } + count++; } - inputTargetView.Height = Application.GetRealHeight(65 * securityAlarm.input.Count); - //if (outputTargetView != null) - //{ - // contentView.AddChidren(outputTargetView); - //} + inputTargetView.Height = Application.GetRealHeight(65 * count); } else { @@ -381,6 +520,7 @@ BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(outputRow); + outputRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); var btnOutputRowTitle = new Button() { @@ -420,9 +560,11 @@ outputTargetView = new VerticalScrolViewLayout() { ScrollEnabled = false, + Height =0, }; contentView.AddChidren(outputTargetView); + outputTargetView.Height = Application.GetRealHeight(65 * securityAlarm.output.Count); iniAlarmListView(); #endregion @@ -440,7 +582,21 @@ { foreach (var outTarget in securityAlarm.output) { - outputTargetView.AddChidren(new OutputRow(outTarget.GetFunction().name, outTarget.GetFunction().GetRoomListName(), "鎵撳紑")); + if (outTarget.NoLocalData()) + { + var outputRow = new OutputRow(outTarget.name, outTarget.RoomName, outTarget); + EventHandler<MouseEventArgs> eventHandler = (sender, e) => { + var delTemp = securityAlarm.output.Find((obj) => obj.sid == outTarget.sid); + if(delTemp!=null) + { + securityAlarm.output.Remove(delTemp); + } + outputRow.RemoveFromParent(); + outputTargetView.Height = Application.GetRealHeight(65 * securityAlarm.output.Count); + }; + outputTargetView.AddChidren(outputRow); + } + outputTargetView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); } outputTargetView.Height = Application.GetRealHeight(65 * securityAlarm.output.Count); } @@ -456,6 +612,7 @@ IsMoreLines = true, BackgroundColor = CSS_Color.MainBackgroundColor, }); + outputTargetView.Height = Application.GetRealHeight(68); } } @@ -480,7 +637,6 @@ }.Show(bodyView); return; } - btnDeploymentName.Text = securityAlarm.name = str; @@ -568,8 +724,14 @@ Button btnRightIcon; - public OutputRow(string title, string subtitle, string state) + Button btnDel; + + SecurityOutput output; + + public OutputRow(string title, string subtitle, SecurityOutput inOutput) { + output = inOutput; + this.LineColor = 0x00000000; this.Height = Application.GetRealHeight(65); this.BackgroundColor = CSS_Color.MainBackgroundColor; @@ -605,7 +767,7 @@ TextAlignment = TextAlignment.CenterRight, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.PromptingColor1, - Text = state + Text = output.StateText() }; this.AddChidren(btnState); @@ -617,7 +779,43 @@ Height = Application.GetRealWidth(16), UnSelectedImagePath = "FunctionIcon/ArmCenter/RightIcon.png", }; - this.AddChidren(btnRightIcon); + if (!string.IsNullOrEmpty(output.spk)) + { + this.AddChidren(btnRightIcon); + } + + btnState.MouseUpEventHandler = (sender, e) => + { + if (!string.IsNullOrEmpty(output.spk)) + { + ShowStateDialog(); + } + }; + btnRightIcon.MouseUpEventHandler = (sender, e) => + { + if (!string.IsNullOrEmpty(output.spk)) + { + ShowStateDialog(); + } + }; + //btnSubTitle.MouseUpEventHandler = (sender, e) => + //{ + // ShowStateDialog(); + //}; + + btnDel = new Button() + { + BackgroundColor = CSS_Color.WarningColor, + TextColor = CSS_Color.MainBackgroundColor, + TextID = StringId.Del, + }; + this.AddRightView(btnDel); + + } + + public void SetDelClick(EventHandler<MouseEventArgs> eventHandler) + { + btnDel.MouseUpEventHandler = eventHandler; } public void SetClickEvent(EventHandler<MouseEventArgs> eventHandler) @@ -626,5 +824,114 @@ btnTitle.MouseUpEventHandler = eventHandler; btnSubTitle.MouseUpEventHandler = eventHandler; } + + + + + private void ShowStateDialog() + { + Dialog dialog = new Dialog(); + + FrameLayout contentView = new FrameLayout(); + dialog.AddChidren(contentView); + contentView.MouseUpEventHandler = (sender, e) => + { + dialog.Close(); + }; + + VerticalScrolViewLayout optinView = new VerticalScrolViewLayout() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealHeight(515), + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(88), + Radius = (uint)Application.GetRealHeight(13), + BackgroundColor = CSS_Color.MainBackgroundColor, + }; + contentView.AddChidren(optinView); + + Button btnOpen = new Button() + { + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + SelectedTextColor = CSS_Color.MainColor, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.SubheadingFontSize, + TextID = StringId.On, + }; + optinView.AddChidren(btnOpen); + optinView.AddChidren(new Button() + { + Height = 1, + BackgroundColor = CSS_Color.DividingLineColor + }); + + Button btnClose = new Button() + { + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + SelectedTextColor = CSS_Color.MainColor, + TextColor = CSS_Color.PromptingColor1, + TextID = StringId.OFF, + TextSize = CSS_FontSize.SubheadingFontSize, + }; + optinView.AddChidren(btnClose); + if (output.status.Count > 0) + { + btnOpen.IsSelected = output.status[0].value.ToLower() == "on"; + btnClose.IsSelected = !btnOpen.IsSelected; + } + + + Button btnCancel = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = optinView.Bottom + Application.GetRealHeight(8), + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(44), + Radius = (uint)Application.GetRealHeight(13), + BackgroundColor = CSS_Color.MainBackgroundColor, + TextID = StringId.Cancel, + TextColor = CSS_Color.WarningColor, + IsBold = true, + }; + contentView.AddChidren(btnCancel); + + dialog.Show(); + + btnOpen.MouseUpEventHandler = (sender, e) => { + btnState.Text = btnOpen.Text; + output.status = new List<SecurityOutputStatus>() + { + new SecurityOutputStatus() + { + key = FunctionAttributeKey.OnOff, + value = "on", + } + }; + dialog.Close(); + }; + + btnClose.MouseUpEventHandler = (sender, e) => + { + btnState.Text = btnClose.Text; + output.status = new List<SecurityOutputStatus>() + { + new SecurityOutputStatus() + { + key = FunctionAttributeKey.OnOff, + value = "off", + } + }; + dialog.Close(); + }; + + btnCancel.MouseUpEventHandler = (sender, e) => + { + dialog.Close(); + }; + + } + } } -- Gitblit v1.8.0