Example #1
0
        /// <summary>
        /// 弹框窗体
        /// </summary>
        /// <param name="title"></param>
        /// <param name="content"></param>
        /// <param name="alertType"></param>
        /// <param name="userButtonList"></param>
        /// <param name="alertConfig"></param>
        public AlertWindow(string title, string content, AlertTheme alertType, List<UserButton> userButtonList, AlertConfig alertConfig)
        {
            InitializeComponent();
            this.ShowInTaskbar = false;
            
            tBlockAlertContent.Text = content;

            if (string.IsNullOrEmpty(title))//标题为空
            {
                //标题栏高度为0
                tBlockAlertTitle.Height = 0;
            }
            else
            {
                tBlockAlertTitle.Text = title;
            }
            if (null == userButtonList || 0 == userButtonList.Count)//按钮为空
            {
                //按钮栏高度为0
                ButtonGroup.Height = 0;
                ButtonGroup.Margin =new  Thickness(0);
            }
            else
            {
                foreach( var btnClass in userButtonList)
                {
                    var btn = btnClass.GenerateControl();
                    if (btnClass.CloseAlertIfClick)
                    {//点击按钮后关闭弹窗
                        btn.Click +=(sender, e) =>{
                            CloseAlert();
                        };
                    }
                    ButtonGroup.Children.Add(btn);
                    
                }
            }
            _alertConfig = alertConfig ?? new AlertConfig() ;

            InitTheme(alertType);
        }
Example #2
0
 /// <summary>
 /// 显示弹框
 /// </summary>
 /// <param name="title">弹框标题</param>
 /// <param name="content">弹框主体内容</param>
 /// <param name="AlertTheme">弹框类型</param>
 /// <param name="userButton1">交互按钮1</param>
 /// <param name="userButton2">交互按钮2</param>
 /// <param name="alertConfig">用户自定义配置</param>
 public static void Show(string title, string content, AlertTheme AlertTheme, UserButton userButton1, UserButton userButton2, AlertConfig alertConfig)
 => Show(title, content, AlertTheme, new List <UserButton>()
 {
     userButton1, userButton2
 }, alertConfig);
Example #3
0
 /// <summary>
 /// 显示弹框
 /// </summary>
 /// <param name="title">弹框标题</param>
 /// <param name="content">弹框主体内容</param>
 /// <param name="AlertTheme">弹框类型</param>
 /// <param name="userButtonList">交互按钮集合</param>
 /// <param name="alertConfig">用户自定义配置</param>
 public static void Show(string title, string content, AlertTheme AlertTheme, List <UserButton> userButtonList, AlertConfig alertConfig)
 {
     if (null != alertConfig && alertConfig.OnlyOneWindowAllowed && _isWindowShowing)
     {
         return;
     }
     System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
     {
         _isWindowShowing = true;
         new AlertWindow(title, content, AlertTheme, userButtonList, alertConfig).SetOnWindowCloseCallback(OnWindowClose);
     }));
 }