/// <summary> /// Displays an error message box /// </summary> /// <param name="errorMessage">The error error message to display</param> /// <param name="isRTL">(Optional) If true the MessageBox FlowDirection will be RightToLeft</param> public static string ShowError(string errorMessage, bool isRTL = false) { try { using var msg = new InputBoxWindow { Title = "Error" }; msg.TxtTitle.Text = "Error"; msg.TxtMessage.Text = errorMessage; msg.TitleBackgroundPanel.Background = Brushes.Red; msg.BorderBrush = Brushes.Red; msg.BtnCancel.Visibility = Visibility.Collapsed; if (isRTL) { msg.FlowDirection = FlowDirection.RightToLeft; } msg.BtnOk.Focus(); msg.ShowDialog(); return(msg.InputTxt.Text); } catch (Exception) { System.Windows.MessageBox.Show(errorMessage); return(null); } }
/// <summary> /// Displays a message box with a cancel button /// </summary> /// <param name="message">The message to display</param> /// <param name="isRTL">(Optional) If true the MessageBox FlowDirection will be RightToLeft</param> /// <returns>Message box Result OK or CANCEL</returns> public static MessageBoxResult ShowWithCancel(string message, bool isRTL = false) { try { using var msg = new InputBoxWindow { Title = MessageBoxTitle }; msg.TxtTitle.Text = MessageBoxTitle; msg.TxtMessage.Text = message; msg.TitleBackgroundPanel.Background = new SolidColorBrush(Color.FromRgb(3, 169, 244)); msg.BorderBrush = new SolidColorBrush(Color.FromRgb(3, 169, 244)); if (isRTL) { msg.FlowDirection = FlowDirection.RightToLeft; } msg.BtnOk.Focus(); msg.ShowDialog(); return(msg.Result == MessageBoxResult.OK ? MessageBoxResult.OK : MessageBoxResult.Cancel); } catch (Exception) { System.Windows.MessageBox.Show(message); return(MessageBoxResult.Cancel); } }
/// <summary> /// Displays a message box with OK button /// </summary> /// <param name="message">The message to display</param> /// <param name="title">The title of the message box</param> /// <param name="isRTL">(Optional) If true the MessageBox FlowDirection will be RightToLeft</param> public static string Show(string message, string title, bool isRTL = false) { using var msg = new InputBoxWindow { Title = title }; msg.TxtTitle.Text = title; msg.TxtMessage.Text = message; msg.TitleBackgroundPanel.Background = new SolidColorBrush(Color.FromRgb(3, 169, 244)); msg.BorderBrush = new SolidColorBrush(Color.FromRgb(3, 169, 244)); msg.BtnCancel.Visibility = Visibility.Collapsed; if (isRTL) { msg.FlowDirection = FlowDirection.RightToLeft; } msg.BtnOk.Focus(); msg.ShowDialog(); return(msg.InputTxt.Text); }