From 24dce73df68f96c4e7ae4ef82658d5fc89f31e0b Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期一, 23 八月 2021 09:58:33 +0800 Subject: [PATCH] 1 --- HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs | 405 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 346 insertions(+), 59 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs index cefa915..6f1d164 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs @@ -1,4 +1,5 @@ 锘縰sing System; +using HDL_ON.DriverLayer; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; @@ -9,7 +10,31 @@ /// <summary> /// 涓荤獥浣� /// </summary> - FrameLayout bodyView; + public static ArmCenterPage bodyView; + /// <summary> + /// 鑷畾涔夊竷闃插尯鍩� + /// </summary> + HorizontalScrolViewLayout customDeploymentView; + /// <summary> + /// + /// </summary> + FrameLayout alarmIconBgView; + //瀹夐槻鐘舵�佽儗鏅浘 + Button btnArmTipIcon; + /// <summary> + /// 瀹夐槻璀︽姤鍥炬爣 + /// </summary> + Button btnInalarmIcon; + /// <summary> + /// 褰撳墠甯冮槻鍚嶇О + /// </summary> + Button btnDefenseName; + + /// <summary> + /// 鎾ら槻鍖哄煙 + /// </summary> + FrameLayout disarmView; + public ArmCenterPage() { bodyView = this; @@ -21,7 +46,7 @@ }; - new TopViewDiv(bodyView, Language.StringByID(StringId.Setting)).LoadTopView_ArmCenter(skipAction); + new TopViewDiv(bodyView, Language.StringByID(StringId.SecurityCenter)).LoadTopView_ArmCenter(skipAction); VerticalScrolViewLayout contentView = new VerticalScrolViewLayout() { @@ -37,25 +62,96 @@ Height =Application.GetRealWidth(32), }); - //瀹夐槻鐘舵�佽儗鏅浘 - Button btnArmTipIcon = new Button() + alarmIconBgView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(198), Height = Application.GetRealWidth(198), + }; + contentView.AddChidren(alarmIconBgView); + + btnArmTipIcon = new Button() + { + //Gravity = Gravity.CenterHorizontal, + //Width = Application.GetRealWidth(198), + //Height = Application.GetRealWidth(198), UnSelectedImagePath = "FunctionIcon/ArmCenter/NoDefenseBigIcon.png", SelectedImagePath = "FunctionIcon/ArmCenter/InDefenseBigIcon.png", }; - contentView.AddChidren(btnArmTipIcon); + alarmIconBgView.AddChidren(btnArmTipIcon); + + btnInalarmIcon = new Button() + { + Width = Application.GetRealWidth(198), + Height = Application.GetRealWidth(198), + }; + btnInalarmIcon.MouseUpEventHandler = (sender, e) => { + if(SecurityCenter.Ins.InDefenseMode!= null) + { + SecurityCenter.Ins.InDefenseMode.alarm = false; + Control.Ins.ControlSecurity(SecurityCenter.Ins.InDefenseMode, "enable"); + } + }; + InitAlarmStatus(SecurityCenter.Ins.InAlarm); + + + btnDefenseName = new Button() + { + Y = Application.GetRealWidth(117), + Height = Application.GetRealHeight(81), + TextAlignment = TextAlignment.Center, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + TextColor = CSS_Color.MainBackgroundColor, + }; + alarmIconBgView.AddChidren(btnDefenseName); contentView.AddChidren(new Button() { Height = Application.GetRealWidth(16), }); - #region 鑷畾涔夊竷闃� - //鑷畾涔夊竷闃叉爣棰� - Button btnCustomDeploymentTitle = new Button() + + #region 鎾ら槻鍖哄煙 + Button btnDisarm; + disarmView = new FrameLayout() + { + Height = 0, + }; + contentView.AddChidren(disarmView); + + btnDisarm = new Button() + { + Y = Application.GetRealHeight(10), + Width = Application.GetRealWidth(148), + Height = Application.GetRealHeight(40), + BackgroundColor = CSS_Color.MainColor, + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.MainBackgroundColor, + Text = "鎾ら槻", + Radius = (uint)Application.GetRealWidth(20), + Gravity = Gravity.CenterHorizontal, + }; + disarmView.AddChidren(btnDisarm); + btnDisarm.MouseUpEventHandler = (sender, e) => { + //foreach (var temp in FunctionList.List.securities) + //{ + // if (temp.status == "enable") + // { + // Control.Ins.ControlSecurity(temp, "disable"); + // break; + // } + //} + if(SecurityCenter.Ins.InDefenseMode!= null) + { + Control.Ins.ControlSecurity(SecurityCenter.Ins.InDefenseMode, "disable"); + } + }; + + #endregion + + #region 鑷畾涔夊竷闃� + //鑷畾涔夊竷闃叉爣棰� + Button btnCustomDeploymentTitle = new Button() { X = Application.GetRealWidth(24), Height = Application.GetRealWidth(54), @@ -67,7 +163,7 @@ }; contentView.AddChidren(btnCustomDeploymentTitle); - HorizontalScrolViewLayout customDeploymentView = new HorizontalScrolViewLayout() + customDeploymentView = new HorizontalScrolViewLayout() { X = Application.GetRealWidth(23), Height = Application.GetRealWidth(80), @@ -75,24 +171,7 @@ }; contentView.AddChidren(customDeploymentView); - //customDeploymentView.AddChidren(new Button() - //{ - // Width = Application.GetRealWidth(23), - //}); - var adv = new ArmDiyView(); - var view = adv.DiyArmView("FunctionIcon/ArmCenter/AtHomeDefenseIcon.png", "FunctionIcon/ArmCenter/AtHomeDefenseIconOn.png", - Language.StringByID(StringId.HouseDefense)); - customDeploymentView.AddChidren(view); - - if(FunctionList.List.securities.Count>3) - { - customDeploymentView.ScrollEnabled = true; - } - - foreach (var mode in FunctionList.List.securities) - { - } #endregion contentView.AddChidren(new Button() @@ -100,6 +179,8 @@ Height = Application.GetRealHeight(20), }); + #region 鍥哄畾甯冮槻鍖哄煙 + /* var fixedDeploymentView = new FrameLayout() { Height = Application.GetRealHeight(133), @@ -130,7 +211,6 @@ }; fixedDeploymentView.AddChidren(btnFixedDeploymentTip); - //鍥哄畾甯冮槻鍖哄煙 var fixedDeploymentTypeView = new HorizontalScrolViewLayout() { Y = btnFixedDeploymentTip.Bottom + Application.GetRealHeight(15), @@ -144,11 +224,11 @@ Width = Application.GetRealWidth(24), }); - + #endregion //鐏惧鎶ヨ - var disasterAlarmView = adv.FixedArmView("FunctionIcon/ArmCenter/DisasterAlarmIcon.png", Language.StringByID(StringId.DisasterDefense), Language.StringByID(StringId.Defense24Hour)); + var disasterAlarmView = new FixedArmView("FunctionIcon/ArmCenter/DisasterAlarmIcon.png", Language.StringByID(StringId.DisasterDefense), Language.StringByID(StringId.Defense24Hour)); fixedDeploymentTypeView.AddChidren(disasterAlarmView); fixedDeploymentTypeView.AddChidren(new Button() @@ -157,9 +237,204 @@ }); //闃茬洍鎶ヨ - var burglarAlarmView = adv.FixedArmView("FunctionIcon/ArmCenter/BurglarAlarmIcon.png", Language.StringByID(StringId.BurglarAlarm), Language.StringByID(StringId.AlarmMute)); + var burglarAlarmView = new FixedArmView("FunctionIcon/ArmCenter/BurglarAlarmIcon.png", Language.StringByID(StringId.BurglarAlarm), Language.StringByID(StringId.AlarmMute)); fixedDeploymentTypeView.AddChidren(burglarAlarmView); + */ + #endregion + + + + ///鍒锋柊鐣岄潰 + LoadEvent_RefreshSecurityStatus(); + + } + + public void InitAlarmStatus(bool inAlarm) + { + try + { + if (inAlarm) + { + alarmIconBgView.AddChidren(btnInalarmIcon); + } + else + { + btnInalarmIcon.RemoveFromParent(); + } + } + catch { } + } + + /// <summary> + /// 鍒濆鍖栬嚜瀹氫箟甯冮槻鍖哄煙 + /// </summary> + private void iniCustomDeploymentView() + { + customDeploymentView.RemoveAll(); + + foreach (var mode in FunctionList.List.securities) + { + var armDiyView = new ArmDiyView("FunctionIcon/ArmCenter/AtHomeDefenseIcon.png", "FunctionIcon/ArmCenter/AtHomeDefenseIconOn.png", + mode.name); + customDeploymentView.AddChidren(armDiyView); + EventHandler<MouseEventArgs> event2 = (sender, e) => + { + ShowArmDialog(mode); + }; + armDiyView.SetClickEvent(event2); + if (mode.status == "enable") + { + armDiyView.LightingView(true); + } + } + + if (FunctionList.List.securities.Count < 4) + { + var view = new ArmDiyView("FunctionIcon/ArmCenter/AddDefenseIcon.png", "FunctionIcon/ArmCenter/AddDefenseIcon.png", + Language.StringByID(StringId.Custom)); + customDeploymentView.AddChidren(view); + EventHandler<MouseEventArgs> event1 = (sender, e) => + { + Action refreshAction = () => + { + iniCustomDeploymentView(); + }; + + var addDefensePage = new AddAlarmDeploymentPage(new SecurityAlarm(), refreshAction); + MainPage.BasePageView.AddChidren(addDefensePage); + addDefensePage.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + view.SetClickEvent(event1); + } + + } + + private void ShowArmDialog(SecurityAlarm alarm) + { + 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, + TextColor = CSS_Color.MainColor, + TextSize = CSS_FontSize.SubheadingFontSize, + TextID = StringId.OpenArm + }; + optinView.AddChidren(btnOpen); + + optinView.AddChidren(new Button() { + Height = 1, + BackgroundColor = CSS_Color.DividingLineColor + }); + + Button btnCheckModify = new Button() + { + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.PromptingColor1, + TextID = StringId.CheckModify, + TextSize = CSS_FontSize.SubheadingFontSize, + }; + optinView.AddChidren(btnCheckModify); + + + 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(); + + if(alarm.status == "enable") + { + btnOpen.TextColor = CSS_Color.PromptingColor1; + btnOpen.Text = Language.StringByID(StringId.AlreadyOpened).Trim() ; + } + + btnOpen.MouseUpEventHandler = (sender, e) => { + if (alarm.status == "disable") + { + Control.Ins.ControlSecurity(alarm, "enable"); + }else + { + Control.Ins.ControlSecurity(alarm, "disable"); + } + dialog.Close(); + }; + + + btnCheckModify.MouseUpEventHandler = (sender, e) => { + dialog.Close(); + Action refreshAction = () => + { + iniCustomDeploymentView(); + }; + var armSetPage = new AddAlarmDeploymentPage(alarm,refreshAction); + MainPage.BasePageView.AddChidren(armSetPage); + armSetPage.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + + btnCancel.MouseUpEventHandler = (sender, e) => + { + dialog.Close(); + }; + + } + + public static void LoadEvent_RefreshSecurityStatus() + { + Application.RunOnMainThread(() => + { + if (bodyView != null) + { + bodyView.iniCustomDeploymentView(); + bodyView.disarmView.Height = 0; + bodyView.btnArmTipIcon.IsSelected = false; + bodyView.btnDefenseName.Text = ""; + foreach (var temp in FunctionList.List.securities) + { + if (temp.status == "enable") + { + bodyView.disarmView.Height = Application.GetRealHeight(68); + bodyView.btnArmTipIcon.IsSelected = true; + bodyView.btnDefenseName.Text = temp.name; + + bodyView.InitAlarmStatus(temp.alarm); + break; + } + } + } + }); } } @@ -167,24 +442,22 @@ /// <summary> /// 瀹夐槻鑷畾涔夋帶浠� /// </summary> - public class ArmDiyView + public class ArmDiyView : FrameLayout { - + Button btnIcon; + Button btnText; /// <summary> - /// + /// 鑷畾涔夊竷闃茬晫闈� /// </summary> /// <param name="UnSelectedIconPath">鍥剧墖璺緞</param> /// <param name="SelectedIconPath">鍥剧墖璺緞</param> /// <param name="Text">鏄剧ず鏂囨湰</param> - public FrameLayout DiyArmView(string UnSelectedIconPath, string SelectedIconPath, string Text) + public ArmDiyView(string UnSelectedIconPath, string SelectedIconPath, string Text) { - var view = new FrameLayout() - { - Width = Application.GetRealWidth(82), - Height = Application.GetRealWidth(80), - }; + this.Width = Application.GetRealWidth(82); + this.Height = Application.GetRealWidth(80); - Button btnIcon = new Button() + btnIcon = new Button() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(40), @@ -192,9 +465,9 @@ UnSelectedImagePath = UnSelectedIconPath, SelectedImagePath = SelectedIconPath, }; - view.AddChidren(btnIcon); + this.AddChidren(btnIcon); - Button btnText = new Button() + btnText = new Button() { Y = Application.GetRealWidth(40), Height = Application.GetRealWidth(41), @@ -203,28 +476,42 @@ TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, }; - view.AddChidren(btnText); + this.AddChidren(btnText); + } - - return view; + public void SetClickEvent(EventHandler<MouseEventArgs> eventHandler) + { + this.MouseUpEventHandler = eventHandler; + btnIcon.MouseUpEventHandler = eventHandler; + btnText.MouseUpEventHandler = eventHandler; } /// <summary> - /// + /// 鐐逛寒鍖哄煙 + /// </summary> + public void LightingView(bool seleted) + { + btnIcon.IsSelected = seleted; + } + + + } + + public class FixedArmView : FrameLayout + { + /// <summary> + /// 鍥哄畾甯冮槻鎺т欢 /// </summary> /// <param name="iconPath"></param> /// <param name="title"></param> /// <param name="titleTip"></param> - public FrameLayout FixedArmView(string iconPath,string title,string titleTip) + public FixedArmView(string iconPath, string title, string titleTip) { - var view = new FrameLayout() - { - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(66), - Radius = (uint)Application.GetRealWidth(6), - BorderColor = CSS_Color.MainColor, - BorderWidth = 1, - }; + this.Width = Application.GetRealWidth(144); + this.Height = Application.GetRealHeight(66); + this.Radius = (uint)Application.GetRealWidth(6); + this.BorderColor = CSS_Color.MainColor; + this.BorderWidth = 1; var btnIcon = new Button() { @@ -234,7 +521,7 @@ Gravity = Gravity.CenterVertical, UnSelectedImagePath = iconPath,// "FunctionIcon/ArmCenter/DisasterAlarmIcon.png", }; - view.AddChidren(btnIcon); + this.AddChidren(btnIcon); var btnTitle = new Button() { @@ -247,7 +534,7 @@ Text = title, IsBold = true, }; - view.AddChidren(btnTitle); + this.AddChidren(btnTitle); var btnTitleTip = new Button() { @@ -260,9 +547,9 @@ TextSize = CSS_FontSize.PromptFontSize_FirstLevel, Text = titleTip, }; - view.AddChidren(btnTitleTip); + this.AddChidren(btnTitleTip); - return view; } } + } -- Gitblit v1.8.0