aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.UI/Controls/ModalWindow.xaml.cs
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
commit767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch)
tree49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.UI/Controls/ModalWindow.xaml.cs
parent845554722efaed872948a9e0f7202e3ef52f1b6e (diff)
Pushing missing changes
Diffstat (limited to 'MediaBrowser.UI/Controls/ModalWindow.xaml.cs')
-rw-r--r--MediaBrowser.UI/Controls/ModalWindow.xaml.cs180
1 files changed, 180 insertions, 0 deletions
diff --git a/MediaBrowser.UI/Controls/ModalWindow.xaml.cs b/MediaBrowser.UI/Controls/ModalWindow.xaml.cs
new file mode 100644
index 000000000..21f97b8ac
--- /dev/null
+++ b/MediaBrowser.UI/Controls/ModalWindow.xaml.cs
@@ -0,0 +1,180 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media.Animation;
+
+namespace MediaBrowser.UI.Controls
+{
+ /// <summary>
+ /// Interaction logic for ModalWindow.xaml
+ /// </summary>
+ public partial class ModalWindow : BaseModalWindow
+ {
+ public MessageBoxResult MessageBoxResult { get; set; }
+
+ public UIElement TextContent
+ {
+ set
+ {
+ pnlContent.Children.Clear();
+
+ var textBlock = value as TextBlock;
+
+ if (textBlock != null)
+ {
+ textBlock.SetResourceReference(TextBlock.StyleProperty, "ModalTextStyle");
+ }
+ pnlContent.Children.Add(value);
+ }
+ }
+
+ public string Text
+ {
+ set { TextContent = new TextBlock { Text = value }; }
+ }
+
+ private MessageBoxButton _button;
+ public MessageBoxButton Button
+ {
+ get { return _button; }
+ set
+ {
+ _button = value;
+ UpdateButtonVisibility();
+ OnPropertyChanged("Button");
+ }
+ }
+
+ 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;
+ txtCaption.Visibility = string.IsNullOrEmpty(value) ? Visibility.Collapsed : Visibility.Visible;
+ OnPropertyChanged("Caption");
+ }
+ }
+
+ public ModalWindow()
+ : base()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnInitialized(EventArgs e)
+ {
+ base.OnInitialized(e);
+
+ btnOk.Click += btnOk_Click;
+ btnCancel.Click += btnCancel_Click;
+ btnYes.Click += btnYes_Click;
+ btnNo.Click += btnNo_Click;
+ }
+
+ void btnNo_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBoxResult = MessageBoxResult.No;
+ CloseModal();
+ }
+
+ void btnYes_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBoxResult = MessageBoxResult.Yes;
+ CloseModal();
+ }
+
+ void btnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBoxResult = MessageBoxResult.Cancel;
+ CloseModal();
+ }
+
+ void btnOk_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBoxResult = MessageBoxResult.OK;
+ CloseModal();
+ }
+
+ private void UpdateButtonVisibility()
+ {
+ btnYes.Visibility = Button == MessageBoxButton.YesNo || Button == MessageBoxButton.YesNoCancel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+
+ btnNo.Visibility = Button == MessageBoxButton.YesNo || Button == MessageBoxButton.YesNoCancel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+
+ btnOk.Visibility = Button == MessageBoxButton.OK || Button == MessageBoxButton.OKCancel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+
+ btnCancel.Visibility = Button == MessageBoxButton.OKCancel || Button == MessageBoxButton.YesNoCancel
+ ? Visibility.Visible
+ : Visibility.Collapsed;
+ }
+ }
+
+ /// <summary>
+ /// I had to make my own enum that essentially clones MessageBoxImage
+ /// Some of the options share the same enum int value, and this was preventing databinding from working properly.
+ /// </summary>
+ public enum MessageBoxIcon
+ {
+ // Summary:
+ // No icon is displayed.
+ None,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of white X in a circle with
+ // a red background.
+ Error,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of a white X in a circle with
+ // a red background.
+ Hand,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of white X in a circle with
+ // a red background.
+ Stop,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of a question mark in a circle.
+ Question,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of an exclamation point in a
+ // triangle with a yellow background.
+ Exclamation,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of an exclamation point in a
+ // triangle with a yellow background.
+ Warning,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of a lowercase letter i in a
+ // circle.
+ Information,
+ //
+ // Summary:
+ // The message box contains a symbol consisting of a lowercase letter i in a
+ // circle.
+ Asterisk
+ }
+}