public static MessageWindowResponse ShowTopMost(string message, string caption, MessageWindowButtons buttons, MessageWindowIcon icon) { var messageWindow = new MessageWindow(message, caption, buttons, icon); TopMostHelper.ShowDialogTopMost(messageWindow, false); return(messageWindow.DialogResponse); }
private void SetIcon(MessageWindowIcon icon) { IconBox.Visibility = Visibility.Visible; IconBox.Width = 32; IconBox.Height = 32; var img = new Image(); switch (icon) { case MessageWindowIcon.Error: img.Source = ConvertBitmap(SystemIcons.Error.ToBitmap()); SystemSounds.Hand.Play(); IconBox.Content = img; break; case MessageWindowIcon.Exclamation: img.Source = ConvertBitmap(SystemIcons.Exclamation.ToBitmap()); SystemSounds.Exclamation.Play(); IconBox.Content = img; break; case MessageWindowIcon.Info: img.Source = ConvertBitmap(SystemIcons.Information.ToBitmap()); IconBox.Content = img; SystemSounds.Asterisk.Play(); break; case MessageWindowIcon.Question: img.Source = ConvertBitmap(SystemIcons.Question.ToBitmap()); IconBox.Content = img; SystemSounds.Question.Play(); break; case MessageWindowIcon.Warning: img.Source = ConvertBitmap(SystemIcons.Warning.ToBitmap()); IconBox.Content = img; SystemSounds.Exclamation.Play(); break; case MessageWindowIcon.PDFCreator: IconBox.Width = 45; IconBox.Height = 45; IconBox.Content = FindResource("PDFCreatorLogo"); break; case MessageWindowIcon.PDFForge: IconBox.Width = 45; IconBox.Height = 45; IconBox.Content = FindResource("RedFlame"); break; case MessageWindowIcon.None: IconBox.Visibility = Visibility.Collapsed; break; } }
public MessageWindowViewModel(string caption, string message, MessageWindowIcon icon, MessageWindowButton buttons) { Caption = caption; Message = message; switch (icon) { case MessageWindowIcon.OK: Icon = Icons.Good; break; case MessageWindowIcon.Caution: Icon = Icons.Caution; break; case MessageWindowIcon.Error: Icon = Icons.Urgent; break; case MessageWindowIcon.Question: Icon = Icons.Unknown; break; } switch (buttons) { case MessageWindowButton.OK: YesButtonVisibility = Visibility.Collapsed; NoButtonVisibility = Visibility.Collapsed; CancelButtonVisibility = Visibility.Collapsed; OKButtonVisibility = Visibility.Visible; break; case MessageWindowButton.OKCancel: YesButtonVisibility = Visibility.Collapsed; NoButtonVisibility = Visibility.Collapsed; CancelButtonVisibility = Visibility.Visible; OKButtonVisibility = Visibility.Visible; break; case MessageWindowButton.YesNo: YesButtonVisibility = Visibility.Visible; NoButtonVisibility = Visibility.Visible; CancelButtonVisibility = Visibility.Collapsed; OKButtonVisibility = Visibility.Collapsed; break; case MessageWindowButton.YesNoCancel: YesButtonVisibility = Visibility.Visible; NoButtonVisibility = Visibility.Visible; CancelButtonVisibility = Visibility.Visible; OKButtonVisibility = Visibility.Collapsed; break; } }
internal static bool? Show(Window owner, string caption, string message, MessageWindowIcon icon = MessageWindowIcon.OK, MessageWindowButton buttons = MessageWindowButton.OK) { bool? result = null; Application.Current.Dispatcher.Invoke(new Action(() => { MessageWindow window = new MessageWindow(); window.DataContext = new MessageWindowViewModel(caption, message, icon, buttons); window.Owner = owner; result = window.ShowDialog(); })); return result; }
internal static bool?Show(Window owner, string caption, string message, MessageWindowIcon icon = MessageWindowIcon.OK, MessageWindowButton buttons = MessageWindowButton.OK) { bool?result = null; Application.Current.Dispatcher.Invoke(new Action(() => { MessageWindow window = new MessageWindow(); window.DataContext = new MessageWindowViewModel(caption, message, icon, buttons); window.Owner = owner; result = window.ShowDialog(); })); return(result); }
public MessageWindow(string title, string message, MessageWindowIcon icon, MessageWindowIconColor iconColor) { InitializeComponent(); Title = title; tbMsg.Text = message; switch (icon) { default: case MessageWindowIcon.Info: tbIcon.Text = Char.ConvertFromUtf32(0xE946); break; case MessageWindowIcon.Warning: tbIcon.Text = Char.ConvertFromUtf32(0xE7BA); break; case MessageWindowIcon.Error: tbIcon.Text = Char.ConvertFromUtf32(0xE783); break; } switch (iconColor) { default: case MessageWindowIconColor.Blue: tbIcon.Foreground = new SolidColorBrush(Color.FromRgb(0, 122, 204)); brd.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 122, 204)); break; case MessageWindowIconColor.Orange: tbIcon.Foreground = new SolidColorBrush(Color.FromRgb(255, 204, 0)); brd.BorderBrush = new SolidColorBrush(Color.FromRgb(255, 204, 0)); break; case MessageWindowIconColor.Red: tbIcon.Foreground = new SolidColorBrush(Color.FromRgb(239, 83, 80)); brd.BorderBrush = new SolidColorBrush(Color.FromRgb(239, 83, 80)); break; } }
public MessageWindow(string message, string caption, MessageWindowButtons buttons, MessageWindowIcon icon) { InitializeComponent(); MessageText.Text = message; Title = caption; SetButtons(buttons); SetIcon(icon); _messageWindowVM = new MessageWindowViewModel(buttons); _messageWindowVM.CloseViewAction = delegate(bool?result) { DialogResult = result; }; DataContext = _messageWindowVM; }