using CoreUnit.Common; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.IO; using System.Linq; using System.Windows.Forms; namespace CoreUnit.Commons { /* Author: BlueMystic (bluemystic.play@gmail.com) 2024 */ public static class Messenger { /// Shows an Error Message. /// an Exception error to show /// public static DialogResult MesageBox(Exception ex, bool ShowTrace = true) => MesageBox(ex.Message + (ShowTrace ? "\r\n" + ex.StackTrace : ""), "Error!", icon: MessageBoxIcon.Error); /// Displays a message window, also known as a dialog box, which presents a message to the user. /// The text to display in the message box. /// The text to display in the title bar of the message box. /// One of the 'Base64Icons.MsgIcon' values that specifies which icon to display in the message box. /// One of the MessageBoxButtons values that specifies which buttons to display in the message box. /// It is a modal window, blocking other actions in the application until the user closes it. public static DialogResult MesageBox( string Message, string title, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information) { Debug.WriteLine(icon.ToString()); Base64Icons.MsgIcon Icon = Base64Icons.MsgIcon.None; /* "..In current implementations there are ONLY four unique symbols with multiple values assigned to them." https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.messageboxicon?view=netframework-4.8 */ switch (icon) { case MessageBoxIcon.Information: Icon = Base64Icons.MsgIcon.Info; break; case MessageBoxIcon.Exclamation: Icon = Base64Icons.MsgIcon.Success; break; case MessageBoxIcon.Question: Icon = Base64Icons.MsgIcon.Question; break; case MessageBoxIcon.Error: Icon = Base64Icons.MsgIcon.Cancel; break; default: break; } return MesageBox(Message, title, Icon, buttons); } /// Displays a message window, also known as a dialog box, which presents a message to the user. /// The text to display in the message box. /// The text to display in the title bar of the message box. /// One of the 'Base64Icons.MsgIcon' values that specifies which icon to display in the message box. /// One of the MessageBoxButtons values that specifies which buttons to display in the message box. /// It is a modal window, blocking other actions in the application until the user closes it. public static DialogResult MesageBox( string Message, string title, Base64Icons.MsgIcon Icon, MessageBoxButtons buttons = MessageBoxButtons.OK) { Form form = new Form { FormBorderStyle = FormBorderStyle.FixedDialog, StartPosition = FormStartPosition.CenterParent, MaximizeBox = false, MinimizeBox = false, Text = title, Width = 340, Height = 170 }; DarkModeCS DMode = new DarkModeCS(form); Base64Icons _Icons = new Base64Icons(); #region Bottom Panel & Buttons Panel bottomPanel = new Panel { Dock = DockStyle.Bottom, Height = 48, BackColor = DMode.OScolors.Surface, ForeColor = DMode.OScolors.TextActive }; form.Controls.Add(bottomPanel); string CurrentLanguage = GetCurrentLanguage(); var ButtonTranslations = GetButtonTranslations(CurrentLanguage); //<- "OK|Cancel|Yes|No|Continue|Retry|Abort" List