OLD | NEW |
| (Empty) |
1 /// Copyright (c) Microsoft Corporation. All rights reserved. | |
2 | |
3 using System; | |
4 using System.Diagnostics; | |
5 using Microsoft.VisualStudio; | |
6 using Microsoft.VisualStudio.Shell.Interop; | |
7 | |
8 namespace Microsoft.VisualStudio.Project | |
9 { | |
10 /// <summary> | |
11 ///This class provides some useful static shell based methods. | |
12 /// </summary> | |
13 [CLSCompliant(false)] | |
14 public static class UIHierarchyUtilities | |
15 { | |
16 /// <summary> | |
17 /// Get reference to IVsUIHierarchyWindow interface from guid pe
rsistence slot. | |
18 /// </summary> | |
19 /// <param name="serviceProvider">The service provider.</param> | |
20 /// <param name="persistenceSlot">Unique identifier for a tool w
indow created using IVsUIShell::CreateToolWindow. | |
21 /// The caller of this method can use predefined identifiers tha
t map to tool windows if those tool windows | |
22 /// are known to the caller. </param> | |
23 /// <returns>A reference to an IVsUIHierarchyWindow interface.</
returns> | |
24 public static IVsUIHierarchyWindow GetUIHierarchyWindow(IService
Provider serviceProvider, Guid persistenceSlot) | |
25 { | |
26 if(serviceProvider == null) | |
27 { | |
28 throw new ArgumentNullException("serviceProvider
"); | |
29 } | |
30 | |
31 IVsUIShell shell = serviceProvider.GetService(typeof(SVs
UIShell)) as IVsUIShell; | |
32 | |
33 Debug.Assert(shell != null, "Could not get the ui shell
from the project"); | |
34 if(shell == null) | |
35 { | |
36 throw new InvalidOperationException(); | |
37 } | |
38 | |
39 object pvar = null; | |
40 IVsWindowFrame frame = null; | |
41 IVsUIHierarchyWindow uiHierarchyWindow = null; | |
42 | |
43 try | |
44 { | |
45 ErrorHandler.ThrowOnFailure(shell.FindToolWindow
(0, ref persistenceSlot, out frame)); | |
46 ErrorHandler.ThrowOnFailure(frame.GetProperty((i
nt)__VSFPROPID.VSFPROPID_DocView, out pvar)); | |
47 } | |
48 finally | |
49 { | |
50 if(pvar != null) | |
51 { | |
52 uiHierarchyWindow = (IVsUIHierarchyWindo
w)pvar; | |
53 } | |
54 } | |
55 | |
56 return uiHierarchyWindow; | |
57 } | |
58 } | |
59 } | |
OLD | NEW |