// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Windows.Forms; using Deltares.Standard; using Deltares.Standard.Forms.DExpress; using Deltares.Standard.Language; namespace Deltares.Dam.Forms { /// /// Summary description for LocalizedMessageBox /// public abstract class LocalizedMessageBox { 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); } // Get the product name to use as dialog caption string caption = About.Product; return MessageBox.Show(targetObject as IWin32Window, finalMessage, caption, buttons, icon); } public static DialogResult ShowTranslatedText(MainForm mainForm, string message) { return Show(mainForm, 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); } 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); } } }