Repository navigation
Expand file tree
/
Copy pathMessageHelper.cs
More file actions
69 lines (63 loc) · 2.5 KB
/
Copy pathMessageHelper.cs
File metadata and controls
69 lines (63 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
namespace NuGet.VisualStudio
{
public static class MessageHelper
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")]
public static void ShowWarningMessage(string message, string title)
{
VsShellUtilities.ShowMessageBox(
ServiceLocator.GetInstance<IServiceProvider>(),
message,
title,
OLEMSGICON.OLEMSGICON_WARNING,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")]
public static void ShowInfoMessage(string message, string title)
{
VsShellUtilities.ShowMessageBox(
ServiceLocator.GetInstance<IServiceProvider>(),
message,
title,
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
public static void ShowErrorMessage(Exception exception, string title)
{
ShowErrorMessage(ExceptionUtility.Unwrap(exception).Message, title);
}
public static void ShowErrorMessage(string message, string title)
{
VsShellUtilities.ShowMessageBox(
ServiceLocator.GetInstance<IServiceProvider>(),
message,
title,
OLEMSGICON.OLEMSGICON_CRITICAL,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
public static bool? ShowQueryMessage(string message, string title, bool showCancelButton)
{
int result = VsShellUtilities.ShowMessageBox(
ServiceLocator.GetInstance<IServiceProvider>(),
message,
title,
OLEMSGICON.OLEMSGICON_QUERY,
showCancelButton ? OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL : OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
if (result == NativeMethods.IDCANCEL)
{
return null;
}
else
{
return (result == NativeMethods.IDYES);
}
}
}
}