using System; using System.Collections.Generic; using System.Linq; using System.Text; using Deltares.Standard; using System.Windows.Forms; using Deltares.Standard.Language; namespace Deltares.Dam.Forms { /// /// Summary description for LocalizedMessageBox /// public class LocalizedMessageBox { private static DialogResult Show(string message, MessageBoxButtons buttons, MessageBoxIcon icon) { // Get the product name to use as dialog caption string caption = About.Product; return MessageBox.Show(message, caption, buttons, icon); } public static DialogResult Show(object targetObject, string translationId) { return Show(targetObject, translationId, MessageBoxButtons.OK, MessageBoxIcon.Information); } public static DialogResult Show(object targetObject, string translationId, MessageBoxButtons buttons, MessageBoxIcon icon, Object[] args = null) { // Convert the translationId into a localized message string translatedMessage = LocalizationManager.GetTranslatedText(targetObject, translationId); // Substitute the parameters in the translated message string finalMessage = translatedMessage; if (args != null) { finalMessage = string.Format(translatedMessage, args); } return Show(finalMessage, buttons, icon); } public static DialogResult ShowTranslatedText(string message) { return Show(message, MessageBoxButtons.OK, MessageBoxIcon.Information); } public static DialogResult ShowError(object targetObject, string translationId, Object[] args = null) { return Show(targetObject, translationId, MessageBoxButtons.OK, MessageBoxIcon.Error, args); } public static DialogResult ShowException(string exceptionMessage) { return Show(exceptionMessage, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }