DepartmentProject/DepartmentPortal/Common/ToolsDesktop/Helpers/DialogHelper.cs

35 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
2022-03-18 22:48:14 +04:00
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);
}
}
}
}