src/Misc/EFTools/EntityDesign/VisualStudio/VsUtils.cs
// <summary>
//     Helper method to show a message box within the shell.
// </summary>
// <param name="serviceProvider"></param>
// <param name="messageText">Text to show.</param>
// <param name="f1Keyword">F1-keyword.</param>
// <param name="messageButtons">Buttons which should appear in the dialog.</param>
// <param name="defaultButton">Default button (invoked when user presses return).</param>
// <param name="messageIcon">Icon (warning, error, informational, etc.) to display</param>
// <returns>result corresponding to the button clicked by the user.</returns>
Helper method to show a message box within the shell.
Helper method to show a message box within the shell .
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1614:ElementParameterDocumentationMustHaveText")]
        public static DialogResult ShowMessageBox(
            IServiceProvider serviceProvider, string messageText, string f1Keyword, OLEMSGBUTTON messageButtons,
            OLEMSGDEFBUTTON defaultButton, OLEMSGICON messageIcon)
        {
            var result = 0;
            Debug.Assert(serviceProvider != null, "ServiceProvider was null");
            if (serviceProvider != null)
            {
                var uiShell = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
                Debug.Assert(uiShell != null, "ServiceProvider returned null for SVsUIShell");
                if (uiShell != null)
                {
                    var rclsidComp = Guid.Empty;
                    VSErrorHandler.ThrowOnFailure(
                        uiShell.ShowMessageBox(
                            0, ref rclsidComp, null, messageText, f1Keyword, 0, messageButtons, defaultButton, messageIcon, 0, out result));
                }
            }
            else
            {
                Debug.Fail("Unable to get IUIService.  Falling back on MessageBox.Show()");
                MessageBoxOptions options = 0;
                if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
                {
                    options = MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading;
                }
                MessageBox.Show(
                    null, messageText, Resources.Application_Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1, options);
            }
            return (DialogResult)result;
        }
[ SuppressMessage ( " " , " " ) ] public static DialogResult ShowMessageBox ( IServiceProvider serviceProvider , string messageText , string f1Keyword , OLEMSGBUTTON messageButtons , OLEMSGDEFBUTTON defaultButton , OLEMSGICON messageIcon ) { var result = 0 ; Debug . Assert ( serviceProvider != null , " " ) ; if ( serviceProvider != null ) { var uiShell = ( IVsUIShell ) serviceProvider . GetService ( typeof ( SVsUIShell ) ) ; Debug . Assert ( uiShell != null , " " ) ; if ( uiShell != null ) { var rclsidComp = Guid . Empty ; VSErrorHandler . ThrowOnFailure ( uiShell . ShowMessageBox ( 0 , ref rclsidComp , null , messageText , f1Keyword , 0 , messageButtons , defaultButton , messageIcon , 0 , out result ) ) ; } } else { Debug . Fail ( " " ) ; MessageBoxOptions options = 0 ; if ( CultureInfo . CurrentUICulture . TextInfo . IsRightToLeft ) { options = MessageBoxOptions . RightAlign | MessageBoxOptions . RtlReading ; } MessageBox . Show ( null , messageText , Resources . Application_Caption , MessageBoxButtons . OK , MessageBoxIcon . Exclamation , MessageBoxDefaultButton . Button1 , options ) ; } return ( DialogResult ) result ; }
Helper method to show a message box within the shell.
Helper method to show a message box within the shell .
result corresponding to the button clicked by the user.
result corresponding to the button clicked by the user .
serviceProvider
IServiceProvider
None
messageText
string
Text to show.
Text to show .
f1Keyword
string
None
messageButtons
OLEMSGBUTTON
Buttons which should appear in the dialog.
Buttons which should appear in the dialog .
defaultButton
OLEMSGDEFBUTTON
Default button (invoked when user presses return).
Default button ( invoked when user presses return ) .
messageIcon
OLEMSGICON
Icon (warning, error, informational, etc.) to display
Icon ( warning error informational etc . ) to display