/// <summary> /// Displays a message box with the specified text, caption, buttons, icon and default button. /// The text can be copied. /// </summary> /// <param name="message">The text to display in the message box. This text can be copied.</param> /// <param name="caption">The text to display in the title bar of the message box.</param> /// <param name="buttons">One of the <see cref="CopyableMessageBoxButtons"/> values that specifies which buttons to display in the message box. /// If not specified, <see cref="CopyableMessageBoxButtons.OK"/> is used.</param> /// <param name="icon">One of the <see cref="CopyableMessageBoxIcon"/> values that specifies which icon to display in the message box. /// If not specified, <see cref="CopyableMessageBoxIcon.None"/> is used.</param> /// <param name="defBtn">The zero-based index of the default button. /// If not specified, <c>0</c> is used.</param> /// <returns>The zero-based index of the button pressed.</returns> public static int Show(string message, string caption, CopyableMessageBoxButtons buttons = CopyableMessageBoxButtons.OK, CopyableMessageBoxIcon icon = CopyableMessageBoxIcon.None, int defBtn = 0) { int cncBtn = enumToCncBtn(buttons); return(Show(message, caption, icon, enumToList(buttons), defBtn, cncBtn)); }
private static IList <string> enumToList(CopyableMessageBoxButtons buttons) { switch (buttons) { case CopyableMessageBoxButtons.OKCancel: return(new List <string>(new string[] { "&OK", "&Cancel", })); case CopyableMessageBoxButtons.AbortRetryIgnore: return(new List <string>(new string[] { "&Abort", "&Retry", "&Ignore", })); case CopyableMessageBoxButtons.RetryCancel: return(new List <string>(new string[] { "&Retry", "&Cancel", })); case CopyableMessageBoxButtons.YesNoCancel: return(new List <string>(new string[] { "&Yes", "&No", "&Cancel", })); case CopyableMessageBoxButtons.YesNo: return(new List <string>(new string[] { "&Yes", "&No", })); case CopyableMessageBoxButtons.OK: default: return(new List <string>(new string[] { "&OK", })); } }
private static int enumToCncBtn(CopyableMessageBoxButtons buttons) { switch (buttons) { case CopyableMessageBoxButtons.OK: return(0); case CopyableMessageBoxButtons.OKCancel: return(1); case CopyableMessageBoxButtons.RetryCancel: return(1); case CopyableMessageBoxButtons.AbortRetryIgnore: return(-1); case CopyableMessageBoxButtons.YesNoCancel: return(2); case CopyableMessageBoxButtons.YesNo: return(-1); default: return(-1); } }
private static IList<string> enumToList(CopyableMessageBoxButtons buttons) { switch (buttons) { case CopyableMessageBoxButtons.OKCancel: return new List<string>(new string[] { "&OK", "&Cancel", }); case CopyableMessageBoxButtons.AbortRetryIgnore: return new List<string>(new string[] { "&Abort", "&Retry", "&Ignore", }); case CopyableMessageBoxButtons.RetryCancel: return new List<string>(new string[] { "&Retry", "&Cancel", }); case CopyableMessageBoxButtons.YesNoCancel: return new List<string>(new string[] { "&Yes", "&No", "&Cancel", }); case CopyableMessageBoxButtons.YesNo: return new List<string>(new string[] { "&Yes", "&No", }); case CopyableMessageBoxButtons.OK: default: return new List<string>(new string[] { "&OK", }); } }
private static int enumToCncBtn(CopyableMessageBoxButtons buttons) { switch (buttons) { case CopyableMessageBoxButtons.OK: return 0; case CopyableMessageBoxButtons.OKCancel: return 1; case CopyableMessageBoxButtons.RetryCancel: return 1; case CopyableMessageBoxButtons.AbortRetryIgnore: return -1; case CopyableMessageBoxButtons.YesNoCancel: return 2; case CopyableMessageBoxButtons.YesNo: return -1; default: return -1; } }
/// <summary> /// Displays a message box with the specified text, caption, icon, buttons, default button and cancel button. /// The text can be copied. /// </summary> /// <param name="message">The text to display in the message box. This text can be copied.</param> /// <param name="caption">The text to display in the title bar of the message box.</param> /// <param name="buttons">One of the <see cref="CopyableMessageBoxButtons"/> values that specifies which buttons to display in the message box.</param> /// <param name="icon">One of the <see cref="CopyableMessageBoxIcon"/> values that specifies which icon to display in the message box.</param> /// <param name="defBtn">The zero-based index of the default button.</param> /// <param name="cncBtn">The zero-based index of the cancel button.</param> /// <returns>The zero-based index of the button pressed.</returns> public static int Show(string message, string caption, CopyableMessageBoxButtons buttons, CopyableMessageBoxIcon icon, int defBtn, int cncBtn) { return Show(message, caption, icon, enumToList(buttons), defBtn, cncBtn); }
/// <summary> /// Displays a message box with the specified text, caption, buttons, icon and default button. /// The text can be copied. /// </summary> /// <param name="message">The text to display in the message box. This text can be copied.</param> /// <param name="caption">The text to display in the title bar of the message box.</param> /// <param name="buttons">One of the <see cref="CopyableMessageBoxButtons"/> values that specifies which buttons to display in the message box. /// If not specified, <see cref="CopyableMessageBoxButtons.OK"/> is used.</param> /// <param name="icon">One of the <see cref="CopyableMessageBoxIcon"/> values that specifies which icon to display in the message box. /// If not specified, <see cref="CopyableMessageBoxIcon.None"/> is used.</param> /// <param name="defBtn">The zero-based index of the default button. /// If not specified, <c>0</c> is used.</param> /// <returns>The zero-based index of the button pressed.</returns> public static int Show(string message, string caption, CopyableMessageBoxButtons buttons = CopyableMessageBoxButtons.OK, CopyableMessageBoxIcon icon = CopyableMessageBoxIcon.None, int defBtn = 0) { int cncBtn = enumToCncBtn(buttons); return Show(message, caption, icon, enumToList(buttons), defBtn, cncBtn); }
/// <summary> /// Displays a message box with the specified text, caption, icon, buttons, default button and cancel button. /// The text can be copied. /// </summary> /// <param name="message">The text to display in the message box. This text can be copied.</param> /// <param name="caption">The text to display in the title bar of the message box.</param> /// <param name="buttons">One of the <see cref="CopyableMessageBoxButtons"/> values that specifies which buttons to display in the message box.</param> /// <param name="icon">One of the <see cref="CopyableMessageBoxIcon"/> values that specifies which icon to display in the message box.</param> /// <param name="defBtn">The zero-based index of the default button.</param> /// <param name="cncBtn">The zero-based index of the cancel button.</param> /// <returns>The zero-based index of the button pressed.</returns> public static int Show(string message, string caption, CopyableMessageBoxButtons buttons, CopyableMessageBoxIcon icon, int defBtn, int cncBtn) { return(Show(message, caption, icon, enumToList(buttons), defBtn, cncBtn)); }