public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string parameterString = parameter as string; MessageDialogType input = (MessageDialogType)value; return(input == MessageDialogType.Success ? Success : Error); }
public MessageDialogViewModel(MessageDialogType messageDialogType) { switch (messageDialogType) { case MessageDialogType.None: break; case MessageDialogType.Information: ShowIconInformation = true; break; case MessageDialogType.Warning: ShowIconWarning = true; break; case MessageDialogType.Error: ShowIconError = true; break; case MessageDialogType.Question: ShowIconQuestion = true; break; case MessageDialogType.Success: ShowIconSuccess = true; break; default: break; } OkCommand = ReactiveCommand.Create(() => OnOk()); CancelCommand = ReactiveCommand.Create(() => OnCancel()); }
public static int ShowMessage(IServiceProvider serviceProvider, MessageDialogType messageType, string title, string message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } bool isDefaultTitle = false; if (String.IsNullOrEmpty(title)) { title = "Tizen Plugin"; isDefaultTitle = true; } OLEMSGICON icon; OLEMSGBUTTON button; switch (messageType) { case MessageDialogType.Debug: icon = OLEMSGICON.OLEMSGICON_NOICON; button = OLEMSGBUTTON.OLEMSGBUTTON_OK; break; case MessageDialogType.Info: icon = OLEMSGICON.OLEMSGICON_INFO; button = OLEMSGBUTTON.OLEMSGBUTTON_OK; break; case MessageDialogType.Warning: if (isDefaultTitle) { title += " Warning"; } icon = OLEMSGICON.OLEMSGICON_WARNING; button = OLEMSGBUTTON.OLEMSGBUTTON_OK; break; case MessageDialogType.Error: if (isDefaultTitle) { title += " Error"; } icon = OLEMSGICON.OLEMSGICON_CRITICAL; button = OLEMSGBUTTON.OLEMSGBUTTON_OK; break; case MessageDialogType.Question: icon = OLEMSGICON.OLEMSGICON_QUERY; button = OLEMSGBUTTON.OLEMSGBUTTON_YESNO; break; default: icon = OLEMSGICON.OLEMSGICON_NOICON; button = OLEMSGBUTTON.OLEMSGBUTTON_OK; break; } return(VsShellUtilities.ShowMessageBox(serviceProvider, message, title, icon, button, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST)); }
/// <summary> /// MessageBox /// </summary> /// <param name="title">Dialog Title</param> /// <param name="message">May contain \n.</param> /// <param name="dialogType">Ok, OkCancel, YesNo, YesNoCancel.</param> /// <param name="iconType">Info, Warning, Error, Question.</param> /// <param name="defaultButton">Cancel_No, Ok_Yes, No_In_Yes_No_Cancel.</param> /// <returns>If Type is OkCancel or YesNo returns true when clicking OK or YES otherwise returns false.</returns> public static bool MessageBox(string title, string message, MessageDialogType dialogType, MessageDialogIconType iconType, MessageDialogDefaultButton defaultButton) { string dialogTypeStr; string iconTypeStr; switch (dialogType) { default: case MessageDialogType.Ok: dialogTypeStr = "ok"; break; case MessageDialogType.OkCancel: dialogTypeStr = "okcancel"; break; case MessageDialogType.YesNo: dialogTypeStr = "yesno"; break; case MessageDialogType.YesNoCancel: dialogTypeStr = "yesnocancel"; break; } switch (iconType) { default: case MessageDialogIconType.Info: iconTypeStr = "info"; break; case MessageDialogIconType.Warning: iconTypeStr = "warning"; break; case MessageDialogIconType.Error: iconTypeStr = "error"; break; case MessageDialogIconType.Question: iconTypeStr = "question"; break; } int result = tinyfd_messageBox(title, message, dialogTypeStr, iconTypeStr, (int)defaultButton); return(result == 1); }
public MessageDialog(MessageDialogType messageType, Exception exception, string messageCode, string strMsg, params object[] buttonLabels) { InitializeComponent(); if (exception != null) { m_messageType = MessageDialogType.Error; m_message = exception.Message; } else { m_messageType = messageType; } m_buttonLabels = buttonLabels; if (!string.IsNullOrEmpty(strMsg)) { m_message = strMsg; } else { m_message = string.IsNullOrEmpty(messageCode) ? string.Empty : ConfigData.Current.SysMessage.GetMessage(messageCode); } DialogInit(); }
/// <summary> /// Render all messages that have been set during execution of the controller action. /// </summary> /// <param name="htmlHelper"></param> /// <returns></returns> public static HtmlString RenderMessages(this HtmlHelper htmlHelper, MessageDialogType type = MessageDialogType.AdminLTE) { var messages = String.Empty; foreach (var messageType in Enum.GetNames(typeof(MessageType))) { var message = htmlHelper.ViewContext.ViewData.ContainsKey(messageType) ? htmlHelper.ViewContext.ViewData[messageType] : htmlHelper.ViewContext.TempData.ContainsKey(messageType) ? htmlHelper.ViewContext.TempData[messageType] : null; if (message != null) { var lowermessage = messageType.ToLowerInvariant(); MessageType msgType = (MessageType)Enum.Parse(typeof(MessageType), messageType, true); var messageTitle = msgType.GetDisplayValue(); var messageBoxBuilder = new TagBuilder("div"); if (type == MessageDialogType.BootStrap) { messageBoxBuilder.AddCssClass(string.Format("alert alert-{0} fade in", lowermessage)); messageBoxBuilder.InnerHtml = string.Format("<button class='close' data-dismiss='alert' aria-label='close'>×</button><strong>{0}</strong> {1}", messageTitle, message.ToString()); } else { messageBoxBuilder.AddCssClass(string.Format("alert alert-{0} fade in", lowermessage)); string msgicon = ""; switch (lowermessage) { case "danger": msgicon = "fa-ban"; break; case "info": msgicon = "fa-info"; break; case "warning": msgicon = "fa-warning"; break; case "success": msgicon = "fa-check"; break; default: break; } messageBoxBuilder.InnerHtml = string.Format("<button type = 'button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>" + "<h4><i class='icon fa {0}'></i> {1}</h4>{2}", msgicon, messageTitle, message.ToString()); } messages += messageBoxBuilder.ToString(); } } return(MvcHtmlString.Create(messages)); }
private void Show(MessageDialogType type, string caption, string text, ButtonsType buttons, Action <ResponseType> callback) { Application.Invoke(delegate { using var dialog = CreateMessageDialog(type, caption, text, buttons); ResponseType result = (ResponseType)dialog.Run(); dialog.Hide(); callback.Invoke(result); });
private static FormMessage CreateMessageForm(MessageDialogType type, string title, string text) { return(new FormMessage(title, text, type switch { MessageDialogType.Error => MessageBoxIcon.Error, MessageDialogType.Warning => MessageBoxIcon.Warning, MessageDialogType.Information => MessageBoxIcon.Information, MessageDialogType.Question => MessageBoxIcon.Question, _ => MessageBoxIcon.None }));
private MessageDialog CreateMessageDialog(MessageDialogType type, string caption, string text, ButtonsType buttons) { var messageType = type switch { MessageDialogType.Error => MessageType.Error, MessageDialogType.Warning => MessageType.Warning, MessageDialogType.Information => MessageType.Info, MessageDialogType.Question => MessageType.Question, _ => MessageType.Other }; return(GtkUtils.CreateMessageDialog(window, messageType, caption, text, buttons)); }
public void ShowMessageDialog(MessageDialogType type, string message, string title) { var image = type switch { MessageDialogType.Information => MessageBoxImage.Information, MessageDialogType.Warning => MessageBoxImage.Warning, MessageDialogType.Error => MessageBoxImage.Error, _ => throw new ArgumentException("Message dialog type is invalid", nameof(type)) }; MessageBox.Show(message, title, MessageBoxButton.OK, image); }
/// <summary> /// Show MessageBox 메시지박스 /// </summary> /// <param name="messageType"></param> /// <param name="messageCode"></param> /// <param name="strMsg"></param> /// <param name="buttonLabels">표시 되는 버튼만큼 버튼글자</param> /// <returns></returns> public DialogResult ShowMessageBox(MessageDialogType messageType, string messageCode, string strMsg, string[] buttonLabels) { Form f = (Form)ChildManager; if (f == null || f.IsDisposed || f.Disposing) { return(new MessageDialog(messageType, null, messageCode, strMsg, buttonLabels).ShowDialog()); } return(new MessageDialog(messageType, null, messageCode, strMsg, buttonLabels).ShowDialog((Form)ChildManager)); //return new MessageBoxDialog(messageType, messageCode, strMsg, buttonLabels).ShowDialog((Form)ChildManager); }
public static int ShowMessage(MessageDialogType messageType, string title, string message) { var vsPackage = instance; if (vsPackage != null) { return(ShellHelper.ShowMessage(vsPackage, messageType, title, message)); } if (messageType != MessageDialogType.Question) { MessageBox.Show(message, title); } return(-1); }
public MessageDialog(MessageDialogType messageType, string messageCode, string strMsg, params object[] buttonLabels) : this() { m_messageType = messageType; m_buttonLabels = buttonLabels; if (!string.IsNullOrEmpty(strMsg)) { m_message = strMsg; } else { m_message = ConfigData.Current.SysMessage.GetMessage(messageCode); } }
public ButtonResult ShowMessage(string message, string title, MessageDialogType messageDialogType) { MessageContent messageContent = new MessageContent() { Message = message, Title = title, MessageDialogValue = messageDialogType }; IDialogResult dialogResult = null; _dialogService.ShowDialog(nameof(MessageDialog), new DialogParameters { { "MessageContent", messageContent } }, result => dialogResult = result); return(dialogResult.Result); }
public MessageDialogResult ShowMessageDialog(string title, string message, MessageDialogType type = MessageDialogType.Ok, MessageDialogResult defaultResult = MessageDialogResult.Ok) { switch (type) { case MessageDialogType.Ok: if (string.IsNullOrEmpty(title)) { MessageBox.Show(message); } else { MessageBox.Show(message, title); } return(MessageDialogResult.Ok); case MessageDialogType.OkCancel: var result = MessageBox.Show(message, title, MessageBoxButton.OKCancel); switch (result) { case MessageBoxResult.OK: return(MessageDialogResult.Ok); case MessageBoxResult.Cancel: default: return(MessageDialogResult.Cancel); } case MessageDialogType.YesNo: result = MessageBox.Show(message, title, MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: return(MessageDialogResult.Yes); case MessageBoxResult.No: default: return(MessageDialogResult.No); } } return(defaultResult); }
public static async Task <bool> Show(string title, string message, MessageDialogType messageDialogType) { dialogManager = Locator.Current.GetService <IDialogManager>(); var vm = new MessageDialogViewModel(messageDialogType) { Title = title, Message = message }; var dialog = new DialogMessage { DataContext = vm }; observableSubs = Observable.Merge(vm.OkCommand, vm.CancelCommand) .Take(1) .Subscribe(r => OnClose(r)); return(await dialogManager.ShowChildDialogAsync <bool>(dialog)); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { MessageDialogType messageDialogType = ((MessageDialogViewModel)item).MessageDialogValue; switch (messageDialogType) { case MessageDialogType.OkOnly: { return(OkOnlyTemplate); } case MessageDialogType.OkCancel: { return(OkCancelTemplate); } case MessageDialogType.YesNo: { return(YesNoTemplate); } } return(base.SelectTemplate(item, container)); }
private static (MessageDialogType, string) GetMessageDialogProperties(string text) { MessageDialogType type = MessageDialogType.None; int pipe = text.IndexOf('|'); if (pipe != -1) { type = text.Substring(0, pipe) switch { "error" => MessageDialogType.Error, "warning" => MessageDialogType.Warning, "info" => MessageDialogType.Information, "question" => MessageDialogType.Question, _ => MessageDialogType.None }; if (type != MessageDialogType.None) { text = text.Substring(pipe + 1); } } return(type, text); }
public static Task <MessageBoxResult> ShowAsync( string header, string content, MessageBoxButton button = MessageBoxButton.OK, MessageDialogType type = MessageDialogType.Light, System.Windows.Window owner = null) { TaskCompletionSource <MessageBoxResult> taskCompletionSource = new TaskCompletionSource <MessageBoxResult>(); if (owner == null) { owner = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); } MessageDialog messageDialog = new MessageDialog() { Content = content }; OverlayWindow window = new OverlayWindow() { Content = messageDialog, Owner = owner }; switch (type) { case MessageDialogType.Accent: window.Style = (Style)window.FindResource("AccentOverlayWindowStyle"); break; case MessageDialogType.Dark: window.Style = (Style)window.FindResource("DarkOverlayWindowStyle"); break; } messageDialog.Header = new TextBlock() { Style = (Style)window.FindResource("HeaderTextStyle"), Text = header }; if ((button == MessageBoxButton.OK) || (button == MessageBoxButton.OKCancel)) { messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.OK); } }), Content = "Ok" }); } if ((button == MessageBoxButton.YesNo) || (button == MessageBoxButton.YesNoCancel)) { messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.Yes); } }), Content = "Yes" }); messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.No); } }), Content = "No" }); } if ((button == MessageBoxButton.OKCancel) || (button == MessageBoxButton.YesNoCancel)) { messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.Cancel); } }), Content = "Cancel" }); } messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1; window.Show(); return(taskCompletionSource.Task); }
public static Task <MessageBoxResult> ShowAsync( string header, string content, IEnumerable <MessageDialogButton> buttons, MessageDialogType type = MessageDialogType.Light, System.Windows.Window owner = null, int defaultCommandIndex = 0, int cancelCommandIndex = -1) { TaskCompletionSource <MessageBoxResult> taskCompletionSource = new TaskCompletionSource <MessageBoxResult>(); if (owner == null) { owner = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); } MessageDialog messageDialog = new MessageDialog() { Header = header, Content = content }; OverlayWindow window = new OverlayWindow() { Content = messageDialog, Owner = owner }; switch (type) { case MessageDialogType.Accent: window.Style = (Style)window.FindResource("AccentOverlayWindowStyle"); break; case MessageDialogType.Dark: window.Style = (Style)window.FindResource("DarkOverlayWindowStyle"); break; } foreach (MessageDialogButton button in buttons) { messageDialog.Items.Add(button); } if (cancelCommandIndex == -1) { messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1; } window.Show(); messageDialog .FindVisualChildren <Button>() .ToList() .ForEach( x => x.Click += (sender, e) => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.None); } }); return(taskCompletionSource.Task); }
public MessageDialog(Exception exception) : this() { m_messageType = MessageDialogType.Error; m_message = exception.Message; }
/// <summary> /// 显示确认对话消息 /// 确认和取消 /// </summary> /// <param name="content">内容</param> /// <param name="title">标题</param> /// <param name="type">对话类型</param> /// <returns></returns> public static async Task <MessageDialogResult> ShowMessageAsync(string content, string title, MessageDialogType type) { MessageDialogResult result = MessageDialogResult.Default; var dialog = new MessageDialog(content, title); List <UICommand> commandList = new List <UICommand>(); switch (type) { case MessageDialogType.OK: commandList.Add(new UICommand("确定", cmd => { result = MessageDialogResult.OK; }, commandId: 0)); break; case MessageDialogType.AbortRetryIgnore: commandList.Add(new UICommand("中止", cmd => { result = MessageDialogResult.Abort; }, commandId: 0)); commandList.Add(new UICommand("重试", cmd => { result = MessageDialogResult.Retry; }, commandId: 1)); commandList.Add(new UICommand("忽略", cmd => { result = MessageDialogResult.Ignore; }, commandId: 2)); break; case MessageDialogType.YesNoCancel: commandList.Add(new UICommand("是", cmd => { result = MessageDialogResult.Yes; }, commandId: 0)); commandList.Add(new UICommand("否", cmd => { result = MessageDialogResult.No; }, commandId: 1)); commandList.Add(new UICommand("取消", cmd => { result = MessageDialogResult.Cancel; }, commandId: 2)); break; case MessageDialogType.YesNo: commandList.Add(new UICommand("是", cmd => { result = MessageDialogResult.Yes; }, commandId: 0)); commandList.Add(new UICommand("否", cmd => { result = MessageDialogResult.No; }, commandId: 1)); break; case MessageDialogType.RetryCancel: commandList.Add(new UICommand("重试", cmd => { result = MessageDialogResult.Retry; }, commandId: 0)); commandList.Add(new UICommand("取消", cmd => { result = MessageDialogResult.Cancel; }, commandId: 1)); break; case MessageDialogType.OKCancel: default: commandList.Add(new UICommand("确定", cmd => { result = MessageDialogResult.OK; }, commandId: 0)); commandList.Add(new UICommand("取消", cmd => { result = MessageDialogResult.Cancel; }, commandId: 1)); break; } foreach (var command in commandList) { dialog.Commands.Add(command); } //设置默认按钮,不设置的话默认的确认按钮是第一个按钮 dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = (uint)commandList.Count - 1; //获取返回值 await dialog.ShowAsync(); return(result); }
public MessageDialogViewModel(MessageDialogType messageDialogType, string message) { MessageDialogType = messageDialogType; Message = message ?? throw new ArgumentNullException(nameof(message)); }
public static Task<MessageBoxResult> ShowAsync( string header, string content, IEnumerable<MessageDialogButton> buttons, MessageDialogType type = MessageDialogType.Light, System.Windows.Window owner = null, int defaultCommandIndex = 0, int cancelCommandIndex = -1) { TaskCompletionSource<MessageBoxResult> taskCompletionSource = new TaskCompletionSource<MessageBoxResult>(); if (owner == null) { owner = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive); } MessageDialog messageDialog = new MessageDialog() { Header = header, Content = content }; OverlayWindow window = new OverlayWindow() { Content = messageDialog, Owner = owner }; switch (type) { case MessageDialogType.Accent: window.Style = (Style)window.FindResource("AccentOverlayWindowStyle"); break; case MessageDialogType.Dark: window.Style = (Style)window.FindResource("DarkOverlayWindowStyle"); break; } foreach (MessageDialogButton button in buttons) { messageDialog.Items.Add(button); } if (cancelCommandIndex == -1) { messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1; } window.Show(); messageDialog .FindVisualChildren<Button>() .ToList() .ForEach( x => x.Click += (sender, e) => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.None); } }); return taskCompletionSource.Task; }
private void InitDialogByType(MessageDialogType messageType) { var msgType = messageType == MessageDialogType.YesNoCancel ? MessageDialogType.Question : messageType; if (messageType != MessageDialogType.None) { picMsgIcon.Image = Extensions.ResourceLoad(string.Format("messagedialog_{0}.png", msgType.ToString().ToLower())); } switch (messageType) { case MessageDialogType.Question: btnYes.Visible = false; btnNoOK.Visible = true; btnCancelClose.Visible = true; btnNoOK.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_Yes; btnNoOK.Tag = "Yes"; btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[1].ToString() : Properties.Resources.MessageDialog_Button_No; btnCancelClose.Tag = "No"; Text = Properties.Resources.MessageDialog_Title_Question; break; case MessageDialogType.YesNoCancel: btnYes.Visible = true; btnNoOK.Visible = true; btnCancelClose.Visible = true; btnYes.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_Yes; btnYes.Tag = "Yes"; btnNoOK.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[1].ToString() : Properties.Resources.MessageDialog_Button_No; btnNoOK.Tag = "No"; btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[2].ToString() : Properties.Resources.MessageDialog_Button_Cancel; btnCancelClose.Tag = "Cancel"; Text = Properties.Resources.MessageDialog_Title_YesNoCancel; break; case MessageDialogType.Error: btnYes.Visible = false; btnNoOK.Visible = false; btnCancelClose.Visible = true; btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_OK; btnCancelClose.Tag = "OK"; Text = Properties.Resources.MessageDialog_Title_Error; break; case MessageDialogType.Warning: btnYes.Visible = false; btnNoOK.Visible = false; btnCancelClose.Visible = true; btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_OK; btnCancelClose.Tag = "OK"; Text = Properties.Resources.MessageDialog_Title_Warning; break; case MessageDialogType.Information: btnYes.Visible = false; btnNoOK.Visible = false; btnCancelClose.Visible = true; btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ? m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_OK; btnCancelClose.Tag = "OK"; Text = Properties.Resources.MessageDialog_Title_Information; break; default: break; } }
bool?IUIService.ShowMessageDialog(string message, MessageDialogType type, bool canCancel) { MessageBoxButton button; MessageBoxImage icon; switch (type) { case MessageDialogType.Information: button = MessageBoxButton.OK; icon = MessageBoxImage.Information; break; case MessageDialogType.Warning: button = MessageBoxButton.OK; icon = MessageBoxImage.Warning; break; case MessageDialogType.Error: button = MessageBoxButton.OK; icon = MessageBoxImage.Error; break; case MessageDialogType.Question: button = canCancel ? MessageBoxButton.YesNoCancel : MessageBoxButton.YesNo; icon = MessageBoxImage.Question; break; default: throw new InvalidOperationException(); } MessageBoxResult result; if (MainWindow != null) { result = MessageBox.Show( MainWindow, message, Model.SR.DefaultWindowCaption, button, icon); } else { result = MessageBox.Show( message, Model.SR.DefaultWindowCaption, button, icon); } switch (result) { case MessageBoxResult.None: return(null); case MessageBoxResult.OK: return(true); case MessageBoxResult.Cancel: return(null); case MessageBoxResult.Yes: return(true); case MessageBoxResult.No: return(false); default: throw new InvalidOperationException(); } }
/// <summary> /// Show MessageBox 메시지박스 /// </summary> /// <param name="messageType"></param> /// <param name="messageCode"></param> /// <param name="strMsg"></param> /// <param name="buttonLabels">표시 되는 버튼만큼 버튼글자</param> /// <returns></returns> public DialogResult ShowMessageBox(MessageDialogType messageType, string messageCode, string strMsg, string[] buttonLabels) { return(new MessageDialog(messageType, null, messageCode, strMsg, buttonLabels).ShowDialog(this)); //return new MessageBoxDialog(messageType, messageCode, strMsg, buttonLabels).ShowDialog(this); }
public MessageDialog(string Title, string Message, MessageDialogButtons Buttons, MessageDialogType Type, Brush BackColor) { InitializeComponent(); switch (Buttons) { case MessageDialogButtons.Ok: ButtonNo.Visibility = System.Windows.Visibility.Hidden; ButtonYes.Visibility = System.Windows.Visibility.Hidden; break; case MessageDialogButtons.YesNo: ButtonOk.Visibility = System.Windows.Visibility.Hidden; break; } switch (Type) { case MessageDialogType.Information: ImageIcon.Source = (ImageSource)ImageIcon.Resources["ImageHeaderDialogInfo"]; break; case MessageDialogType.Warning: ImageIcon.Source = (ImageSource)ImageIcon.Resources["ImageHeaderDialogWarning"]; break; case MessageDialogType.Error: ImageIcon.Source = (ImageSource)ImageIcon.Resources["ImageHeaderDialogError"]; break; } TextBlockMessage.Text = Message; TextBlockTitle.Text = Title; GridTitle.Background = BackColor; }
public static Task<MessageBoxResult> ShowAsync( string header, string content, MessageBoxButton button = MessageBoxButton.OK, MessageDialogType type = MessageDialogType.Light, System.Windows.Window owner = null) { TaskCompletionSource<MessageBoxResult> taskCompletionSource = new TaskCompletionSource<MessageBoxResult>(); if (owner == null) { owner = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive); } MessageDialog messageDialog = new MessageDialog() { Content = content }; OverlayWindow window = new OverlayWindow() { Content = messageDialog, Owner = owner }; switch (type) { case MessageDialogType.Accent: window.Style = (Style)window.FindResource("AccentOverlayWindowStyle"); break; case MessageDialogType.Dark: window.Style = (Style)window.FindResource("DarkOverlayWindowStyle"); break; } messageDialog.Header = new TextBlock() { Style = (Style)window.FindResource("HeaderTextStyle"), Text = header }; if ((button == MessageBoxButton.OK) || (button == MessageBoxButton.OKCancel)) { messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.OK); } }), Content = "Ok" }); } if ((button == MessageBoxButton.YesNo) || (button == MessageBoxButton.YesNoCancel)) { messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.Yes); } }), Content = "Yes" }); messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.No); } }), Content = "No" }); } if ((button == MessageBoxButton.OKCancel) || (button == MessageBoxButton.YesNoCancel)) { messageDialog.Items.Add( new MessageDialogButton() { Command = new DelegateCommand( () => { if (!taskCompletionSource.Task.IsCompleted) { window.Close(); taskCompletionSource.SetResult(MessageBoxResult.Cancel); } }), Content = "Cancel" }); } messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1; window.Show(); return taskCompletionSource.Task; }
public void ShowMessageDialog(string text, string caption, MessageDialogType type) { Console.WriteLine(string.Format("XMA: Message dialog shown: Text: {0}, Caption: {1}", text, caption)); }
public int ShowMessage(MessageDialogType messageType, string message) { return(ShellHelper.ShowMessage(_package, messageType, "", message)); }
public void ShowMessageDialog(string text, string caption, MessageDialogType type) { MessageBox.Show(text, caption, MessageBoxButton.OK); }