using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace ToolsDesktop.Helpers { public static class DialogHelper { public static DialogResult MessageInformation(string message, string title) => MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Information); public static DialogResult MessageQuestion(string message, string title) => MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question); public static DialogResult MessageQuestion(string message) => MessageBox.Show(message, "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question); public static DialogResult MessageException(string message) => MessageBox.Show(message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); public static DialogResult MessageException(string message, string title) => MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error); public static DialogResult MessageException(List<(string Title, string Message)> messages, string title) { if (messages.Count == 1) { return MessageBox.Show(messages.First().Message, messages.First().Title, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { return MessageBox.Show(string.Join(Environment.NewLine, messages.Select(x=> $"{x.Title}:{x.Message}")), title, MessageBoxButtons.OK, MessageBoxIcon.Error); } } public static DialogResult MessageException(Exception e, string title) { var list = new List(); while(e != null) { list.Add(e.Message); e = e.InnerException; } return MessageBox.Show(string.Join(Environment.NewLine, list), title, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }