예제 #1
0
        /// <summary>
        /// 生成按钮控件
        /// </summary>
        /// <returns></returns>
        public Button GenerateControl()
        {
            var btn = new Button();

            btn.Content    = ButtonContent;
            btn.Background = AlertTheme.GetBrush(BackgroundColor);
            btn.Padding    = new System.Windows.Thickness(10, 5, 10, 5);
            btn.Margin     = new System.Windows.Thickness(10, 0, 0, 0);
            btn.Height     = Height;
            if (Width != -1)
            {
                btn.Width = Width;
            }
            btn.FontSize        = FontSize;
            btn.Foreground      = AlertTheme.GetBrush(FontColor);
            btn.BorderBrush     = AlertTheme.GetBrush(BorderColor);
            btn.BorderThickness = new System.Windows.Thickness(BorderThickness);
            btn.Margin          = new System.Windows.Thickness(10, 0, 0, 0);
            if (-1 != Width)
            {
                btn.Width = Width;
            }
            btn.Cursor = System.Windows.Input.Cursors.Hand;
            btn.Click += (sender, e) =>
            {
                _onBtnClickCallback?.Invoke();
            };
            return(btn);
        }
예제 #2
0
 /// <summary>
 /// 初始化UI
 /// </summary>
 /// <param name="alertType"></param>
 private void InitTheme(AlertTheme alertType)
 {
     MainBorder.Background = new SolidColorBrush(AlertTheme.GetMediaColorFromDrawingColor(alertType.PrimaryBackColor));
     tBlockAlertTitle.Background = new SolidColorBrush(AlertTheme.GetMediaColorFromDrawingColor(alertType.SecondaryBackColor));
     brdCose.Background = new SolidColorBrush(AlertTheme.GetMediaColorFromDrawingColor(alertType.SecondaryBackColor));
     tBlockAlertTitle.Foreground = new SolidColorBrush(AlertTheme.GetMediaColorFromDrawingColor(alertType.TitleColor));
     tBlockAlertContent.Foreground = new SolidColorBrush(AlertTheme.GetMediaColorFromDrawingColor(alertType.ContentColor));
     btnClose.Background = new SolidColorBrush(AlertTheme.GetMediaColorFromDrawingColor(alertType.PullBackColor));
     btnClose.Foreground = new SolidColorBrush(AlertTheme.GetMediaColorFromDrawingColor(alertType._pullBackForeColor));
 }
예제 #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);
     }));
 }
예제 #4
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);
        }
예제 #5
0
 /// <summary>
 /// 应用指定弹窗主题
 /// </summary>
 /// <param name="theme"></param>
 public void LoadAlertTheme(AlertTheme theme)
 {
     BorderColor = FontColor = theme.PullBackColor;
 }
예제 #6
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);
예제 #7
0
 /// <summary>
 /// 显示弹框
 /// </summary>
 /// <param name="title">弹框标题</param>
 /// <param name="content">弹框主体内容</param>
 /// <param name="AlertTheme">弹框类型</param>
 /// <param name="userButton">交互按钮</param>
 public static void Show(string title, string content, AlertTheme AlertTheme, UserButton userButton)
 => Show(title, content, AlertTheme, new List <UserButton>()
 {
     userButton
 }, null);
예제 #8
0
 /// <summary>
 /// 显示弹框
 /// </summary>
 /// <param name="content">弹框主体内容</param>
 /// <param name="AlertTheme">弹框类型</param>
 public static void Show(string content, AlertTheme AlertTheme)
 => Show(null, content, AlertTheme);