// // // // // $Revision: 3772 $ // using System; namespace ICSharpCode.Core.Services { /// /// Description of IMessageService. /// public interface IMessageService { /// /// Shows an error. /// If is null, the message is shown inside /// a message box. /// Otherwise, the custom error reporter is used to display /// the exception error. /// void ShowError(Exception ex, string message); /// /// Shows a warning message. /// void ShowWarning(string message); /// /// Asks the user a Yes/No question, using "Yes" as the default button. /// Returns true if yes was clicked, false if no was clicked. /// bool AskQuestion(string question, string caption); /// /// Shows a custom dialog. /// /// The title of the dialog. /// The description shown in the dialog. /// /// The number of the button that is the default accept button. /// Use -1 if you don't want to have an accept button. /// /// /// The number of the button that is the cancel button. /// Use -1 if you don't want to have a cancel button. /// /// The captions of the buttons. /// The number of the button that was clicked, or -1 if the dialog was closed without clicking a button. int ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts); string ShowInputBox(string caption, string dialogText, string defaultValue); void ShowMessage(string message, string caption); /// /// Show a message informing the user about a save error. /// void InformSaveError(string fileName, string message, string dialogName, Exception exceptionGot); /// /// Show a message informing the user about a save error, /// and allow him to retry/save under alternative name. /// ChooseSaveErrorResult ChooseSaveError(string fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled); } public sealed class ChooseSaveErrorResult { public bool IsRetry { get; private set; } public bool IsIgnore { get; private set; } public bool IsSaveAlternative { get { return AlternativeFileName != null; } } public string AlternativeFileName { get; private set; } private ChooseSaveErrorResult() {} public readonly static ChooseSaveErrorResult Retry = new ChooseSaveErrorResult { IsRetry = true }; public readonly static ChooseSaveErrorResult Ignore = new ChooseSaveErrorResult { IsIgnore = true }; public static ChooseSaveErrorResult SaveAlternative(string alternativeFileName) { return new ChooseSaveErrorResult { AlternativeFileName = alternativeFileName }; } } }