2021-03-29 23:16:11 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2022-03-18 22:48:14 +04:00
|
|
|
|
namespace ToolsDesktop.Helpers
|
2021-03-29 23:16:11 +04:00
|
|
|
|
{
|
|
|
|
|
public static class DialogHelper
|
|
|
|
|
{
|
2021-04-01 21:30:29 +04:00
|
|
|
|
public static DialogResult MessageInformation(string message, string title) =>
|
|
|
|
|
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
|
2021-03-29 23:16:11 +04:00
|
|
|
|
public static DialogResult MessageQuestion(string message, string title) =>
|
|
|
|
|
MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
2021-04-01 21:30:29 +04:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-29 23:16:11 +04:00
|
|
|
|
}
|
|
|
|
|
}
|