aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.UI/Controls/NotificationMessage.xaml.cs
blob: 06ed513b13150b6ec3d25609139d5bcca5855b33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Windows;
using System.Windows.Controls;

namespace MediaBrowser.UI.Controls
{
    /// <summary>
    /// Interaction logic for NotificationMessage.xaml
    /// </summary>
    public partial class NotificationMessage : BaseUserControl
    {
        public NotificationMessage()
        {
            InitializeComponent();
        }

        public UIElement TextContent
        {
            set
            {
                pnlContent.Children.Clear();

                var textBlock = value as TextBlock;

                if (textBlock != null)
                {
                    textBlock.SetResourceReference(TextBlock.StyleProperty, "NotificationTextStyle");
                }
                pnlContent.Children.Add(value);
            }
        }

        public string Text
        {
            set { TextContent = new TextBlock { Text = value }; }
        }

        private MessageBoxIcon _messageBoxImage;
        public MessageBoxIcon MessageBoxImage
        {
            get { return _messageBoxImage; }
            set
            {
                _messageBoxImage = value;
                OnPropertyChanged("MessageBoxImage");
            }
        }

        private string _caption;
        public string Caption
        {
            get { return _caption; }
            set
            {
                _caption = value;
                OnPropertyChanged("Caption");
                txtCaption.Visibility = string.IsNullOrEmpty(value) ? Visibility.Collapsed : Visibility.Visible;
            }
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            DataContext = this;
        }
    }
}