JLChen
2021-08-21 af9c3e0b3b1eb370e966b3ca9db3f62848d4189b
HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs
@@ -1,4 +1,5 @@
using System;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
@@ -10,6 +11,11 @@
        /// 主窗体
        /// </summary>
        FrameLayout bodyView;
        /// <summary>
        /// 自定义布防区域
        /// </summary>
        HorizontalScrolViewLayout customDeploymentView;
        public ArmCenterPage()
        {
            bodyView = this;
@@ -21,7 +27,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()
            {
@@ -53,6 +59,33 @@
                Height = Application.GetRealWidth(16),
            });
            #region 撤防区域
            var disarmView = new FrameLayout()
            {
                Height = 0,
            };
            contentView.AddChidren(disarmView);
            var btnDisarm = new Button()
            {
                Width = Application.GetRealWidth(120),
                Height = Application.GetRealHeight(44),
                BackgroundColor = CSS_Color.WarningColor,
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainBackgroundColor,
                Text = "撤防"
            };
            disarmView.AddChidren(btnDisarm);
            btnDisarm.MouseUpEventHandler = (sender, e) => {
                if (SecurityCenter.Security.CurrentDefenseMode != null)
                {
                    Control.Ins.ControlSecurity(SecurityCenter.Security.CurrentDefenseMode, "disable");
                }
            };
            #endregion
            #region 自定义布防
            //自定义布防标题
            Button btnCustomDeploymentTitle = new Button()
@@ -67,7 +100,7 @@
            };
            contentView.AddChidren(btnCustomDeploymentTitle);
            HorizontalScrolViewLayout customDeploymentView = new HorizontalScrolViewLayout()
            customDeploymentView = new HorizontalScrolViewLayout()
            {
                X = Application.GetRealWidth(23),
                Height = Application.GetRealWidth(80),
@@ -75,24 +108,9 @@
            };
            contentView.AddChidren(customDeploymentView);
            //customDeploymentView.AddChidren(new Button()
            //{
            //    Width = Application.GetRealWidth(23),
            //});
            iniCustomDeploymentView();
            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 +118,8 @@
                Height = Application.GetRealHeight(20),
            });
            #region 固定布防区域
            /*
            var fixedDeploymentView = new FrameLayout()
            {
                Height = Application.GetRealHeight(133),
@@ -130,7 +150,6 @@
            };
            fixedDeploymentView.AddChidren(btnFixedDeploymentTip);
            //固定布防区域
            var fixedDeploymentTypeView = new HorizontalScrolViewLayout()
            {
                Y = btnFixedDeploymentTip.Bottom + Application.GetRealHeight(15),
@@ -144,11 +163,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,34 +176,171 @@
            });
            //防盗报警
            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
        }
        /// <summary>
        /// 初始化自定义布防区域
        /// </summary>
        private void iniCustomDeploymentView()
        {
            customDeploymentView.RemoveAll();
            foreach (var mode in FunctionList.List.securities)
            {
                var armDiyView = new ArmDiyView("FunctionIcon/ArmCenter/AddDefenseIcon.png", "FunctionIcon/ArmCenter/AddDefenseIcon.png",
                mode.name);
                customDeploymentView.AddChidren(armDiyView);
                EventHandler<MouseEventArgs> event2 = (sender, e) =>
                        {
                            ShowArmDialog(mode);
                        };
                armDiyView.SetClickEvent(event2);
            }
            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();
            btnOpen.MouseUpEventHandler = (sender, e) => {
                Control.Ins.ControlSecurity(alarm,  "enable");
                dialog.Close();
            };
            btnCheckModify.MouseUpEventHandler = (sender, e) => {
                dialog.Close();
                Action refreshAction = () =>
                {
                    iniCustomDeploymentView();
                };
                var armSetPage = new ArmDeploymentSettingPage(alarm,refreshAction);
                MainPage.BasePageView.AddChidren(armSetPage);
                armSetPage.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
        }
    }
    /// <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 +348,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 +359,34 @@
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            };
            view.AddChidren(btnText);
            return view;
            this.AddChidren(btnText);
        }
        public void SetClickEvent(EventHandler<MouseEventArgs> eventHandler)
        {
            this.MouseUpEventHandler = eventHandler;
            btnIcon.MouseUpEventHandler = eventHandler;
            btnText.MouseUpEventHandler = eventHandler;
        }
    }
    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 +396,7 @@
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = iconPath,// "FunctionIcon/ArmCenter/DisasterAlarmIcon.png",
            };
            view.AddChidren(btnIcon);
            this.AddChidren(btnIcon);
            var btnTitle = new Button()
            {
@@ -247,7 +409,7 @@
                Text = title,
                IsBold = true,
            };
            view.AddChidren(btnTitle);
            this.AddChidren(btnTitle);
            var btnTitleTip = new Button()
            {
@@ -260,9 +422,9 @@
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = titleTip,
            };
            view.AddChidren(btnTitleTip);
            this.AddChidren(btnTitleTip);
            return view;
        }
    }
}